alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: compress: Make sure we trigger STOP before closing the stream.
@ 2013-09-13 16:43 Liam Girdwood
  2013-09-13 16:43 ` [PATCH] ALSA: compress: Fix compress device unregister Liam Girdwood
  2013-09-16  3:57 ` [PATCH] ALSA: compress: Make sure we trigger STOP before closing the stream Vinod Koul
  0 siblings, 2 replies; 11+ messages in thread
From: Liam Girdwood @ 2013-09-13 16:43 UTC (permalink / raw)
  To: alsa-devel; +Cc: Vinod Koul, Takashi Iwai, Mark Brown, Liam Girdwood

Currently we assume that userspace will shut down the compressed stream
correctly. However, if userspcae dies (e.g. cplay & ctrl-C) we dont
stop the stream before freeing it.

This now checks that the stream is stopped before freeing.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
---
 sound/core/compress_offload.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 99db892..a9ae4f3 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -139,6 +139,18 @@ static int snd_compr_open(struct inode *inode, struct file *f)
 static int snd_compr_free(struct inode *inode, struct file *f)
 {
 	struct snd_compr_file *data = f->private_data;
+	struct snd_compr_runtime *runtime = data->stream.runtime;
+
+	switch (runtime->state) {
+	case SNDRV_PCM_STATE_RUNNING:
+	case SNDRV_PCM_STATE_DRAINING:
+	case SNDRV_PCM_STATE_PAUSED:
+		data->stream.ops->trigger(&data->stream, SNDRV_PCM_TRIGGER_STOP);
+		break;
+	default:
+		break;
+	}
+
 	data->stream.ops->free(&data->stream);
 	kfree(data->stream.runtime->buffer);
 	kfree(data->stream.runtime);
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-09-26  7:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-13 16:43 [PATCH] ALSA: compress: Make sure we trigger STOP before closing the stream Liam Girdwood
2013-09-13 16:43 ` [PATCH] ALSA: compress: Fix compress device unregister Liam Girdwood
2013-09-16  4:15   ` Vinod Koul
2013-09-16  4:22     ` Vinod Koul
2013-09-19 16:41       ` Takashi Iwai
2013-09-16  3:57 ` [PATCH] ALSA: compress: Make sure we trigger STOP before closing the stream Vinod Koul
2013-09-16 11:01   ` Liam Girdwood
2013-09-19 16:43     ` Takashi Iwai
2013-09-23 10:19       ` Liam Girdwood
2013-09-23  9:41         ` Vinod Koul
2013-09-26  7:58           ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).