From 8cb8307dad3e0b609257bec7d276e32689d62863 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 7 Jun 2013 18:24:28 +0100 Subject: [PATCH] ALSA: compress: Make sure we trigger STOP before closing the stream. 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. Change-Id: If163520ff08b61fcf104ad6c06d89c705b7e5935 Signed-off-by: Liam Girdwood Signed-off-by: Krishnankutty Kolathappilly --- 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 f60eb27c74f..35f30f5ad5a 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -132,6 +132,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);