From f40b4dcf0d2cee53387276af301a6efb27eca7e6 Mon Sep 17 00:00:00 2001 From: sletz Date: Wed, 2 Jul 2008 12:45:33 +0000 Subject: [PATCH] New JackIOAdapter and JackCoreAudioIOAdapter classes git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2573 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackIOAdapter.h | 42 +++++++++++++++++++++++++++++++++ common/JackNetIOAdapter.cpp | 17 +++++++++---- common/JackNetIOAdapter.h | 4 +++- common/wscript | 2 +- macosx/JackCoreAudioIOAdapter.h | 42 +++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 common/JackIOAdapter.h create mode 100644 macosx/JackCoreAudioIOAdapter.h diff --git a/common/JackIOAdapter.h b/common/JackIOAdapter.h new file mode 100644 index 00000000..db0da192 --- /dev/null +++ b/common/JackIOAdapter.h @@ -0,0 +1,42 @@ +/* +Copyright (C) 2008 Grame + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __JackIOAdapter__ +#define __JackIOAdapter__ + +namespace Jack +{ + + class JackIOAdapterInterface + { + private: + + public: + + JackIOAdapterInterface() + {} + ~JackIOAdapterInterface() + {} + + void SetRingBuffers(jack_ringbuffer_t* input, jack_ringbuffer_t* output) + {} + }; +} + +#endif diff --git a/common/JackNetIOAdapter.cpp b/common/JackNetIOAdapter.cpp index 0871c200..cb181e5e 100644 --- a/common/JackNetIOAdapter.cpp +++ b/common/JackNetIOAdapter.cpp @@ -27,7 +27,7 @@ using namespace std; namespace Jack { -#define DEFAULT_RB_SIZE 16384 /* ringbuffer size in frames */ +#define DEFAULT_RB_SIZE 16384 /* ringbuffer size in frames */ int JackNetIOAdapter::Process(jack_nframes_t frames, void* arg) { @@ -64,7 +64,7 @@ int JackNetIOAdapter::Process(jack_nframes_t frames, void* arg) return 0; } -JackNetIOAdapter::JackNetIOAdapter(jack_client_t* jack_client) +JackNetIOAdapter::JackNetIOAdapter(jack_client_t* jack_client, JackIOAdapterInterface* audio_io) { int i; char name[32]; @@ -72,6 +72,8 @@ JackNetIOAdapter::JackNetIOAdapter(jack_client_t* jack_client) fCaptureChannels = 2; fPlaybackChannels = 2; + fIOAdapter = audio_io; + fCapturePortList = new jack_port_t* [fCaptureChannels]; fPlaybackPortList = new jack_port_t* [fPlaybackChannels]; @@ -83,6 +85,8 @@ JackNetIOAdapter::JackNetIOAdapter(jack_client_t* jack_client) if (fPlaybackRingBuffer == NULL) goto fail; + fIOAdapter->SetRingBuffers(fCaptureRingBuffer, fPlaybackRingBuffer); + for (i = 0; i < fCaptureChannels; i++) { sprintf(name, "in_%d", i+1); if ((fCapturePortList[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)) == NULL) @@ -94,7 +98,7 @@ JackNetIOAdapter::JackNetIOAdapter(jack_client_t* jack_client) if ((fPlaybackPortList[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0)) == NULL) goto fail; } - + if (jack_set_process_callback(fJackClient, Process, this) < 0) goto fail; @@ -109,7 +113,8 @@ fail: JackNetIOAdapter::~JackNetIOAdapter() { - FreePorts(); + // When called Close has already been sued for the client, thus ports are already unregistered. + delete fIOAdapter; } void JackNetIOAdapter::FreePorts() @@ -145,6 +150,8 @@ extern "C" { #endif +#include "JackCoreAudioIOAdapter.h" + EXPORT int jack_initialize(jack_client_t* jack_client, const char* load_init) { if (adapter) { @@ -152,7 +159,7 @@ extern "C" return 1; } else { jack_log("Loading NetAudio Adapter"); - adapter = new Jack::JackNetIOAdapter(jack_client); + adapter = new Jack::JackNetIOAdapter(jack_client, new Jack::JackCoreAudioIOAdapter()); return (adapter) ? 0 : 1; } } diff --git a/common/JackNetIOAdapter.h b/common/JackNetIOAdapter.h index e9b35d99..d0f9a8d0 100644 --- a/common/JackNetIOAdapter.h +++ b/common/JackNetIOAdapter.h @@ -22,6 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "jack.h" #include "ringbuffer.h" +#include "JackIOAdapter.h" namespace Jack { @@ -40,13 +41,14 @@ namespace Jack jack_ringbuffer_t* fPlaybackRingBuffer; jack_client_t* fJackClient; + JackIOAdapterInterface* fIOAdapter; static int Process(jack_nframes_t, void* arg); void FreePorts(); public: - JackNetIOAdapter(jack_client_t* jack_client); + JackNetIOAdapter(jack_client_t* jack_client, JackIOAdapterInterface* audio_io); ~JackNetIOAdapter(); }; } diff --git a/common/wscript b/common/wscript index aad4f87b..dc172d3e 100644 --- a/common/wscript +++ b/common/wscript @@ -41,7 +41,7 @@ def subst_func(tsk): def create_jack_process_obj(bld, target, sources, uselib = None): process = bld.create_obj('cpp', 'shlib') process.env['shlib_PATTERN'] = '%s.so' - process.includes = ['./jack', '.'] + process.includes = ['./jack', '.', '../macosx'] process.name = target process.target = target process.source = sources diff --git a/macosx/JackCoreAudioIOAdapter.h b/macosx/JackCoreAudioIOAdapter.h new file mode 100644 index 00000000..3c0a7620 --- /dev/null +++ b/macosx/JackCoreAudioIOAdapter.h @@ -0,0 +1,42 @@ +/* +Copyright (C) 2008 Grame + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __JackCoreAudioIOAdapter__ +#define __JackCoreAudioIOAdapter__ + +#include "JackIOAdapter.h" + +namespace Jack +{ + + class JackCoreAudioIOAdapter : public JackIOAdapterInterface + { + private: + + public: + + JackCoreAudioIOAdapter() + {} + ~JackCoreAudioIOAdapter() + {} + + }; +} + +#endif