From patchwork Fri Feb 17 07:17:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sutar.mounesh@gmail.com X-Patchwork-Id: 9578977 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 0A6B86049F for ; Fri, 17 Feb 2017 07:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F28E7286A2 for ; Fri, 17 Feb 2017 07:17:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E638C286A7; Fri, 17 Feb 2017 07:17:36 +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 295F1286A2 for ; Fri, 17 Feb 2017 07:17:35 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id C5BA72670F1; Fri, 17 Feb 2017 08:17:32 +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 82FCE2670F1; Fri, 17 Feb 2017 08:17:31 +0100 (CET) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by alsa0.perex.cz (Postfix) with ESMTP id D0902266F7F; Fri, 17 Feb 2017 08:17:27 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id c85so997322wmi.1; Thu, 16 Feb 2017 23:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VbplJb3oaUD6KfUjIMT7A8KdOkfVkBcva38ez/bcKKQ=; b=a6vbbFIc5IIcmUC4PxdTyYF6MIVfcAql4JPq3LbF3aHFmhWH3Hq2F2o7R9MmdEtR9U mOHzzVNTaRkoXqX/QoNpJQzeYu3nqUSlpG7rkawnqYsdhuBK/Dw6ORVoO99eXRpgRu1w eK6EuVtPFTgr4jpM8L+nStiW4Yd7Iigohs8B+tkxQfSBrO1XTCvhbZq8+DJa4VY60ycQ QDvrd2I0RjXeN6sdJtx61ndEh9jW9m/SelIScz7rLRrrz7dVcCswHgQC+2sOnYo1uGBN VHimSWzk35DReweakUsbaR3+I3enDogJUbY7t1Fhoa91a3LhPGRX1V/FtsQsku6+A2pw VODg== 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; bh=VbplJb3oaUD6KfUjIMT7A8KdOkfVkBcva38ez/bcKKQ=; b=Udn5skzetAo8xS+6QrgNogkAYCQrsqCdkGc4h6ceU+x2t9iY/VDG6BwKks5gwHB3DV r1ht3gdpEvEe6x+XGmst8FiEU2qgLj1ZYLMrKn7wqXzQQ84xhMHblA5pHLDm0Iy8nFh7 8RFwfAgKtTaOjzl+DUszeAzBp1Nw8BCJmhN89m+gfW13l04uTLHUDU79Fp6j5EnDQEPP oL90CWqdirplCZLvgDnrF9I23XrUEpP5xRiYIuZ6ezZ8tHfkXmjXeagqXmxD4aFrtD/F rII7hnUmavc0ZEmCg/OzBjXHUilNfqzQ9nmbtf1KFCyy4u3gb884gzZcJn9kenu5jOyd 8HOg== X-Gm-Message-State: AMke39nZdYpQc2QyEUjE37ddRbigHIELlRM+d2yduPsDhdzhQsqDIuvYP5OBwqAF0s5oKw== X-Received: by 10.28.232.90 with SMTP id f87mr1540263wmh.35.1487315847400; Thu, 16 Feb 2017 23:17:27 -0800 (PST) Received: from msutar-VirtualBox.inp.mentorg.com ([139.181.35.34]) by smtp.gmail.com with ESMTPSA id a35sm11856435wra.21.2017.02.16.23.17.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Feb 2017 23:17:26 -0800 (PST) From: sutar.mounesh@gmail.com To: patch@alsa-project.org Date: Fri, 17 Feb 2017 12:47:17 +0530 Message-Id: <1487315837-9034-1-git-send-email-sutar.mounesh@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: Mounesh Sutar , Timo Wischer , alsa-devel@alsa-project.org, mounesh_sutar@mentor.com Subject: [alsa-devel] [PATCH 3/6] pcm:file: Enable file writing for capture path 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: Timo Wischer This commit reverts parts of commit 4081be0b87ab9fa53a8906e66bc240f18a7a9a54, because it is realy useful to use the file plugin in a capture path for debugging. Also it fixes the truncate issue mentioned in above commit. Additionally following MMAP access issue is considered: $ arecord -D teeraw -M -d5 arecord.wav Recording WAVE 'arecord.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono ALSA lib pcm/pcm_file.c:358:(snd_pcm_file_write_bytes) write failed: Bad file descriptor ALSA lib pcm/pcm_file.c:358:(snd_pcm_file_write_bytes) write failed: Bad file descriptor arecord: pcm/pcm_file.c:397: snd_pcm_file_add_frames: Assertion `file->wbuf_used_bytes < file->wbuf_size_bytes' failed. Aborted by signal Aborted... Signed-off-by: Timo Wischer Signed-off-by: Mounesh Sutar diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index 6d119d6..0363f84 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -544,6 +544,7 @@ static snd_pcm_sframes_t snd_pcm_file_writen(snd_pcm_t *pcm, void **bufs, snd_pc static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; + snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_sframes_t n; n = _snd_pcm_readi(file->gen.slave, buffer, size); @@ -555,8 +556,10 @@ static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pc __snd_pcm_unlock(pcm); if (n < 0) return n; - return n * 8 / pcm->frame_bits; + n = n * 8 / pcm->frame_bits; } + snd_pcm_areas_from_buf(pcm, areas, buffer); + snd_pcm_file_add_frames(pcm, areas, 0, n); return n; } @@ -564,6 +567,7 @@ static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pc static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; + snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_sframes_t n; if (file->ifd >= 0) { @@ -572,6 +576,10 @@ static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm } n = _snd_pcm_readn(file->gen.slave, bufs, size); + if (n > 0) { + snd_pcm_areas_from_bufs(pcm, areas, bufs); + snd_pcm_file_add_frames(pcm, areas, 0, n); + } return n; } @@ -635,7 +643,7 @@ static int snd_pcm_file_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) a->first = slave->sample_bits * channel; a->step = slave->frame_bits; } - if ((file->fd < 0) && (pcm->stream == SND_PCM_STREAM_PLAYBACK)) { + if (file->fd < 0) { err = snd_pcm_file_open_output_file(file); if (err < 0) { SYSERR("failed opening output file %s", file->fname);