Skip to contentSkip to conversation

ALSA: compress: Fix stop handling on compressed capture streams

PATCH In review Charles Keepax 2 participants 2 messages Feb 5, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: compress: Fix stop handling on compressed capture streams

It is normal user behaviour to start, stop, then start a stream again without closing it. Currently this works for compressed playback streams but not capture ones.

The states on a compressed capture stream go directly from OPEN to PREPARED, unlike a playback stream which moves to SETUP and waits for a write of data before moving to PREPARED. Currently however, when a stop is sent the state is set to SETUP for both types of streams. This leaves a capture stream in the situation where a new start can't be sent as that requires the state to be PREPARED and a new set_params can't be sent as that requires the state to be OPEN. The only option being to close the stream, and then reopen.

Correct this issues by allowing snd_compr_drain_notify to set the state depending on the stream direction, as we already do in set_params.

Fixes 49bb6402f1aa ("ALSA: compress_core: Add support for capture streams")
---
 include/sound/compress_driver.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/sound/compress_driver.h +5 -1
index 0cdc3999ecfa8..c5188ff724d12 100644
@@ -173,7 +173,11 @@ 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;
+	if (stream->direction == SND_COMPRESS_PLAYBACK)
+		stream->runtime->state = SNDRV_PCM_STATE_SETUP;
+	else
+		stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
+
 	wake_up(&stream->runtime->sleep);
 }
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 14 lines · Charles Keepax

It is normal user behaviour to start, stop, then start a stream again without closing it. Currently this works for compressed playback streams but not capture ones.

The states on a compressed capture stream go directly from OPEN to PREPARED, unlike a playback stream which moves to SETUP and waits for a write of data before moving to PREPARED. Currently however, when a stop is sent the state is set to SETUP for both types of streams. This leaves a capture stream in the situation where a new start can't be sent as that requires the state to be PREPARED and a new set_params can't be sent as that requires the state to be OPEN. The only option being to close the stream, and then reopen.

Quoted 6 lines

Correct this issues by allowing snd_compr_drain_notify to set the state depending on the stream direction, as we already do in set_params.

Fixes 49bb6402f1aa ("ALSA: compress_core: Add support for capture streams")

Applied now (with Cc to stable). Thanks.

Takashi