alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Liam Girdwood <liam.r.girdwood@intel.com>
To: Vinod Koul <vinod.koul@intel.com>
Cc: Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org,
	Liam Girdwood <liam.r.girdwood@linux.jf.intel.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH] ALSA: compress: Make sure we trigger STOP before closing the stream.
Date: Mon, 16 Sep 2013 12:01:23 +0100	[thread overview]
Message-ID: <1379329283.3215.34.camel@loki> (raw)
In-Reply-To: <20130916035753.GJ17188@intel.com>

On Mon, 2013-09-16 at 09:27 +0530, Vinod Koul wrote:
> On Fri, Sep 13, 2013 at 05:43:16PM +0100, Liam Girdwood wrote:
> > 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);
> when usermode dies the free will get invoked as we have below. The free is a
> valid trigger from any state. So shouldnt the DSP then STOP the DMAs and free
> the streams.

This means that the compressed stream ops don't follow the PCM ops wrt
trigger() sequencing (i.e. we have to add extra logic in free to deal
with this difference).

I think it would be better to follow the PCM operations use case here as
it simplifies the driver code and stops people making the false
assumption that trigger() works the same way throughout ALSA ?   

> Given that most of the usage is a DSP then IMO it might make send to tell DSP
> that stop and cleanup rather than saying stop and cleanup?
> 

Sorry, don't follow you here ;)

Liam

> ~Vinod
> > +		break;
> > +	default:
> > +		break;
> > +	}
> > +
> >  	data->stream.ops->free(&data->stream);
> >  	kfree(data->stream.runtime->buffer);
> >  	kfree(data->stream.runtime);
> > -- 
> > 1.8.1.2
> > 
> 



---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

  reply	other threads:[~2013-09-16 11:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379329283.3215.34.camel@loki \
    --to=liam.r.girdwood@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@linux.jf.intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).