From nobody Fri Nov 7 04:13:09 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547683352779414.4000627042558; Wed, 16 Jan 2019 16:02:32 -0800 (PST) Received: from localhost ([127.0.0.1]:37070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjv8h-0006Lu-LJ for importer@patchew.org; Wed, 16 Jan 2019 19:02:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjukz-0004IF-KA for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:38:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjukv-0003DO-TY for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:59 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:33800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjukt-000388-Nb for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:56 -0500 Received: by mail-wr1-x444.google.com with SMTP id j2so9012949wrw.1 for ; Wed, 16 Jan 2019 15:37:53 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-e4b0-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:e4b0::5]) by smtp.gmail.com with ESMTPSA id s66sm30760437wmf.34.2019.01.16.15.37.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 15:37:52 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=N+A2xH2hiqjAiUAulU3GcZpOwJkdZbBvxfkx4/ncV6I=; b=p4DC2PRmikouid9NHRD8/cur8aClFXuKkTv7HQtUmlOtvXwhYQ45JFehVzDd4TbgFO 6QuulUzhVkyRW0yU5yN0kg3FFgOb8pXlPFaxulZpVeMvdpugX12DxUb/MaC+opaHlD61 UA8Jnde8+WcWZtT9sSa+KZrl22mOk/MXiDwTmoV+o86S/6Aj3u89aOxQQbKPXz8ZqXmq OX6GP0AEG4ksuiO6SbUGGj16s0k+HQhFeJQrX3G3nkvzb0RIhdz4sNRtyzYzP26ds8ZE 2uPyJl8kyp6mKQP/ImAOfmIWIdcUCAV+FGleMaF0l5ouYC6HLKLc6SZrqMJQOBnZxRZX i03w== 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=N+A2xH2hiqjAiUAulU3GcZpOwJkdZbBvxfkx4/ncV6I=; b=SGEpsdAS44IaOkyltByeZzzqAzFZRQXli+9RwI7mn+86ck1b7vkjBdIXC2kM1oUmZR JXTqk8/Txxcndyv02c7pZZCuvOoRbEIMKAqfbCm4lh6fvPQntysoo+G/T0fbfZW5vyfG 8V+58K/NLDyzIABIV3XVczXY4mZ4MitwLyiqV1XZOMn7NxOGLVI/jVOIvEcKOGLyBDkG 1wv3kN8NB7Yf6K/IwvHhSuNL+c0wzMnVDP1OhFrpfN+cXcPwkBtBnG6xvTQAItTnFR5H 7G3jGpIC2gcuBAh1yzPR9f00GAGHlO2yNGM7btXR++uSDehVZGxnLMHpMlWptKXJY9W+ OeTA== X-Gm-Message-State: AJcUukeEWBYNyGkHaAMaym11UPtwK0ySccswJNxgFPBIc/xuBGFmoRms 0ZctXdJ1lOs28H3tokxv+RgO6weoAlk= X-Google-Smtp-Source: ALg8bN6dkFmbvhLF58Nnu7sJM079vaFDGohS1NN0DRz5krMKJ8QvhZu74CfdEufLdzn5mmLWdfac3w== X-Received: by 2002:adf:8228:: with SMTP id 37mr9232213wrb.160.1547681872722; Wed, 16 Jan 2019 15:37:52 -0800 (PST) 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: Thu, 17 Jan 2019 00:37:03 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 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::444 Subject: [Qemu-devel] [PATCH v3 30/50] noaudio: port to the new audio backend api X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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 | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/audio/noaudio.c b/audio/noaudio.c index 59e680db6f..647558f54c 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -40,10 +40,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; @@ -51,13 +50,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) @@ -91,25 +86,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_SEC= OND); + 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= ); =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, ...) @@ -132,12 +123,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.20.1