output/alsa: Fix (theoretical error in) ALSA device recovery

It is not possible to prepare an ALSA device when it is is state
SND_PCM_STATE_OPEN; it is necessary to set the hardware parameters
first.

This pedantic commit corrects that error. Note that in practice
this code path cannot be encountered because MPD always sets the
hardware parameters before attempting to start playback.
This commit is contained in:
borine 2023-12-22 12:02:33 +00:00
parent 50e6950fa8
commit b1f28d6003

View File

@ -910,7 +910,6 @@ AlsaOutput::Recover(int err) noexcept
/* fall-through to snd_pcm_prepare: */
[[fallthrough]];
case SND_PCM_STATE_OPEN:
case SND_PCM_STATE_SETUP:
case SND_PCM_STATE_XRUN:
period_buffer.Rewind();
@ -918,6 +917,7 @@ AlsaOutput::Recover(int err) noexcept
err = snd_pcm_prepare(pcm);
break;
case SND_PCM_STATE_OPEN:
case SND_PCM_STATE_DISCONNECTED:
case SND_PCM_STATE_DRAINING:
/* can't play in this state; throw the error */