From nobody Wed Nov 12 06:52:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568575482; cv=none; d=zoho.com; s=zohoarc; b=mzgA2EY5dnhEXjTOPs5wl3gLp7J7nMRKzTeuGaYZu/LyXWDW2gmiUWsQBDxtFQU8ZBwwy0tVDrOhhERYnuozfBgmkLCLNgkP/mt5/greJZg1InviexVrnCaA/KsRYCrvk9xSqFZ4TZjaC74weZyRqJz/5t3vZHt4pdNAHy33JeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568575482; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aJOgLJbUU33d0sFNF8d3VZOVm5JVuSp9jkJ/aPDzPik=; b=CP5qRhl33pIB2MD9DnQL+vjeXEeOtTla+i5xcl9kgKqRTdmyzyGBf1fDRK3PXSrsGYFyXM2+Py9lEyLfu+E5Vc1DP7xwgaz6cv5C9TUSBSlC9+0BrzzcWEgRiI0j0Wsi/Y1thSuSMlkG/AXFl1JVdZdeS6ilqxjRqUJ02fXEUnE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568575482453192.2738509369908; Sun, 15 Sep 2019 12:24:42 -0700 (PDT) Received: from localhost ([::1]:56554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9a8X-0006rx-Au for importer@patchew.org; Sun, 15 Sep 2019 15:24:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39964) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9a7e-0005yu-89 for qemu-devel@nongnu.org; Sun, 15 Sep 2019 15:23:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9a7d-0001xr-3A for qemu-devel@nongnu.org; Sun, 15 Sep 2019 15:23:46 -0400 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]:35901) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9a7c-0001xe-T7 for qemu-devel@nongnu.org; Sun, 15 Sep 2019 15:23:45 -0400 Received: by mail-ed1-x542.google.com with SMTP id f2so24889554edw.3 for ; Sun, 15 Sep 2019 12:23:44 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-74ef-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:74ef::5]) by smtp.gmail.com with ESMTPSA id j20sm6480562edy.95.2019.09.15.12.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Sep 2019 12:23:43 -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 :mime-version:content-transfer-encoding; bh=aJOgLJbUU33d0sFNF8d3VZOVm5JVuSp9jkJ/aPDzPik=; b=Yzv5jNjcLcJ8Vt2OLBoEbcOBm6N6e3A6fmcp+eGZ5p3Cq4m3M52Y0aTo+TDI0nXIrd fFlmIaiZ/Rio8gu99Fk1zyliIpuDX1Nn8NcgXSGkvk2gQhVj5IPolhAOceg8j922A5IR PA88L+a7Z39LajYfWKSsFGMgYmj8qpmB6NvrZtOfRQJOFV8gSbXswg6IfrchrR4jz4pK U8CqY+1/CzM1xU74KYFJNH4vc1qiANKOt8ndlmXTt5n7fa53ll5cf8jBZtvzG7yYK4Ei hkwcOEl+x5S0gw5agoks6ckf+r/mHotliQqAxvOZMemKlUtoKw9UoRu9UMf5h0puMLAg DmWg== 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:mime-version:content-transfer-encoding; bh=aJOgLJbUU33d0sFNF8d3VZOVm5JVuSp9jkJ/aPDzPik=; b=Y7Dzhg4t0RDceMWNScEi71pPAKaZMuA9My+ytBQRrMNhdKg5/R6ohgvvWn0lU2S28F nm54AvklkoBh7Qfn/e47488t02n+aGp+ckS56/T6u3C0xAf3QGByDGMmdZX4fc42z1ul Vrw8sdQW5b9q0MzSq0PB2tfXXRWHLYIYyHwLenDWp2Bmq5+a+XDWTx0H0el0BVlu7N2l RL7aieN4215t9zbZp8/8I5bWkMaL5aR2LAZpc08u4rWKrmWvf6jUjI9FcKhMsW83QgZd Iofb70nLHo1kfxAkYf/T1bRwYlJkj1q/WLFQRFipzNAzCmQofP69FnhpuN1T0jx70o8V tnYQ== X-Gm-Message-State: APjAAAUJrI0R7Gydk/r9ByveZj9cnyeL9Cmkz2i9vL0Kf9tUSE24fqGY iSkIeZuXyDbANxcjCSkVE+g8KeV3 X-Google-Smtp-Source: APXvYqz9Khx1uU7OuIacnmMKC0KnIARyLiTag+o2EStpbmqs1KhyRJ+vzjBt9NyYOsEN8irUeHplkg== X-Received: by 2002:a17:906:c742:: with SMTP id fk2mr17169378ejb.44.1568575423774; Sun, 15 Sep 2019 12:23:43 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Sun, 15 Sep 2019 21:23:21 +0200 Message-Id: <066dc6dd54f4382d80de4376306f585b7fb47805.1568574965.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::542 Subject: [Qemu-devel] [PATCH v3 05/24] noaudio: port to the new audio backend api 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: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/noaudio.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/audio/noaudio.c b/audio/noaudio.c index 0fb2629cf2..b054fd225b 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_S= ECOND); - 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_o= paque) @@ -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; - - 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_SEC= OND); - - no->old_ticks =3D now; - bytes =3D MIN (bytes, SIZE_MAX); - samples =3D bytes >> hw->info.shift; - samples =3D MIN (samples, dead); - } - return samples; + + 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_SECOND); + + 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.23.0