From patchwork Mon Aug 23 11:46:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Bokowy X-Patchwork-Id: 12452521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 007EFC4338F for ; Mon, 23 Aug 2021 11:47:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05C6861373 for ; Mon, 23 Aug 2021 11:47:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 05C6861373 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1B7594E; Mon, 23 Aug 2021 13:46:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1B7594E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1629719268; bh=uf/bRxlMflMRbWGOYMw1BFi0GqTQZujLfnN9B+1eZKY=; h=From:Date:Subject:To:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=QfE3MeM+uEd4xBGpkFhsrVvEKQHycDkdYIAkiGIPZZd4QzFmy4Bt6i9zvw/OBEegy cmnbW+IRZtKIBsp9PQjSJO9OqHyZGYZPqOwIlEKnNT7JqBT8Nfd723LqF5X9VRhQ2d Sqneyhugf9GyGUzoBG2RhP5lXFjLMpciJ5xtVtkQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A33F4F8020C; Mon, 23 Aug 2021 13:46:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 10320F80217; Mon, 23 Aug 2021 13:46:56 +0200 (CEST) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 86225F8016E for ; Mon, 23 Aug 2021 13:46:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 86225F8016E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B0pfG5pB" Received: by mail-il1-x12e.google.com with SMTP id y3so16780788ilm.6 for ; Mon, 23 Aug 2021 04:46:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=yy4pE1GOmOy9ogUg19qEnYHdTY0X4dKp77N6saqxSvA=; b=B0pfG5pB25UV215r8g5FoDMPhITadc4t1NuapsT8r6gtdQBsKKPtKuUPfPlYAwZK84 c+B47+cfSB1u0lGfv/VDcll2dfxAT5gmichduTG9ggBDnxvCb+kIQjZiNEXOB/QgnM0E fjFKvNK51uqmzrww5hZG+MVHXnsjPSk+7g+No5lvtMnZgruleJ3uj9vjBn9WCZpegv/8 HTPgOFooOM/oxNZPpghTClYJgBbk/ragG5U/wLfZcY3BrhH3KrafZr2rKo3pBsv4DIgd FpPYZc2vF16sm4kUavbSPrAcPjr3v/2eqvXD0Y2HQLqjYGA7WF/DEBAT84gx0fI1m70p mBeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=yy4pE1GOmOy9ogUg19qEnYHdTY0X4dKp77N6saqxSvA=; b=l+NbEVIM4+y4kEgD4/DiK9KF7nBMUanokss51WBh6o0MjURycZdD4CxZTK+t5kn1sg 90iIg/aIB8TuMlEDenRdhHiOZnfw2MzfGPtrv4+9J8T9UAi+3LC23b5qqqz0CidNHH4c GdPJ/I6o9izgTRpSEwH4GZIfVk13bB6L/0SC3dAW3jkzzsxhimw2RTzNqHEbGL9TUNq6 s2Ul2D0POw0eKBEJxFIpcg72pwIgk8Whwf5wLnE8kdVvCGyw5MRepCGyZDdF5o5VDi3J hTIwH0rLlpisUOuBzmieNfsi6qxWAtGMr+g+oYUllqKnWauIwwZWetrtcQDoQNM8PYdm +m8A== X-Gm-Message-State: AOAM532MPFc7a0OUuAk7ni3/2U54/jH5z8kvEYgdWqMB92bKAjKrXTym xeK2kn4oUZto+a5FfM51MrqAlFgw3MYGVqZhCOqBv62yGPo= X-Google-Smtp-Source: ABdhPJyQjikMfXUO2p643TEeVupCrPB0Ln/+oVrDjQqS1okMVz3UFxShfcF9piF2i+y9fs+A2K27s//jKC+PmC5N3bI= X-Received: by 2002:a92:d3c1:: with SMTP id c1mr22699041ilh.194.1629719208597; Mon, 23 Aug 2021 04:46:48 -0700 (PDT) MIME-Version: 1.0 From: Arkadiusz Bokowy Date: Mon, 23 Aug 2021 13:46:37 +0200 Message-ID: Subject: [PATCH 1/2] ioplug: Check for callback error codes To: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Arkadiusz Bokowy --- src/pcm/pcm_ioplug.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) snd_pcm_sframes_t hw; @@ -85,7 +85,9 @@ static void snd_pcm_ioplug_hw_ptr_update(snd_pcm_t *pcm) snd_pcm_ioplug_drop(pcm); else io->data->state = SNDRV_PCM_STATE_XRUN; + return -EPIPE; } + return 0; } static int snd_pcm_ioplug_info(snd_pcm_t *pcm, snd_pcm_info_t *info) @@ -115,7 +117,10 @@ static int snd_pcm_ioplug_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) io->data->callback->delay) return io->data->callback->delay(io->data, delayp); else { - snd_pcm_ioplug_hw_ptr_update(pcm); + int err; + err = snd_pcm_ioplug_hw_ptr_update(pcm); + if (err < 0) + return err; *delayp = snd_pcm_mmap_delay(pcm); } return 0; @@ -499,11 +504,14 @@ static int snd_pcm_ioplug_start(snd_pcm_t *pcm) static int snd_pcm_ioplug_drop(snd_pcm_t *pcm) { ioplug_priv_t *io = pcm->private_data; + int err; if (io->data->state == SND_PCM_STATE_OPEN) return -EBADFD; - io->data->callback->stop(io->data); + err = io->data->callback->stop(io->data); + if (err < 0) + return err; gettimestamp(&io->trigger_tstamp, pcm->tstamp_type); io->data->state = SND_PCM_STATE_SETUP; @@ -625,7 +633,7 @@ static int snd_pcm_ioplug_resume(snd_pcm_t *pcm) ioplug_priv_t *io = pcm->private_data; if (io->data->callback->resume) - io->data->callback->resume(io->data); + return io->data->callback->resume(io->data); return 0; } @@ -898,13 +906,14 @@ static void clear_io_params(ioplug_priv_t *io) static int snd_pcm_ioplug_close(snd_pcm_t *pcm) { ioplug_priv_t *io = pcm->private_data; + int err = 0; clear_io_params(io); if (io->data->callback->close) - io->data->callback->close(io->data); + err = io->data->callback->close(io->data); free(io); - return 0; + return err; } static const snd_pcm_ops_t snd_pcm_ioplug_ops = { diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c index 98184398..c96104e9 100644 --- a/src/pcm/pcm_ioplug.c +++ b/src/pcm/pcm_ioplug.c @@ -54,7 +54,7 @@ static int snd_pcm_ioplug_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsi /* update the hw pointer */ /* called in lock */ -static void snd_pcm_ioplug_hw_ptr_update(snd_pcm_t *pcm) +static int snd_pcm_ioplug_hw_ptr_update(snd_pcm_t *pcm) { ioplug_priv_t *io = pcm->private_data; From patchwork Mon Aug 23 11:48:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Bokowy X-Patchwork-Id: 12452549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B09A3C4338F for ; Mon, 23 Aug 2021 11:49:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D062B61373 for ; Mon, 23 Aug 2021 11:49:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D062B61373 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 61A34112; Mon, 23 Aug 2021 13:48:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 61A34112 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1629719387; bh=rvKEHG+V5P5958Idt0zT0SZsTZxU/6CjLe7f+MZLLSc=; h=From:Date:Subject:To:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Go4/YW7enxl06VhKgmBl9HUbq+WWwSlbTa1wPNgBQCdpbIyxicscP7Pvs41O9Snh3 1ESCpf5S8ncTDFeTBFytrDZm3q2jGj4E7YG8H4F5K9/wYlPn4obIJtMGwmZztZq1Yt 18nEBiV8kkNQaK9XUYcbSN2BacU+ftARUZql1aog= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0E5B5F8016E; Mon, 23 Aug 2021 13:48:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1FCFAF80217; Mon, 23 Aug 2021 13:48:55 +0200 (CEST) Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B57D4F800E7 for ; Mon, 23 Aug 2021 13:48:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B57D4F800E7 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z3nam39b" Received: by mail-io1-xd30.google.com with SMTP id g9so21372059ioq.11 for ; Mon, 23 Aug 2021 04:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=DGeOtwniKjgHeFEXcTnWIoKjqVAsKHeKtt5KDw99aRM=; b=Z3nam39bXXNw4zj0cv1glfRbHWY8kPk3JWIaJoBihTUY8yAfdI+jugW2xDYdujbvw+ OLv4JaBCpt/YA5o++DX/hS6yWwfsifECJ+o/ykEuP23vEFkm89CSsAX/DnHKxX8lGway eh/ziuO/NSB1brxBMwwi5TRqewN/NNtvzg2dGlwUjlMvTKhg1DHCVlH1GUPPbwNruCvX SZdf4CYNM+DHPdLGSGNLiDBUk9ZaM5gH4hrFQcDLAolIXxDeUi5q3kfsiIDfiEdsBmsj AxfWx70Vht22DSDdrBdLr8TbwE5zaeQSA2ftJlZr//iBt3rWihYJfLQ6x1pboJkdUbTR TsTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=DGeOtwniKjgHeFEXcTnWIoKjqVAsKHeKtt5KDw99aRM=; b=Z6Lyyn9vG2YEhrHcSMIyfPoWOYnpeGGaU3ctr6pMQIdx2V4Aa2hOemiTNQBX8gdbtc syDrg6tMP5ss80tYCi+J0lu8eP/uN6xOuftqzZ5EX/fTt4ZAS5NxCJrS07wxBR1ItZpm NRLdst7d2zOov/f1TFPWnrg2TlKrek3KU67WXbYToDA9gq1jUvoWbCCVnJYOU5FEnlBk 7c4VAKx7YP1WZaDbMP2fI69xqcWVDMxivkIBpggOER2kAWUWcJ07XK78oJGT0Lsy2e6S 4JwmYmV2vR2tZzomIy46nD5sHXK26WhhpECxPpwILmYqqrrCuxWeqc8hTob/dpxCWB4Y LbFA== X-Gm-Message-State: AOAM5327xGv6Clr5zar+tuvn7dHOqL/OjOHFxGBNvsyKYyIe0mBiAjMv vbJ6Qzku02gTs8UsmmCLd54xxniVONgw6OXx7Wx/f21FM+I= X-Google-Smtp-Source: ABdhPJwzsWhJYjmqNW7lzETuKOb9ghbo1NbwHdvPBLdczBp10mRkvpK3SepcVJmfyzyPy8fIJKIHKk4MUl8qCfl3cTE= X-Received: by 2002:a5e:990e:: with SMTP id t14mr26675403ioj.75.1629719329851; Mon, 23 Aug 2021 04:48:49 -0700 (PDT) MIME-Version: 1.0 From: Arkadiusz Bokowy Date: Mon, 23 Aug 2021 13:48:38 +0200 Message-ID: Subject: [PATCH 2/2] plugio: Check for pointer callback error codes To: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" By checking error code returned by the pointer callback, we can determine more precisely PCM state. Previous implementation assumed, that a software PCM can only produce overrun or underrun. It was impossible to mark software PCM as disconnected. Signed-off-by: Arkadiusz Bokowy --- src/pcm/pcm_ioplug.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c index c96104e9..0e27e121 100644 --- a/src/pcm/pcm_ioplug.c +++ b/src/pcm/pcm_ioplug.c @@ -81,11 +81,21 @@ static int snd_pcm_ioplug_hw_ptr_update(snd_pcm_t *pcm) } io->last_hw = (snd_pcm_uframes_t)hw; } else { + switch (hw) { + case -ESTRPIPE: + io->data->state = SND_PCM_STATE_SUSPENDED; + break; + case -ENODEV: + io->data->state = SND_PCM_STATE_DISCONNECTED; + break; + default: + io->data->state = SND_PCM_STATE_XRUN; + } if (io->data->state == SND_PCM_STATE_DRAINING) snd_pcm_ioplug_drop(pcm); else io->data->state = SNDRV_PCM_STATE_XRUN; - return -EPIPE; + return hw; } return 0; }