From patchwork Sun Jan 7 13:32:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Bokowy X-Patchwork-Id: 10148309 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 90CBC601A1 for ; Sun, 7 Jan 2018 13:41:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 781EF287F2 for ; Sun, 7 Jan 2018 13:41:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69618288F1; Sun, 7 Jan 2018 13:41:42 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 C3892287F2 for ; Sun, 7 Jan 2018 13:41:41 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B20B1267140; Sun, 7 Jan 2018 14:33:23 +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 C6B0026710B; Sun, 7 Jan 2018 14:33:19 +0100 (CET) Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by alsa0.perex.cz (Postfix) with ESMTP id 143E2266AE1 for ; Sun, 7 Jan 2018 14:33:13 +0100 (CET) Received: by mail-lf0-f66.google.com with SMTP id y71so9490286lfd.12 for ; Sun, 07 Jan 2018 05:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version :content-transfer-encoding; bh=bZYAWfUEZP2gyn8KzXRVHBigk3XnypkUV4W/53OIJlw=; b=g0yk+loRA/UK866HM5b2/kRSeEoUFkHV7eUM5QtRN2i0QzYEhElM0hC29xOC1/AUIv ZC3DICQOKemGOWMO2GEDB+D7yLMBDcX9HffLFtxNqsNbCJ2Lg/0SsBMGMciQSb22zRNP rVPGyCwM5IJXEtv6FdzQ7T1RDWOIAJruj/i1/G3WRvar2h8JRvjJE/A6Ks4u3mDiChGO 5NvPblKAZmQYWGPRe+fI1NNkkmQFCv0RASo753G9ErUZo1q+xoFqJ6DCRciIcfuTTlvk NRUAcRsp36qqBInxCFKkBA3pFuK+jkpHdYKn0lPf02TM9YIVniMl01XqFBG1zRZQwr9B qOFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-transfer-encoding; bh=bZYAWfUEZP2gyn8KzXRVHBigk3XnypkUV4W/53OIJlw=; b=Hmk03ZRjL0c+wvo5PfcfePyn8O43OzkScXbT71wphMfYWCWjC2N326xsF6xVaNIuMg FUOtLLKJUPbYHdaeq+tOQFt2BeTEQQlgirkrO71kVxC/5Tsgp7aCNlE47NkukkfNolin 6gS+Bo97DCEtvqRFqrmTg5SGR4djBSSJdh1bWvjSr4aJ6CVrFcBlF4hQE/no8fBZeImH Lli3FRDpe9dffZlkJak1RImo3F0u3sMnKpKtxdX/xXPwWScT/M14HJ/h+KJ4IAg1C/ID jfbyUKqkbf+qWfBgyPKZqGPrIFCCWyEbtIyc8UPu8Nvm2lQvLOFSAey+bRpHUoGQ8iqW mstA== X-Gm-Message-State: AKGB3mK5Yjb9g8RA2W0a826pcLk1Flu23t1JBj+3Jnu77+Kgu/cPOhT5 tvi1loA7f59CdeplTgb8tYMDtg== X-Google-Smtp-Source: ACJfBot+UweNGOqSZSt3DA5+5W7qczkfX1Mr/sSPdR5bAZyPgPe4IlLMb0zZwT77HMVrk0I8uIhYBw== X-Received: by 10.46.93.212 with SMTP id v81mr5218355lje.12.1515331992852; Sun, 07 Jan 2018 05:33:12 -0800 (PST) Received: from sambook (89-73-142-93.dynamic.chello.pl. [89.73.142.93]) by smtp.gmail.com with ESMTPSA id f73sm1764330lfg.93.2018.01.07.05.33.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 07 Jan 2018 05:33:12 -0800 (PST) Date: Sun, 7 Jan 2018 14:32:14 +0100 From: "Arkadiusz (Arkq) Bokowy" To: alsa-devel@alsa-project.org Message-ID: <20180107143214.6d31af53@sambook> X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Subject: [alsa-devel] [PATCH 3/3] plugio: Check for pointer callback error codes 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP plugio: Check for pointer callback error codes 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 | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c index 06c20d7b..cc234611 100644 --- a/src/pcm/pcm_ioplug.c +++ b/src/pcm/pcm_ioplug.c @@ -53,20 +53,29 @@ static int snd_pcm_ioplug_hw_ptr_update(snd_pcm_t *pcm) { ioplug_priv_t *io = pcm->private_data; snd_pcm_sframes_t hw; + unsigned int delta; hw = io->data->callback->pointer(io->data); - if (hw >= 0) { - unsigned int delta; - if ((unsigned int)hw >= io->last_hw) - delta = hw - io->last_hw; - else - delta = pcm->buffer_size + hw - io->last_hw; - snd_pcm_mmap_hw_forward(io->data->pcm, delta); - io->last_hw = hw; - return 0; - } else - io->data->state = SNDRV_PCM_STATE_XRUN; - return -EPIPE; + if (hw < 0) { + 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; + } + return hw; + } + if ((unsigned int)hw >= io->last_hw) + delta = hw - io->last_hw; + else + delta = pcm->buffer_size + hw - io->last_hw; + snd_pcm_mmap_hw_forward(io->data->pcm, delta); + io->last_hw = hw; + return 0; } static int snd_pcm_ioplug_info(snd_pcm_t *pcm, snd_pcm_info_t *info)