_freewheeling = false;
_freewheel = false;
- _pcmio->pcm_setup (name_to_id(_input_audio_device), name_to_id(_output_audio_device), _samplerate, _samples_per_period);
+ PortAudioIO::ErrorCode err;
- switch (_pcmio->state ()) {
- case 0: /* OK */
- break;
- case -1:
- PBD::error << get_error_string(AudioDeviceOpenError) << endmsg;
+ err = _pcmio->pcm_setup(name_to_id(_input_audio_device),
+ name_to_id(_output_audio_device),
+ _samplerate,
+ _samples_per_period);
+
+ switch (err) {
+ case PortAudioIO::NoError:
break;
+ case PortAudioIO::DeviceConfigNotSupportedError:
+ PBD::error << get_error_string(DeviceConfigurationNotSupportedError)
+ << endmsg;
+ return -1;
default:
PBD::error << get_error_string(AudioDeviceOpenError) << endmsg;
- break;
- }
-
- if (_pcmio->state ()) {
return -1;
}
return true;
}
-int
+PortAudioIO::ErrorCode
PortAudioIO::pcm_setup (
int device_input, int device_output,
double sample_rate, uint32_t samples_per_period)
{
_state = -2;
- PaError err = paNoError;
-
if (!initialize_pa()) {
DEBUG_AUDIO ("PortAudio Initialization Failed\n");
- return -1;
+ return InitializationError;
}
reset_stream_dependents ();
"PortAudio Device IDs: i:%1 o:%2\n", device_input, device_output));
if (device_input == DeviceNone && device_output == DeviceNone) {
- // just send the error msg for now rather than return it
- error << AudioBackend::get_error_string(AudioBackend::DeviceConfigurationNotSupportedError)
- << endmsg;
- return -1;
+ return DeviceConfigNotSupportedError;
}
PaStreamParameters inputParam;
if (_capture_channels == 0 && _playback_channels == 0) {
DEBUG_AUDIO("PortAudio no input or output channels.\n");
- return -1;
+ return DeviceConfigNotSupportedError;
}
DEBUG_AUDIO (string_compose ("PortAudio Channels: in:%1 out:%2\n",
_capture_channels,
_playback_channels));
+ PaError err = paNoError;
// XXX re-consider using callback API, testing needed.
err = Pa_OpenStream (
if (err != paNoError) {
DEBUG_AUDIO ("PortAudio failed to start stream.\n");
- return -1;
+ return StreamOpenError;
}
if (!set_sample_rate_and_latency_from_stream()) {
DEBUG_AUDIO ("PortAudio failed to query stream information.\n");
pcm_stop();
- return -1;
+ return StreamOpenError;
}
_state = 0;
if (!allocate_buffers_for_blocking_api(samples_per_period)) {
pcm_stop();
- return -1;
+ return StreamOpenError;
}
- return 0;
+ return NoError;
}
int
void pcm_stop (void);
int pcm_start (void);
- int pcm_setup (
- int device_input,
- int device_output,
- double sample_rate,
- uint32_t samples_per_period
- );
+ ErrorCode pcm_setup(int device_input,
+ int device_output,
+ double sample_rate,
+ uint32_t samples_per_period);
uint32_t n_playback_channels (void) const { return _playback_channels; }
uint32_t n_capture_channels (void) const { return _capture_channels; }