--- a/sc2src/alsadirect.cpp
+++ b/sc2src/alsadirect.cpp
@@ -793,4 +793,26 @@
return (void *)1;
}
-AudioEater alsaAudioEater(AudioEater::BO_HOST, &audioEater);
+// Map the ALSA state to the audio eater state.
+static AudioEater::AudioState audioState()
+{
+ snd_pcm_state_t pcm_state;
+ AudioEater::AudioState state = AudioEater::AudioState::UNKNOWN;
+
+ if (pcm != nullptr) {
+ pcm_state = snd_pcm_state(pcm);
+ LOGDEB("alsaEater: PCM state " << pcm_state << endl);
+ switch (pcm_state) {
+ case SND_PCM_STATE_RUNNING:
+ state = AudioEater::AudioState::PLAYING;
+ break;
+ default:
+ state = AudioEater::AudioState::STOPPED;
+ break;
+ }
+ }
+
+ return state;
+}
+
+AudioEater alsaAudioEater(AudioEater::BO_HOST, &audioEater, &audioState);