ALSABackend: elaborate on start-up error cases
This commit is contained in:
parent
daaa59b533
commit
03cb44f814
@ -436,9 +436,17 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
|||||||
|
|
||||||
unsigned int pos = _capture_device.find(" ");
|
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);
|
_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 ()) {
|
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;
|
delete _pcmi; _pcmi = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -410,6 +410,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_state = -2;
|
||||||
if (_play_handle)
|
if (_play_handle)
|
||||||
{
|
{
|
||||||
if (snd_pcm_hw_params_malloc (&_play_hwpar) < 0)
|
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 (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");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested sample rate for playback.\n");
|
||||||
|
_state = -3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (snd_pcm_hw_params_get_period_size (_play_hwpar, &fsize, &dir) || (fsize != _fsize) || dir)
|
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");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested period size for playback.\n");
|
||||||
|
_state = -4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (snd_pcm_hw_params_get_periods (_play_hwpar, &nfrag, &dir) || (nfrag != _nfrag) || dir)
|
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");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested number of periods for playback.\n");
|
||||||
|
_state = -5;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,6 +507,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle playback sample format.\n");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle playback sample format.\n");
|
||||||
|
_state = -6;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||||
@ -540,6 +545,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle playback sample format.\n");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle playback sample format.\n");
|
||||||
|
_state = -6;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#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 (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");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested sample rate for capture.\n");
|
||||||
|
_state = -3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (snd_pcm_hw_params_get_period_size (_capt_hwpar, &fsize, &dir) || (fsize != _fsize) || dir)
|
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");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested period size for capture.\n");
|
||||||
|
_state = -4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (snd_pcm_hw_params_get_periods (_capt_hwpar, &nfrag, &dir) || (nfrag != _nfrag) || dir)
|
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");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested number of periods for capture.\n");
|
||||||
|
_state = -5;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,6 +614,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle capture sample format.\n");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle capture sample format.\n");
|
||||||
|
_state = -6;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||||
@ -636,6 +646,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle capture sample format.\n");
|
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't handle capture sample format.\n");
|
||||||
|
_state = -6;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user