Messages in this thread | | | Subject | Re: [RFC PATCH] ALSA: compress: Fix gapless playback state machine | From | Pierre-Louis Bossart <> | Date | Wed, 10 Jun 2020 07:56:05 -0500 |
| |
On 6/10/20 5:07 AM, Srinivas Kandagatla wrote: > For gapless playback call to snd_compr_drain_notify() after > partial drain should put the state to SNDRV_PCM_STATE_RUNNING > rather than SNDRV_PCM_STATE_SETUP as the driver is ready to > process the buffers for new track. > > With existing code, if we are playing 3 tracks in gapless, after
The gapless playback only deals with transitions between two tracks of identical format. I am not sure what the reference to 3 tracks means.
> partial drain finished on previous track 1 the state is set to > SNDRV_PCM_STATE_SETUP which is then moved to SNDRV_PCM_STATE_PREPARED > after data write. With this state calls to snd_compr_next_track() and > few other calls will fail as they expect the state to be in > SNDRV_PCM_STATE_RUNNING. > > Here is the sequence of events and state transitions: > > 1. set_params (Track 1), state = SNDRV_PCM_STATE_SETUP > 2. set_metadata (Track 1), no state change, state = SNDRV_PCM_STATE_SETUP > 3. fill and trigger start (Track 1), state = SNDRV_PCM_STATE_RUNNING > 4. set_next_track (Track 2), state = SNDRV_PCM_STATE_RUNNING > 5. partial_drain (Track 1), state = SNDRV_PCM_STATE_SETUP > 6 snd_compr_drain_notify (Track 1), state = SNDRV_PCM_STATE_SETUP > 7. fill data (Track 2), state = SNDRV_PCM_STATE_PREPARED > 8. set_metadata (Track 3), no state change, state = SNDRV_PCM_STATE_PREPARED > 9. set_next_track (Track 3), !! FAILURE as state != SNDRV_PCM_STATE_RUNNING > > Fixes: f44f2a5417b2 ("ALSA: compress: fix drain calls blocking other compress functions (v6)") > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > --- > > I wonder who did gapless work on upstream so far?
IIRC the only users of gapless playback are Android platforms, where the HAL deals with the transitions. I am not aware of any plain vanilla Linux solution.
> > include/sound/compress_driver.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h > index 6ce8effa0b12..eabac33864c2 100644 > --- a/include/sound/compress_driver.h > +++ b/include/sound/compress_driver.h > @@ -182,7 +182,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) > if (snd_BUG_ON(!stream)) > return; > > - stream->runtime->state = SNDRV_PCM_STATE_SETUP; > + stream->runtime->state = SNDRV_PCM_STATE_RUNNING; > > wake_up(&stream->runtime->sleep); > } >
| |