Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: jeeja.kp@intel.com
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, patches.audio@intel.com, broonie@kernel.org,
	liam.r.girdwood@intel.com, Jeeja KP <jeeja.kp@intel.com>,
	Vinod Koul <vinod.koul@intel.com>
Subject: [PATCH] aplay: Fix to handle pause when system is suspended/Resumed
Date: Mon, 28 Nov 2016 22:02:00 +0530	[thread overview]
Message-ID: <1480350720-13441-1-git-send-email-jeeja.kp@intel.com> (raw)

From: Jeeja KP <jeeja.kp@intel.com>

If PCM is paused and then we do system supend-resume, the stream throws
error(EBADF) when stream is paused released.

Check the pcm state before pause/release and if stream is suspended,
call snd_pcm_resume to resume the stream.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
---
 aplay/aplay.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/aplay/aplay.c b/aplay/aplay.c
index 2da7dda..ee480f2 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -166,6 +166,8 @@ static void end_wave(int fd);
 static void begin_au(int fd, size_t count);
 static void end_au(int fd);
 
+static void suspend(void);
+
 static const struct fmt_capture {
 	void (*start) (int fd, size_t count);
 	void (*end) (int fd);
@@ -1487,6 +1489,9 @@ static void do_pause(void)
 		fprintf(stderr, _("\rPAUSE command ignored (no hw support)\n"));
 		return;
 	}
+	if (snd_pcm_state(handle) == SND_PCM_STATE_SUSPENDED)
+		suspend();
+
 	err = snd_pcm_pause(handle, 1);
 	if (err < 0) {
 		error(_("pause push error: %s"), snd_strerror(err));
@@ -1496,6 +1501,8 @@ static void do_pause(void)
 		while (read(fileno(stdin), &b, 1) != 1);
 		if (b == ' ' || b == '\r') {
 			while (read(fileno(stdin), &b, 1) == 1);
+			if (snd_pcm_state(handle) == SND_PCM_STATE_SUSPENDED)
+				suspend();
 			err = snd_pcm_pause(handle, 0);
 			if (err < 0)
 				error(_("pause release error: %s"), snd_strerror(err));
-- 
2.5.0

             reply	other threads:[~2016-11-28 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 16:32 jeeja.kp [this message]
2016-11-28 19:19 ` [PATCH] aplay: Fix to handle pause when system is suspended/Resumed 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=1480350720-13441-1-git-send-email-jeeja.kp@intel.com \
    --to=jeeja.kp@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@intel.com \
    --cc=patches.audio@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