From patchwork Tue Oct 14 14:58:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 5080741 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 469EEC11AC for ; Tue, 14 Oct 2014 15:00:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A69420154 for ; Tue, 14 Oct 2014 15:00:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D36020148 for ; Tue, 14 Oct 2014 15:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932557AbaJNO7d (ORCPT ); Tue, 14 Oct 2014 10:59:33 -0400 Received: from resqmta-po-02v.sys.comcast.net ([96.114.154.161]:44676 "EHLO resqmta-po-02v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932552AbaJNO7c (ORCPT ); Tue, 14 Oct 2014 10:59:32 -0400 Received: from resomta-po-04v.sys.comcast.net ([96.114.154.228]) by resqmta-po-02v.sys.comcast.net with comcast id 32yS1p0044vw8ds012zXX8; Tue, 14 Oct 2014 14:59:31 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by resomta-po-04v.sys.comcast.net with comcast id 32zW1p00L0MU7Qa012zW5J; Tue, 14 Oct 2014 14:59:31 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 1BE0140A3A; Tue, 14 Oct 2014 08:59:30 -0600 (MDT) From: Shuah Khan To: m.chehab@samsung.com, akpm@linux-foundation.org, gregkh@linuxfoundation.org, crope@iki.fi, olebowle@gmx.com, dheitmueller@kernellabs.com, hverkuil@xs4all.nl, ramakrmu@cisco.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, perex@perex.cz, tiwai@suse.de, prabhakar.csengg@gmail.com, tim.gardner@canonical.com, linux@eikelenboom.it Cc: Shuah Khan , linux-media@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] sound/usb: pcm changes to use media token api Date: Tue, 14 Oct 2014 08:58:41 -0600 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1413298771; bh=fOYw3Kprx3HUQSlifdgaYar9bAq5RwwvyyhqeWJ6E9c=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=Mzud+df4VeV/WZurnQVtx3wyf+pP5GozF83Gfre7qoZK66SE/tIa7/tFGr5qM9TMP jHZxkuHSIsMfCBKJ5DZus3EkWwLmlNHVQjMhlE1aXLQeRnDruFSwRaIHPVSO5lZW3X 9ePBz0yUGFQAi4sZPt7WHUrlcrIk19yTzk7f23uRJflGAAodeKSFgvG7e9haK5g8hh mJM8CoNrVgvF2+tLIio+PFJwKafDAcrl60ZrkztITs4P816XHfC3RZBWsJeMLlzNvx pRRPCI4SfEiq4tzmWt7v8mjc2rDZs02+pJ+EQ7L1ZlYQmyZTbEJTEBWBWWQD+R+IsD 4M4kMFv06MjRw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change snd_usb_capture_ops trigger to hold audio token prior starting endpoints for SNDRV_PCM_TRIGGER_START request and release after stopping endpoints for SNDRV_PCM_TRIGGER_STOP request. Audio token is released from snd_usb_capture_ops close interface to cover the case where an application exits without stopping capture. Audio token get request will succeed if it is free or when a media application with the same task pid or task gid makes the request. This covers the cases when a media application first hold the tuner nd audio token and then requests SNDRV_PCM_TRIGGER_START either from the same thread or a another thread in the same process group. Signed-off-by: Shuah Khan --- sound/usb/pcm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index c62a165..d23abeb 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -1220,6 +1221,7 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction) subs->pcm_substream = NULL; snd_usb_autosuspend(subs->stream->chip); + media_put_audio_tkn(&subs->dev->dev); return 0; } @@ -1573,6 +1575,12 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream switch (cmd) { case SNDRV_PCM_TRIGGER_START: + err = media_get_audio_tkn(&subs->dev->dev); + if (err == -EBUSY) { + dev_info(&subs->dev->dev, "%s device is busy\n", + __func__); + return err; + } err = start_endpoints(subs, false); if (err < 0) return err; @@ -1583,6 +1591,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream case SNDRV_PCM_TRIGGER_STOP: stop_endpoints(subs, false); subs->running = 0; + media_put_audio_tkn(&subs->dev->dev); return 0; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: subs->data_endpoint->retire_data_urb = NULL;