diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index 7ce83ddc40..68f54fbe46 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -436,9 +436,17 @@ AlsaAudioBackend::_start (bool for_latency_measurement) unsigned int pos = _capture_device.find(" "); _pcmi = new Alsa_pcmi (_capture_device.substr(0, pos).c_str(), _playback_device.substr(0, pos).c_str(), 0, _samplerate, _samples_per_period, _periods_per_cycle, 0); + switch (_pcmi->state ()) { + case 0: /* OK */ break; + case -1: PBD::error << _("AlsaAudioBackend: failed to open device.") << endmsg; break; + case -2: PBD::error << _("AlsaAudioBackend: failed to allocate parameters.") << endmsg; break; + case -3: PBD::error << _("AlsaAudioBackend: cannot set requested sample rate.") << endmsg; break; + case -4: PBD::error << _("AlsaAudioBackend: cannot set requested period size.") << endmsg; break; + case -5: PBD::error << _("AlsaAudioBackend: cannot set requested number of periods.") << endmsg; break; + case -6: PBD::error << _("AlsaAudioBackend: unsupported sample format.") << endmsg; break; + default: PBD::error << _("AlsaAudioBackend: initialization failed.") << endmsg; break; + } if (_pcmi->state ()) { - // TODO get detailed error from _pcmi - PBD::error << _("AlsaAudioBackend: failed to open device (see stderr for details).") << endmsg; delete _pcmi; _pcmi = 0; return -1; } diff --git a/libs/backends/alsa/zita-alsa-pcmi.cc b/libs/backends/alsa/zita-alsa-pcmi.cc index 8947e1a12e..10b8e08831 100644 --- a/libs/backends/alsa/zita-alsa-pcmi.cc +++ b/libs/backends/alsa/zita-alsa-pcmi.cc @@ -410,6 +410,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const } } + _state = -2; if (_play_handle) { if (snd_pcm_hw_params_malloc (&_play_hwpar) < 0) @@ -447,16 +448,19 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const if (snd_pcm_hw_params_get_rate (_play_hwpar, &fsamp, &dir) || (fsamp != _fsamp) || dir) { if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested sample rate for playback.\n"); + _state = -3; return; } if (snd_pcm_hw_params_get_period_size (_play_hwpar, &fsize, &dir) || (fsize != _fsize) || dir) { if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested period size for playback.\n"); + _state = -4; return; } if (snd_pcm_hw_params_get_periods (_play_hwpar, &nfrag, &dir) || (nfrag != _nfrag) || dir) { if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested number of periods for playback.\n"); + _state = -5; return; } @@ -503,6 +507,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const default: if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle playback sample format.\n"); + _state = -6; return; } #elif __BYTE_ORDER == __BIG_ENDIAN @@ -540,6 +545,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const default: if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle playback sample format.\n"); + _state = -6; return; } #else @@ -554,16 +560,19 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const if (snd_pcm_hw_params_get_rate (_capt_hwpar, &fsamp, &dir) || (fsamp != _fsamp) || dir) { if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested sample rate for capture.\n"); + _state = -3; return; } if (snd_pcm_hw_params_get_period_size (_capt_hwpar, &fsize, &dir) || (fsize != _fsize) || dir) { if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested period size for capture.\n"); + _state = -4; return; } if (snd_pcm_hw_params_get_periods (_capt_hwpar, &nfrag, &dir) || (nfrag != _nfrag) || dir) { if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested number of periods for capture.\n"); + _state = -5; return; } @@ -605,6 +614,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const default: if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle capture sample format.\n"); + _state = -6; return; } #elif __BYTE_ORDER == __BIG_ENDIAN @@ -636,6 +646,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const default: if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle capture sample format.\n"); + _state = -6; return; } #else