From 9bf9ba35b03ea79a4ecd708510bf335df2eba5a4 Mon Sep 17 00:00:00 2001 From: amir Date: Fri, 14 Feb 2020 14:06:40 +0200 Subject: [PATCH] fix bug - song start time after end of file would cause no STOP indication to be sent --- src/alsa_frames_transfer.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/alsa_frames_transfer.cc b/src/alsa_frames_transfer.cc index bcb7998..c31f3de 100644 --- a/src/alsa_frames_transfer.cc +++ b/src/alsa_frames_transfer.cc @@ -204,7 +204,11 @@ namespace wavplayeralsa { bool AlsaFramesTransfer::IsAlsaStatePlaying() { int status = snd_pcm_state(alsa_playback_handle_); - return (status == SND_PCM_STATE_RUNNING) || (status == SND_PCM_STATE_PREPARED); + // the code had SND_PCM_STATE_PREPARED as well. + // it is removed, to resolve issue of song start playing after end of file. + // the drain function would not finish since the status is 'SND_PCM_STATE_PREPARED' + // because no frames were sent to alsa. + return (status == SND_PCM_STATE_RUNNING); // || (status == SND_PCM_STATE_PREPARED); } void AlsaFramesTransfer::StartPlay(uint32_t position_in_ms, uint32_t play_seq_id)