Skip to content

Commit

Permalink
ALSA: compress: Make sure we trigger STOP before closing the stream.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
lrgirdwo authored and tiwai committed Sep 26, 2013
1 parent 4028b6c commit b26d19e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sound/core/compress_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b26d19e

Please sign in to comment.