Skip to content

Commit 4475f8c

Browse files
charleskeepaxtiwai
authored andcommitted
ALSA: compress: Fix regression on compressed capture streams
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]>
1 parent e4091bd commit 4475f8c

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

include/sound/compress_driver.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
173173
if (snd_BUG_ON(!stream))
174174
return;
175175

176-
if (stream->direction == SND_COMPRESS_PLAYBACK)
177-
stream->runtime->state = SNDRV_PCM_STATE_SETUP;
178-
else
179-
stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
176+
stream->runtime->state = SNDRV_PCM_STATE_SETUP;
180177

181178
wake_up(&stream->runtime->sleep);
182179
}

sound/core/compress_offload.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,7 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
574574
stream->metadata_set = false;
575575
stream->next_track = false;
576576

577-
if (stream->direction == SND_COMPRESS_PLAYBACK)
578-
stream->runtime->state = SNDRV_PCM_STATE_SETUP;
579-
else
580-
stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
577+
stream->runtime->state = SNDRV_PCM_STATE_SETUP;
581578
} else {
582579
return -EPERM;
583580
}
@@ -693,8 +690,17 @@ static int snd_compr_start(struct snd_compr_stream *stream)
693690
{
694691
int retval;
695692

696-
if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED)
693+
switch (stream->runtime->state) {
694+
case SNDRV_PCM_STATE_SETUP:
695+
if (stream->direction != SND_COMPRESS_CAPTURE)
696+
return -EPERM;
697+
break;
698+
case SNDRV_PCM_STATE_PREPARED:
699+
break;
700+
default:
697701
return -EPERM;
702+
}
703+
698704
retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START);
699705
if (!retval)
700706
stream->runtime->state = SNDRV_PCM_STATE_RUNNING;

0 commit comments

Comments
 (0)