Commit 01bb4f0f authored by moret's avatar moret
Browse files

AlsaAdapter compiles again with profiling records.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3016 0c269be4-1314-0410-8aa9-9f06e86f4224
parent f5b6fd75
......@@ -33,38 +33,38 @@ namespace Jack
{
//static methods ***********************************************************
int JackAudioAdapter::Process(jack_nframes_t frames, void* arg)
int JackAudioAdapter::Process ( jack_nframes_t frames, void* arg )
{
JackAudioAdapter* adapter = static_cast<JackAudioAdapter*>(arg);
JackAudioAdapter* adapter = static_cast<JackAudioAdapter*> ( arg );
float* buffer;
bool failure = false;
int i;
if (!adapter->fAudioAdapter->IsRunning())
if ( !adapter->fAudioAdapter->IsRunning() )
return 0;
// DLL
adapter->fAudioAdapter->SetCallbackTime(jack_get_time());
adapter->fAudioAdapter->SetCallbackTime ( jack_get_time() );
// Push/pull from ringbuffer
for (i = 0; i < adapter->fCaptureChannels; i++)
for ( i = 0; i < adapter->fCaptureChannels; i++ )
{
buffer = static_cast<float*>(jack_port_get_buffer(adapter->fCapturePortList[i], frames));
if (adapter->fCaptureRingBuffer[i]->Read(buffer, frames) < frames)
buffer = static_cast<float*> ( jack_port_get_buffer ( adapter->fCapturePortList[i], frames ) );
if ( adapter->fCaptureRingBuffer[i]->Read ( buffer, frames ) < frames )
failure = true;
}
for (i = 0; i < adapter->fPlaybackChannels; i++)
for ( i = 0; i < adapter->fPlaybackChannels; i++ )
{
buffer = static_cast<float*>(jack_port_get_buffer(adapter->fPlaybackPortList[i], frames));
if (adapter->fPlaybackRingBuffer[i]->Write(buffer, frames) < frames)
buffer = static_cast<float*> ( jack_port_get_buffer ( adapter->fPlaybackPortList[i], frames ) );
if ( adapter->fPlaybackRingBuffer[i]->Write ( buffer, frames ) < frames )
failure = true;
}
// Reset all ringbuffers in case of failure
if (failure)
if ( failure )
{
jack_error("JackCallbackAudioAdapter::Process ringbuffer failure... reset");
jack_error ( "JackCallbackAudioAdapter::Process ringbuffer failure... reset" );
adapter->Reset();
}
return 0;
......@@ -72,7 +72,7 @@ namespace Jack
int JackAudioAdapter::BufferSize ( jack_nframes_t buffer_size, void* arg )
{
JackAudioAdapter* adapter = static_cast<JackAudioAdapter*>(arg);
JackAudioAdapter* adapter = static_cast<JackAudioAdapter*> ( arg );
adapter->Reset();
adapter->fAudioAdapter->SetHostBufferSize ( buffer_size );
return 0;
......@@ -80,9 +80,9 @@ namespace Jack
int JackAudioAdapter::SampleRate ( jack_nframes_t sample_rate, void* arg )
{
JackAudioAdapter* adapter = static_cast<JackAudioAdapter*>(arg);
JackAudioAdapter* adapter = static_cast<JackAudioAdapter*> ( arg );
adapter->Reset();
adapter->fAudioAdapter->SetHostSampleRate(sample_rate);
adapter->fAudioAdapter->SetHostSampleRate ( sample_rate );
return 0;
}
......@@ -91,10 +91,10 @@ namespace Jack
{
// When called, Close has already been used for the client, thus ports are already unregistered.
int i;
for (i = 0; i < fCaptureChannels; i++)
delete(fCaptureRingBuffer[i]);
for (i = 0; i < fPlaybackChannels; i++)
delete(fPlaybackRingBuffer[i]);
for ( i = 0; i < fCaptureChannels; i++ )
delete ( fCaptureRingBuffer[i] );
for ( i = 0; i < fPlaybackChannels; i++ )
delete ( fPlaybackRingBuffer[i] );
delete[] fCaptureRingBuffer;
delete[] fPlaybackRingBuffer;
......@@ -107,9 +107,9 @@ namespace Jack
for ( i = 0; i < fCaptureChannels; i++ )
if ( fCapturePortList[i] )
jack_port_unregister ( fJackClient, fCapturePortList[i] );
for (i = 0; i < fCaptureChannels; i++)
for ( i = 0; i < fCaptureChannels; i++ )
if ( fPlaybackPortList[i] )
jack_port_unregister (fJackClient, fPlaybackPortList[i] );
jack_port_unregister ( fJackClient, fPlaybackPortList[i] );
delete[] fCapturePortList;
delete[] fPlaybackPortList;
......@@ -118,9 +118,9 @@ namespace Jack
void JackAudioAdapter::Reset()
{
int i;
for (i = 0; i < fCaptureChannels; i++)
for ( i = 0; i < fCaptureChannels; i++ )
fCaptureRingBuffer[i]->Reset();
for (i = 0; i < fPlaybackChannels; i++)
for ( i = 0; i < fPlaybackChannels; i++ )
fPlaybackRingBuffer[i]->Reset();
fAudioAdapter->Reset();
}
......@@ -132,8 +132,8 @@ namespace Jack
fCaptureChannels = fAudioAdapter->GetInputs();
fPlaybackChannels = fAudioAdapter->GetOutputs();
jack_log("JackAudioAdapter::Open fCaptureChannels %d fPlaybackChannels %d", fCaptureChannels, fPlaybackChannels);
jack_log ( "JackAudioAdapter::Open fCaptureChannels %d fPlaybackChannels %d", fCaptureChannels, fPlaybackChannels );
//ringbuffers
fCaptureRingBuffer = new JackResampler*[fCaptureChannels];
......@@ -142,26 +142,26 @@ namespace Jack
fCaptureRingBuffer[i] = new JackLibSampleRateResampler();
for ( i = 0; i < fPlaybackChannels; i++ )
fPlaybackRingBuffer[i] = new JackLibSampleRateResampler();
fAudioAdapter->SetRingBuffers(fCaptureRingBuffer, fPlaybackRingBuffer);
fAudioAdapter->SetRingBuffers ( fCaptureRingBuffer, fPlaybackRingBuffer );
if ( fCaptureChannels )
jack_log ( "ReadSpace = %ld", fCaptureRingBuffer[0]->ReadSpace() );
if ( fPlaybackChannels )
jack_log ( "WriteSpace = %ld", fPlaybackRingBuffer[0]->WriteSpace() );
jack_log ( "ReadSpace = %ld", fCaptureRingBuffer[0]->ReadSpace() );
if ( fPlaybackChannels )
jack_log ( "WriteSpace = %ld", fPlaybackRingBuffer[0]->WriteSpace() );
//jack ports
fCapturePortList = new jack_port_t* [fCaptureChannels];
fPlaybackPortList = new jack_port_t* [fPlaybackChannels];
for (i = 0; i < fCaptureChannels; i++)
for ( i = 0; i < fCaptureChannels; i++ )
{
sprintf(name, "capture_%d", i+1);
sprintf ( name, "capture_%d", i+1 );
if ( ( fCapturePortList[i] = jack_port_register ( fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ) ) == NULL )
goto fail;
}
for (i = 0; i < fPlaybackChannels; i++)
for ( i = 0; i < fPlaybackChannels; i++ )
{
sprintf(name, "playback_%d", i+1);
sprintf ( name, "playback_%d", i+1 );
if ( ( fPlaybackPortList[i] = jack_port_register ( fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 ) ) == NULL )
goto fail;
}
......@@ -179,7 +179,7 @@ namespace Jack
//ringbuffers and jack clients are ok, we can now open the adapter driver interface
return fAudioAdapter->Open();
fail:
fail:
FreePorts();
return -1;
}
......
......@@ -27,43 +27,43 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
namespace Jack
{
/*!
\brief Audio adapter : Jack client side.
*/
/*!
\brief Audio adapter : Jack client side.
*/
class JackAudioAdapter
{
private:
class JackAudioAdapter
{
private:
static int Process(jack_nframes_t, void* arg);
static int BufferSize(jack_nframes_t buffer_size, void *arg);
static int SampleRate(jack_nframes_t sample_rate, void *arg);
static int Process ( jack_nframes_t, void* arg );
static int BufferSize ( jack_nframes_t buffer_size, void *arg );
static int SampleRate ( jack_nframes_t sample_rate, void *arg );
int fCaptureChannels;
int fPlaybackChannels;
int fCaptureChannels;
int fPlaybackChannels;
JackResampler** fCaptureRingBuffer;
JackResampler** fPlaybackRingBuffer;
JackResampler** fCaptureRingBuffer;
JackResampler** fPlaybackRingBuffer;
jack_port_t** fCapturePortList;
jack_port_t** fPlaybackPortList;
jack_port_t** fCapturePortList;
jack_port_t** fPlaybackPortList;
jack_client_t* fJackClient;
JackAudioAdapterInterface* fAudioAdapter;
jack_client_t* fJackClient;
JackAudioAdapterInterface* fAudioAdapter;
void FreePorts();
void Reset();
void FreePorts();
void Reset();
public:
public:
JackAudioAdapter(jack_client_t* jack_client, JackAudioAdapterInterface* audio_io) :
fJackClient(jack_client), fAudioAdapter(audio_io)
{}
~JackAudioAdapter();
JackAudioAdapter ( jack_client_t* jack_client, JackAudioAdapterInterface* audio_io ) :
fJackClient ( jack_client ), fAudioAdapter ( audio_io )
{}
~JackAudioAdapter();
int Open();
int Close();
};
int Open();
int Close();
};
}
......
......@@ -17,6 +17,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include "JackAlsaAdapter.h"
#include "JackServer.h"
#include "JackEngineControl.h"
......@@ -209,14 +213,14 @@ extern "C"
jack_driver_desc_t *desc;
jack_driver_param_desc_t * params;
unsigned int i;
desc = (jack_driver_desc_t*)calloc(1, sizeof(jack_driver_desc_t));
strcpy(desc->name, "audioadapter"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy(desc->desc, "netjack audio <==> net backend adapter"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
desc = ( jack_driver_desc_t* ) calloc ( 1, sizeof ( jack_driver_desc_t ) );
strcpy ( desc->name, "audioadapter" ); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy ( desc->desc, "netjack audio <==> net backend adapter" ); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
desc->nparams = 9;
params = (jack_driver_param_desc_t*)calloc(desc->nparams, sizeof(jack_driver_param_desc_t));
params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) );
i = 0;
strcpy ( params[i].name, "capture" );
......
......@@ -94,7 +94,7 @@ namespace Jack
for ( i = 0; NetErrorList[i].code >= 0; ++i )
{
if ( error == NetErrorList[i].code )
return NetErrorList[i].msg;
return NetErrorList[i].msg.c_str();
}
return strerror ( error );
}
......
......@@ -40,7 +40,7 @@ namespace Jack
struct _win_net_error
{
int code;
char* msg;
std::string msg;
};
SERVER_EXPORT const char* PrintError ( int error );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment