mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-05 21:25:46 +01:00
Use PortAudioIO::ErrorCode as return value from PortAudioIO::pcm_setup
This commit is contained in:
parent
4e75220661
commit
fd0b54f459
3 changed files with 25 additions and 29 deletions
|
|
@ -456,20 +456,22 @@ PortAudioBackend::_start (bool for_latency_measurement)
|
|||
_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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -681,18 +681,16 @@ PortAudioIO::get_output_stream_params(int device_output,
|
|||
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 ();
|
||||
|
|
@ -701,10 +699,7 @@ PortAudioIO::pcm_setup (
|
|||
"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;
|
||||
|
|
@ -720,13 +715,14 @@ PortAudioIO::pcm_setup (
|
|||
|
||||
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 (
|
||||
|
|
@ -740,22 +736,22 @@ PortAudioIO::pcm_setup (
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -90,12 +90,10 @@ public:
|
|||
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; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue