Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: libin.yang@intel.com
To: tiwai@suse.de, broonie@kernel.org, alsa-devel@alsa-project.org
Cc: liam.r.girdwood@linux.intel.com, libin.yang@intel.com
Subject: [PATCH 1/2] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger
Date: Thu, 18 Dec 2014 15:36:03 +0800	[thread overview]
Message-ID: <1418888164-41117-1-git-send-email-libin.yang@intel.com> (raw)

From: Libin Yang <libin.yang@intel.com>

Add SNDRV_PCM_TRIGGER_DRAIN trigger for pcm drain.

Some audio devices require notification of drain events
in order to properly drain and shutdown an audio stream.

Signed-off-by: Libin Yang <libin.yang@intel.com>
---
 include/sound/pcm.h     | 1 +
 sound/core/pcm_native.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 8bb00a2..bb77aa3 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -109,6 +109,7 @@ struct snd_pcm_ops {
 #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE	4
 #define SNDRV_PCM_TRIGGER_SUSPEND	5
 #define SNDRV_PCM_TRIGGER_RESUME	6
+#define SNDRV_PCM_TRIGGER_DRAIN		7
 
 #define SNDRV_PCM_POS_XRUN		((snd_pcm_uframes_t)-1)
 
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 166d59c..15fe682 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1517,6 +1517,11 @@ static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+
+		if (substream->runtime->trigger_master == substream)
+			substream->ops->trigger(substream,
+					SNDRV_PCM_TRIGGER_DRAIN);
+
 		switch (runtime->status->state) {
 		case SNDRV_PCM_STATE_PREPARED:
 			/* start playback stream if possible */
-- 
1.9.1

             reply	other threads:[~2014-12-18  7:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18  7:36 libin.yang [this message]
2014-12-18  7:36 ` [PATCH 2/2] ASoC: Intel: Clean data after SST fw fetch libin.yang
2014-12-18  8:29 ` [PATCH 1/2] [ALSA] add SNDRV_PCM_TRIGGER_DRAIN trigger Takashi Iwai
2014-12-19  6:29   ` Yang, Libin
2014-12-19  8:47     ` Takashi Iwai
2014-12-22  7:42       ` Yang, Libin
2014-12-25 10:11         ` Takashi Iwai
2014-12-30  8:42           ` Yang, Libin
2014-12-30 15:02             ` 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=1418888164-41117-1-git-send-email-libin.yang@intel.com \
    --to=libin.yang@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=tiwai@suse.de \
    /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