[alsa-devel] [PATCH 1/1] ALSA: compress_core: Ensure device is stopped when stream closed

Vinod Koul vinod.koul at intel.com
Fri Apr 26 18:42:55 CEST 2013


On Fri, Apr 26, 2013 at 02:47:06PM +0100, Richard Fitzgerald wrote:
> If the stream state is running or paused when device file is
> closed snd_compr_free() will send a SNDRV_PCM_TRIGGER_STOP
> to the stream.
> 
> Signed-off-by: Richard Fitzgerald <rf at opensource.wolfsonmicro.com>
> ---
>  sound/core/compress_offload.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 91e6bcb..a81c5e4 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -132,6 +132,11 @@ 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;
> +
> +	if ((data->stream.runtime->state == SNDRV_PCM_STATE_RUNNING) ||
> +	    (data->stream.runtime->state == SNDRV_PCM_STATE_PAUSED))
> +		data->stream.ops->trigger(&data->stream, SNDRV_PCM_TRIGGER_STOP);
two things:
1. I like Mark's idea the switch will make it look better :)
2. why do you want to do explicit stop when you are freeing. Esp the Paused
cases doesnt make sense. Shouldnt the DSP be able to handle this transistion?

--
~Vinod
> +
>  	data->stream.ops->free(&data->stream);
>  	kfree(data->stream.runtime->buffer);
>  	kfree(data->stream.runtime);
> -- 
> 1.7.2.5
> 


More information about the Alsa-devel mailing list