From patchwork Wed Jan 16 23:37:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= X-Patchwork-Id: 1026313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="p4DC2PRm"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43g43N37PCz9sCh for ; Thu, 17 Jan 2019 11:00:48 +1100 (AEDT) Received: from localhost ([127.0.0.1]:36664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjv70-0004mQ-Aq for incoming@patchwork.ozlabs.org; Wed, 16 Jan 2019 19:00:46 -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) 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) 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) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?utf-8?b?S8WRdsOhZ8OzLCBab2x0w6Fu?= 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Kővágó, Zoltán --- 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; -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 = (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 = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ticks = now - no->old_ticks; bytes = muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SECOND); - bytes = MIN(bytes, SIZE_MAX); - samples = bytes >> hw->info.shift; no->old_ticks = now; - decr = MIN (live, samples); - hw->rpos = (hw->rpos + decr) % hw->samples; - return decr; + return MIN(len, bytes); } static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) @@ -91,25 +86,21 @@ static void no_fini_in (HWVoiceIn *hw) (void) hw; } -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 = (NoVoiceIn *) hw; - size_t live = audio_pcm_hw_get_live_in(hw); - size_t dead = hw->samples - live; - size_t samples = 0; - if (dead) { - int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - int64_t ticks = now - no->old_ticks; - int64_t bytes = - muldiv64(ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SECOND); + int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + int64_t ticks = now - no->old_ticks; + int64_t bytes = + muldiv64 (ticks, hw->info.bytes_per_second, NANOSECONDS_PER_SECOND); - no->old_ticks = now; - bytes = MIN (bytes, SIZE_MAX); - samples = bytes >> hw->info.shift; - samples = MIN (samples, dead); - } - return samples; + no->old_ticks = now; + to_clear = MIN(bytes, size); + + audio_pcm_info_clear_buf(&hw->info, buf, to_clear >> hw->info.shift); + return to_clear; } 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 = { .init_out = no_init_out, .fini_out = no_fini_out, - .run_out = no_run_out, + .write = no_write, .ctl_out = no_ctl_out, .init_in = no_init_in, .fini_in = no_fini_in, - .run_in = no_run_in, + .read = no_read, .ctl_in = no_ctl_in };