Message ID | 1502229960-8516-4-git-send-email-daniel.baluta@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <alsa-devel-bounces@alsa-project.org> 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 D1022603F9 for <patchwork-alsa-devel@patchwork.kernel.org>; Tue, 8 Aug 2017 22:07:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C072628A38 for <patchwork-alsa-devel@patchwork.kernel.org>; Tue, 8 Aug 2017 22:07:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B529328A2A; Tue, 8 Aug 2017 22:07:24 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM, 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 DFD8628A33 for <patchwork-alsa-devel@patchwork.kernel.org>; Tue, 8 Aug 2017 22:07:23 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D05D02673D3; Wed, 9 Aug 2017 00:06:37 +0200 (CEST) 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 2CAB2266E29; Wed, 9 Aug 2017 00:06:36 +0200 (CEST) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by alsa0.perex.cz (Postfix) with ESMTP id CA491266E29 for <alsa-devel@alsa-project.org>; Wed, 9 Aug 2017 00:06:19 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id o33so3338227wrb.1 for <alsa-devel@alsa-project.org>; Tue, 08 Aug 2017 15:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gvj9S2BtG8QWtqcbhwgnhkjye5ESRZkO47XFfzLk14k=; b=mVXvGnlM/bMbVPWVugENjsIKLw1AWyyCODaOwEdrZjLYhnRvaHuC/DLI9VwZFCx7wk uPSBAj37bOd62s67IemD+1HjRy6YEV7FWs/t6Jvs5XM7n7XK/f4b7dgOEUEOZTDDqc6H jWAP1rvGYsNYiRULP4gB+sxahrTVywDaXWm9ALnP1bx6BdDxgf+e/YiWBzW3duhN31+X pK8YaE9nMGnffK7kf2zdEnJ3GJ4VPV1c8AvjS2GBuSZIZKYvXxpKcsrKCnprxE5uI56Z mnkJTW0viubWwICUVAwUPdGSE6OoWZRznYyJhHOQ4Ah6hR5pFIYEo4p4i0/su4qquJAG aCVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gvj9S2BtG8QWtqcbhwgnhkjye5ESRZkO47XFfzLk14k=; b=QFuKPTMqGMZ2byiNRs92maRLgSb76nPEIw5Uyp5F/p9KoJaTYspSCG1XxKKoixwphB PprjsOzKkGO1SKfBBphMunCqP8CYjRfW3/ddglYb+8MPn3NK8T/tyRcgaO+d8mPIaIVx cbLl7/WahOaEAcOgM5R/WeIjmkps47iADPX71nO9mf2FOQDQbHR5UjD8OO11AC+Ii3ET 4ZIoWG4tbW0A5WlQpNqI++t6A8eycwwKyfwX9CEEPLgVv4in2fzxMsMthZ3MnXwMI6oL 4+zzb5PYjZMV5/DS2muB/IAo/eD7ns6BsJEeKobs2f90uQOfGkXZ6n+W8z2MvhdO5z6Z uRYw== X-Gm-Message-State: AHYfb5jIGWdu5srX+gMBTC/ZZzS+5cBZlOoDasGkq5LYCBs0REE4SINP KANPsN3RZRKgQQ== X-Received: by 10.223.144.131 with SMTP id i3mr3974565wri.40.1502229979161; Tue, 08 Aug 2017 15:06:19 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f01:5040:14c8:152d:3d14:674f:951]) by smtp.gmail.com with ESMTPSA id g18sm3592132wrg.69.2017.08.08.15.06.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Aug 2017 15:06:18 -0700 (PDT) From: Daniel Baluta <daniel.baluta@gmail.com> To: tiwai@suse.com, alsa-devel@alsa-project.org Date: Wed, 9 Aug 2017 01:06:00 +0300 Message-Id: <1502229960-8516-4-git-send-email-daniel.baluta@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502229960-8516-1-git-send-email-daniel.baluta@gmail.com> References: <1502229960-8516-1-git-send-email-daniel.baluta@gmail.com> Cc: mihai.serban@nxp.com, shengjiu.wang@nxp.com, Daniel Baluta <daniel.baluta@nxp.com>, Daniel Baluta <daniel.baluta@gmail.com>, viorel.suman@nxp.com Subject: [alsa-devel] [PATCH 3/3] aplay: Fix playback for small raw files 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" <alsa-devel.alsa-project.org> List-Unsubscribe: <http://mailman.alsa-project.org/mailman/options/alsa-devel>, <mailto:alsa-devel-request@alsa-project.org?subject=unsubscribe> List-Archive: <http://mailman.alsa-project.org/pipermail/alsa-devel/> List-Post: <mailto:alsa-devel@alsa-project.org> List-Help: <mailto:alsa-devel-request@alsa-project.org?subject=help> List-Subscribe: <http://mailman.alsa-project.org/mailman/listinfo/alsa-devel>, <mailto:alsa-devel-request@alsa-project.org?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/aplay/aplay.c b/aplay/aplay.c index 28da6c5..0aa1688 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -2774,6 +2774,13 @@ static void playback_go(int fd, size_t loaded, off64_t count, int rtype, char *n c = count - written; if (c > chunk_bytes) c = chunk_bytes; + + /* c < l, there is more data loaded + * then we actually need to write + */ + if (c < l) + l = c; + c -= l; if (c == 0)
This fixes a bug when trying to play files with size smaller than maximum supported header size. Lets have a look at the following example: $ aplay -s 2 sample.raw -> playback_go(fd = 10, loaded = 26, count = 2, name="sample.raw") --> l = loaded = 26 --> c = count - written = 2 --> c -= l = 2 - 26 = -24 ---> r = safe_read(fd, audiobuf + 26, -24) ---> r = -1, EXIT_FAILURE In this case we have already 'loaded' from the input file more bytes that we need to send to pcm device. So, we need to adjust the number of bytes loaded and avoid reading a negative number of bytes. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> --- aplay/aplay.c | 7 +++++++ 1 file changed, 7 insertions(+)