_freewheeling = false;
_freewheel = false;
- PortAudioIO::ErrorCode err;
+ PaErrorCode err = paNoError;
err = _pcmio->open_blocking_stream(name_to_id(_input_audio_device),
name_to_id(_output_audio_device),
_samplerate,
_samples_per_period);
+ // reintepret Portaudio error messages
switch (err) {
- case PortAudioIO::NoError:
+ case paNoError:
break;
- case PortAudioIO::DeviceConfigNotSupportedError:
- PBD::error << get_error_string(DeviceConfigurationNotSupportedError)
- << endmsg;
- return -1;
default:
- PBD::error << get_error_string(AudioDeviceOpenError) << endmsg;
return -1;
}
manager.registration_callback();
manager.graph_order_callback();
- if (_pcmio->start_stream() != PortAudioIO::NoError) {
+ if (_pcmio->start_stream() != paNoError) {
_pcmio->close_stream ();
_active = false;
engine.halted_callback(get_error_string(AudioDeviceIOError).c_str());
_cur_output_latency = 0;
}
-PortAudioIO::ErrorCode
+PaErrorCode
PortAudioIO::close_stream()
{
- if (!_stream) return NoError;
+ if (!_stream) return paNoError;
PaError err = Pa_CloseStream (_stream);
if (err != paNoError) {
- return StreamCloseError;
+ return (PaErrorCode)err;
}
_stream = NULL;
free (_input_buffer); _input_buffer = NULL;
free (_output_buffer); _output_buffer = NULL;
- return NoError;
+ return paNoError;
}
-PortAudioIO::ErrorCode
+PaErrorCode
PortAudioIO::start_stream()
{
PaError err = Pa_StartStream (_stream);
if (err != paNoError) {
- return StreamStartError;
+ DEBUG_AUDIO(string_compose("PortAudio failed to start stream %1\n",
+ Pa_GetErrorText(err)));
+ return (PaErrorCode)err;
}
- return NoError;
+ return paNoError;
}
bool
return true;
}
-PortAudioIO::ErrorCode
+PaErrorCode
PortAudioIO::pre_stream_open(int device_input,
PaStreamParameters& inputParam,
int device_output,
{
if (!pa_initialize()) {
DEBUG_AUDIO ("PortAudio Initialization Failed\n");
- return InitializationError;
+ return paNotInitialized;
}
reset_stream_dependents ();
"PortAudio Device IDs: i:%1 o:%2\n", device_input, device_output));
if (device_input == DeviceNone && device_output == DeviceNone) {
- return DeviceConfigNotSupportedError;
+ return paBadIODeviceCombination;
}
if (get_input_stream_params(device_input, inputParam)) {
if (_capture_channels == 0 && _playback_channels == 0) {
DEBUG_AUDIO("PortAudio no input or output channels.\n");
- return DeviceConfigNotSupportedError;
+ return paBadIODeviceCombination;
}
DEBUG_AUDIO (string_compose ("PortAudio Channels: in:%1 out:%2\n",
_capture_channels,
_playback_channels));
- return NoError;
+ return paNoError;
}
-PortAudioIO::ErrorCode
+PaErrorCode
PortAudioIO::open_blocking_stream(int device_input,
int device_output,
double sample_rate,
PaStreamParameters inputParam;
PaStreamParameters outputParam;
- ErrorCode error_code =
+ PaErrorCode error_code =
pre_stream_open(device_input, inputParam, device_output, outputParam);
- if (error_code != NoError) return error_code;
+ if (error_code != paNoError) return error_code;
PaError err = paNoError;
NULL, NULL);
if (err != paNoError) {
- DEBUG_AUDIO ("PortAudio failed to start stream.\n");
- return StreamOpenError;
+ DEBUG_AUDIO(string_compose("PortAudio failed to open stream %1\n",
+ Pa_GetErrorText(err)));
+ return (PaErrorCode)err;
}
if (!set_sample_rate_and_latency_from_stream()) {
DEBUG_AUDIO ("PortAudio failed to query stream information.\n");
close_stream();
- return StreamOpenError;
+ return paInternalError;
}
if (!allocate_buffers_for_blocking_api(samples_per_period)) {
close_stream();
- return StreamOpenError;
+ return paInternalError;
}
- return NoError;
+ return paNoError;
}
int
PortAudioIO (void);
~PortAudioIO (void);
- enum ErrorCode {
- NoError = 0,
- InitializationError,
- DeInitializationError,
- DeviceConfigNotSupportedError,
- StreamOpenError,
- StreamStartError,
- StreamStopError,
- StreamCloseError,
- IOError,
- BufferUnderrunError,
- BufferOverrunError
- };
-
enum StandardDevices {
DeviceNone = -2,
DeviceDefault = -1
std::string control_app_name (int device_id) const;
void launch_control_app (int device_id);
- ErrorCode open_blocking_stream(int device_input,
+ PaErrorCode open_blocking_stream(int device_input,
int device_output,
double sample_rate,
uint32_t samples_per_period);
- ErrorCode start_stream(void);
+ PaErrorCode start_stream(void);
- ErrorCode close_stream(void);
+ PaErrorCode close_stream(void);
uint32_t n_playback_channels (void) const { return _playback_channels; }
uint32_t n_capture_channels (void) const { return _capture_channels; }
bool set_sample_rate_and_latency_from_stream();
bool allocate_buffers_for_blocking_api (uint32_t samples_per_period);
- ErrorCode pre_stream_open(int device_input,
+ PaErrorCode pre_stream_open(int device_input,
PaStreamParameters& inputParam,
int device_output,
PaStreamParameters& outputParam);