Browse Source

New JackIOAdapter and JackCoreAudioIOAdapter classes

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2573 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
f40b4dcf0d
5 changed files with 100 additions and 7 deletions
  1. +42
    -0
      common/JackIOAdapter.h
  2. +12
    -5
      common/JackNetIOAdapter.cpp
  3. +3
    -1
      common/JackNetIOAdapter.h
  4. +1
    -1
      common/wscript
  5. +42
    -0
      macosx/JackCoreAudioIOAdapter.h

+ 42
- 0
common/JackIOAdapter.h View File

@@ -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

+ 12
- 5
common/JackNetIOAdapter.cpp View File

@@ -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;
}
}


+ 3
- 1
common/JackNetIOAdapter.h View File

@@ -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();
};
}


+ 1
- 1
common/wscript View File

@@ -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


+ 42
- 0
macosx/JackCoreAudioIOAdapter.h View File

@@ -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

Loading…
Cancel
Save