From patchwork Mon Nov 28 16:32:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeeja KP X-Patchwork-Id: 9450265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DFBD1600CB for ; Mon, 28 Nov 2016 20:04:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0D8227FE4 for ; Mon, 28 Nov 2016 20:04:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5B0728068; Mon, 28 Nov 2016 20:04:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78C8D27FE4 for ; Mon, 28 Nov 2016 20:04:00 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EBB8F266F94; Mon, 28 Nov 2016 21:03:58 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 62768266DD5; Mon, 28 Nov 2016 21:01:39 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0A4FD266DD4; Mon, 28 Nov 2016 17:22:01 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id 8451D266DAA for ; Mon, 28 Nov 2016 17:21:59 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 28 Nov 2016 08:21:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,564,1473145200"; d="scan'208"; a="1065236613" Received: from kpjeeja-desk.iind.intel.com ([10.223.96.110]) by orsmga001.jf.intel.com with ESMTP; 28 Nov 2016 08:21:55 -0800 From: jeeja.kp@intel.com To: alsa-devel@alsa-project.org Date: Mon, 28 Nov 2016 22:02:00 +0530 Message-Id: <1480350720-13441-1-git-send-email-jeeja.kp@intel.com> X-Mailer: git-send-email 2.5.0 Cc: tiwai@suse.de, patches.audio@intel.com, broonie@kernel.org, liam.r.girdwood@intel.com, Jeeja KP , Vinod Koul Subject: [alsa-devel] [PATCH] aplay: Fix to handle pause when system is suspended/Resumed X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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));