From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 A17DFC432C1 for ; Tue, 24 Sep 2019 06:22:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 7680220673 for ; Tue, 24 Sep 2019 06:22:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7680220673 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCeDI-0005Tr-Jv for qemu-devel@archiver.kernel.org; Tue, 24 Sep 2019 02:22:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59186) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCeB7-0003ZA-1n for qemu-devel@nongnu.org; Tue, 24 Sep 2019 02:20:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCeB5-0000r1-Ho for qemu-devel@nongnu.org; Tue, 24 Sep 2019 02:20:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53124) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCeB5-0000qK-9l for qemu-devel@nongnu.org; Tue, 24 Sep 2019 02:19:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E3D9806A5E; Tue, 24 Sep 2019 06:19:58 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5091A5C1B2; Tue, 24 Sep 2019 06:19:58 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C27199C90; Tue, 24 Sep 2019 08:19:51 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 07/16] noaudio: port to the new audio backend api Date: Tue, 24 Sep 2019 08:19:42 +0200 Message-Id: <20190924061951.27916-8-kraxel@redhat.com> In-Reply-To: <20190924061951.27916-1-kraxel@redhat.com> References: <20190924061951.27916-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Tue, 24 Sep 2019 06:19:58 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kővágó@redhat.com, Gerd Hoffmann , =?UTF-8?q?Zolt=C3=A1n?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Message-id: 10eebdd2e1529c2bd403ef98dd9d346c6d4ca3d1.1568927990.git.DirtY= .iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann --- audio/noaudio.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/audio/noaudio.c b/audio/noaudio.c index 0fb2629cf283..b054fd225b66 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -41,10 +41,9 @@ typedef struct NoVoiceIn { int64_t old_ticks; } NoVoiceIn; =20 -static size_t no_run_out(HWVoiceOut *hw, size_t live) +static size_t no_write(HWVoiceOut *hw, void *buf, size_t len) { NoVoiceOut *no =3D (NoVoiceOut *) hw; - size_t decr, samples; int64_t now; int64_t ticks; int64_t bytes; @@ -52,13 +51,9 @@ static size_t no_run_out(HWVoiceOut *hw, size_t live) now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ticks =3D now - no->old_ticks; bytes =3D muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER= _SECOND); - bytes =3D MIN(bytes, SIZE_MAX); - samples =3D bytes >> hw->info.shift; =20 no->old_ticks =3D now; - decr =3D MIN (live, samples); - hw->rpos =3D (hw->rpos + decr) % hw->samples; - return decr; + return MIN(len, bytes); } =20 static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv= _opaque) @@ -92,25 +87,21 @@ static void no_fini_in (HWVoiceIn *hw) (void) hw; } =20 -static size_t no_run_in(HWVoiceIn *hw) +static size_t no_read(HWVoiceIn *hw, void *buf, size_t size) { + size_t to_clear; NoVoiceIn *no =3D (NoVoiceIn *) hw; - size_t live =3D audio_pcm_hw_get_live_in(hw); - size_t dead =3D hw->samples - live; - size_t samples =3D 0; =20 - if (dead) { - int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - int64_t ticks =3D now - no->old_ticks; - int64_t bytes =3D - muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_S= ECOND); + int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + int64_t ticks =3D now - no->old_ticks; + int64_t bytes =3D + muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SECON= D); =20 - no->old_ticks =3D now; - bytes =3D MIN (bytes, SIZE_MAX); - samples =3D bytes >> hw->info.shift; - samples =3D MIN (samples, dead); - } - return samples; + no->old_ticks =3D now; + to_clear =3D MIN(bytes, size); + + audio_pcm_info_clear_buf(&hw->info, buf, to_clear >> hw->info.shift)= ; + return to_clear; } =20 static int no_ctl_in (HWVoiceIn *hw, int cmd, ...) @@ -133,12 +124,12 @@ static void no_audio_fini (void *opaque) static struct audio_pcm_ops no_pcm_ops =3D { .init_out =3D no_init_out, .fini_out =3D no_fini_out, - .run_out =3D no_run_out, + .write =3D no_write, .ctl_out =3D no_ctl_out, =20 .init_in =3D no_init_in, .fini_in =3D no_fini_in, - .run_in =3D no_run_in, + .read =3D no_read, .ctl_in =3D no_ctl_in }; =20 --=20 2.18.1