From: Takashi Iwai Subject: Re: [PATCH] aplay: Fix to handle pause when system is suspended/Resumed Date: Mon, 28 Nov 2016 20:19:48 +0100 Message-ID: References: <1480350720-13441-1-git-send-email-jeeja.kp@intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id D287A266F68 for ; Mon, 28 Nov 2016 20:19:49 +0100 (CET) In-Reply-To: <1480350720-13441-1-git-send-email-jeeja.kp@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: jeeja.kp@intel.com Cc: patches.audio@intel.com, Vinod Koul , alsa-devel@alsa-project.org, broonie@kernel.org, liam.r.girdwood@intel.com List-Id: alsa-devel@alsa-project.org On Mon, 28 Nov 2016 17:32:00 +0100, jeeja.kp@intel.com wrote: > > From: Jeeja KP > > 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 > Signed-off-by: Jeeja KP Applied, thanks. Takashi > --- > 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 >