Browse Source

Code factorization on JackPortAudioDriver.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4251 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.8
sletz 14 years ago
parent
commit
38fbcf2de4
4 changed files with 49 additions and 72 deletions
  1. +1
    -1
      common/JackWaitThreadedDriver.h
  2. +5
    -6
      windows/portaudio/JackPortAudioDevices.cpp
  3. +42
    -65
      windows/portaudio/JackPortAudioDriver.cpp
  4. +1
    -0
      windows/portaudio/JackPortAudioDriver.h

+ 1
- 1
common/JackWaitThreadedDriver.h View File

@@ -22,7 +22,7 @@
#define __JackWaitThreadedDriver__

#include "JackThreadedDriver.h"
#include "JackAudioDriver.h"
#include "JackDriver.h"

namespace Jack
{


+ 5
- 6
windows/portaudio/JackPortAudioDevices.cpp View File

@@ -27,19 +27,18 @@ PortAudioDevices::PortAudioDevices()
PaError err;
PaDeviceIndex id;
jack_log("Initializing PortAudio...");
if ( ( err = Pa_Initialize() ) == paNoError )
{
if ((err = Pa_Initialize() ) == paNoError) {
fNumHostApi = Pa_GetHostApiCount();
fNumDevice = Pa_GetDeviceCount();
fDeviceInfo = new PaDeviceInfo*[fNumDevice];
for ( id = 0; id < fNumDevice; id++ )
for (id = 0; id < fNumDevice; id++)
fDeviceInfo[id] = const_cast<PaDeviceInfo*>(Pa_GetDeviceInfo(id));
fHostName = new string[fNumHostApi];
for ( id = 0; id < fNumHostApi; id++ )
for (id = 0; id < fNumHostApi; id++)
fHostName[id] = string ( Pa_GetHostApiInfo(id)->name );
}
else
} else {
jack_error("JackPortAudioDriver::Pa_Initialize error = %s", Pa_GetErrorText(err));
}
}

PortAudioDevices::~PortAudioDevices()


+ 42
- 65
windows/portaudio/JackPortAudioDriver.cpp View File

@@ -60,6 +60,40 @@ namespace Jack
return 0;
}

int JackPortAudioDriver::OpenStream()
{
PaStreamParameters inputParameters;
PaStreamParameters outputParameters;

// Update parameters
inputParameters.device = fInputDevice;
inputParameters.channelCount = fCaptureChannels;
inputParameters.sampleFormat = paFloat32 | paNonInterleaved; // 32 bit floating point output
inputParameters.suggestedLatency = (fInputDevice != paNoDevice) // TODO: check how to setup this on ASIO
? Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency
: 0;
inputParameters.hostApiSpecificStreamInfo = NULL;

outputParameters.device = fOutputDevice;
outputParameters.channelCount = fPlaybackChannels;
outputParameters.sampleFormat = paFloat32 | paNonInterleaved; // 32 bit floating point output
outputParameters.suggestedLatency = (fOutputDevice != paNoDevice) // TODO: check how to setup this on ASIO
? Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency
: 0;
outputParameters.hostApiSpecificStreamInfo = NULL;

PaError err = Pa_OpenStream(&fStream,
(fInputDevice == paNoDevice) ? 0 : &inputParameters,
(fOutputDevice == paNoDevice) ? 0 : &outputParameters,
fEngineControl->fSampleRate,
buffer_size,
paNoFlag, // Clipping is on...
Render,
this);

return (err == paNoError) ? 0: -1;
}

int JackPortAudioDriver::Open(jack_nframes_t buffer_size,
jack_nframes_t samplerate,
bool capturing,
@@ -72,9 +106,6 @@ namespace Jack
jack_nframes_t capture_latency,
jack_nframes_t playback_latency)
{
PaError err = paNoError;
PaStreamParameters inputParameters;
PaStreamParameters outputParameters;
int in_max = 0;
int out_max = 0;

@@ -117,32 +148,7 @@ namespace Jack
outchannels = out_max;
}

//in/out streams parametering
inputParameters.device = fInputDevice;
inputParameters.channelCount = inchannels;
inputParameters.sampleFormat = paFloat32 | paNonInterleaved; // 32 bit floating point output
inputParameters.suggestedLatency = (fInputDevice != paNoDevice) // TODO: check how to setup this on ASIO
? fPaDevices->GetDeviceInfo(fInputDevice)->defaultLowInputLatency
: 0;
inputParameters.hostApiSpecificStreamInfo = NULL;

outputParameters.device = fOutputDevice;
outputParameters.channelCount = outchannels;
outputParameters.sampleFormat = paFloat32 | paNonInterleaved; // 32 bit floating point output
outputParameters.suggestedLatency = (fOutputDevice != paNoDevice) // TODO: check how to setup this on ASIO
? fPaDevices->GetDeviceInfo(fOutputDevice)->defaultLowOutputLatency
: 0;
outputParameters.hostApiSpecificStreamInfo = NULL;

err = Pa_OpenStream(&fStream,
(fInputDevice == paNoDevice) ? 0 : &inputParameters,
(fOutputDevice == paNoDevice) ? 0 : &outputParameters,
samplerate,
buffer_size,
paNoFlag, // Clipping is on...
Render,
this);
if (err != paNoError) {
if (OpenStream() < 0) {
jack_error("Pa_OpenStream error = %s", Pa_GetErrorText(err));
goto error;
}
@@ -208,41 +214,13 @@ error:
int JackPortAudioDriver::SetBufferSize(jack_nframes_t buffer_size)
{
PaError err;
PaStreamParameters inputParameters;
PaStreamParameters outputParameters;

if ((err = Pa_CloseStream(fStream)) != paNoError) {
jack_error("Pa_CloseStream error = %s", Pa_GetErrorText(err));
return -1;
}

// Update parameters
inputParameters.device = fInputDevice;
inputParameters.channelCount = fCaptureChannels;
inputParameters.sampleFormat = paFloat32 | paNonInterleaved; // 32 bit floating point output
inputParameters.suggestedLatency = (fInputDevice != paNoDevice) // TODO: check how to setup this on ASIO
? Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency
: 0;
inputParameters.hostApiSpecificStreamInfo = NULL;

outputParameters.device = fOutputDevice;
outputParameters.channelCount = fPlaybackChannels;
outputParameters.sampleFormat = paFloat32 | paNonInterleaved; // 32 bit floating point output
outputParameters.suggestedLatency = (fOutputDevice != paNoDevice) // TODO: check how to setup this on ASIO
? Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency
: 0;
outputParameters.hostApiSpecificStreamInfo = NULL;

err = Pa_OpenStream(&fStream,
(fInputDevice == paNoDevice) ? 0 : &inputParameters,
(fOutputDevice == paNoDevice) ? 0 : &outputParameters,
fEngineControl->fSampleRate,
buffer_size,
paNoFlag, // Clipping is on...
Render,
this);

if (err != paNoError) {
if (OpenStream() < 0) {
jack_error("Pa_OpenStream error = %s", Pa_GetErrorText(err));
return -1;
} else {
@@ -402,8 +380,7 @@ extern "C"
{
param = (const jack_driver_param_t *) node->data;

switch (param->character)
{
switch (param->character) {

case 'd':
capture_pcm_name = param->value.str;
@@ -474,12 +451,12 @@ extern "C"
}

Jack::JackDriverClientInterface* driver = new Jack::JackPortAudioDriver("system", "portaudio", engine, table, pa_devices);
if (driver->Open(frames_per_interrupt, srate, capture, playback, chan_in, chan_out, monitor, capture_pcm_name, playback_pcm_name, systemic_input_latency, systemic_output_latency) == 0)
{
if (driver->Open(frames_per_interrupt, srate, capture, playback,
chan_in, chan_out, monitor, capture_pcm_name,
playback_pcm_name, systemic_input_latency,
systemic_output_latency) == 0) {
return driver;
}
else
{
} else {
delete driver;
return NULL;
}


+ 1
- 0
windows/portaudio/JackPortAudioDriver.h View File

@@ -49,6 +49,7 @@ class JackPortAudioDriver : public JackAudioDriver
void* userData);

void UpdateLatencies();
int OpenStream();

public:



Loading…
Cancel
Save