Skip to content

Commit

Permalink
ALSA: compress: Fix regression on compressed capture streams
Browse files Browse the repository at this point in the history
A previous fix to the stop handling on compressed capture streams causes
some knock on issues. The previous fix updated snd_compr_drain_notify to
set the state back to PREPARED for capture streams. This causes some
issues however as the handling for snd_compr_poll differs between the
two states and some user-space applications were relying on the poll
failing after the stream had been stopped.

To correct this regression whilst still fixing the original problem the
patch was addressing, update the capture handling to skip the PREPARED
state rather than skipping the SETUP state as it has done until now.

Fixes: 4f2ab5e ("ALSA: compress: Fix stop handling on compressed capture streams")
Signed-off-by: Charles Keepax <[email protected]>
Acked-by: Vinod Koul <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
charleskeepax authored and tiwai committed Jul 23, 2019
1 parent e4091bd commit 4475f8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 1 addition & 4 deletions include/sound/compress_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
if (snd_BUG_ON(!stream))
return;

if (stream->direction == SND_COMPRESS_PLAYBACK)
stream->runtime->state = SNDRV_PCM_STATE_SETUP;
else
stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
stream->runtime->state = SNDRV_PCM_STATE_SETUP;

wake_up(&stream->runtime->sleep);
}
Expand Down
16 changes: 11 additions & 5 deletions sound/core/compress_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,7 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
stream->metadata_set = false;
stream->next_track = false;

if (stream->direction == SND_COMPRESS_PLAYBACK)
stream->runtime->state = SNDRV_PCM_STATE_SETUP;
else
stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
stream->runtime->state = SNDRV_PCM_STATE_SETUP;
} else {
return -EPERM;
}
Expand Down Expand Up @@ -693,8 +690,17 @@ static int snd_compr_start(struct snd_compr_stream *stream)
{
int retval;

if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED)
switch (stream->runtime->state) {
case SNDRV_PCM_STATE_SETUP:
if (stream->direction != SND_COMPRESS_CAPTURE)
return -EPERM;
break;
case SNDRV_PCM_STATE_PREPARED:
break;
default:
return -EPERM;
}

retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START);
if (!retval)
stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
Expand Down

0 comments on commit 4475f8c

Please sign in to comment.