From patchwork Sun Dec 23 20:52:08 2018 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: 1018102 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=208.118.235.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="ahF5pr1t"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43NFRg6mZPz9sC7 for ; Mon, 24 Dec 2018 08:11:59 +1100 (AEDT) Received: from localhost ([127.0.0.1]:59800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbB2S-0006JO-Mm for incoming@patchwork.ozlabs.org; Sun, 23 Dec 2018 16:11:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbAk7-00087R-T3 for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:53:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbAk5-00031m-Tl for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:58 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbAk5-0002xp-N4 for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:57 -0500 Received: by mail-wm1-x341.google.com with SMTP id f81so10393873wmd.4 for ; Sun, 23 Dec 2018 12:52:57 -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=WipQek9x1u13Ko1/oMje1fHohsxHrq2H6frltFwooJw=; b=ahF5pr1tl0T15S13REj6NoTNda/Y/PpAn67m+1hGvmDJnY2PfxNEBzcQ42Ds5qKebu n3IKG3wjckiIiJp58h970v94k8pYsak5X1X21AsCpW+voXxZF4xx0+HrOGoblkQHuv79 N90QcbfevFrY78j+CfsJLqKG5DlrS6AmaVyCuUYeJrmw+TDaiD0jRynzXS0s3s6sTweE GKQONKurXdpg+phzEz1+vNxPHX4H13eNa4PyBYP01wKKyQ6s3SKAEm7EQhV5nKHt1dEv hSRxxQt7nkZX8YPAOltub/oeFmg0C8cij3Qsf3HbteMetQnRVB1TOH4iqq57BEHqm4lU ua/A== 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=WipQek9x1u13Ko1/oMje1fHohsxHrq2H6frltFwooJw=; b=Csf8MXzxzoKjdWFBtzZQ7clJLC1aUDr7ovSsEpiM7R7+Pi8SzkAyrHICQk4iGZahsu K2JWbUt+HA/t2uirwyFgv2FXTZHcE0t0sjaOaDgfaiVGRXgBc4Y7uOhYMcLseZQK+OBa 7i5NDLh43qqLq6MUxPf6+zyRVtQQNFMTKF7j9jLTCeZghbf1hhsmM03uLbkU3T98XnoI e0jGy+fLYM/W08UTpHSCkrslmFF9AeCVTe44uFIwVzaJmwqeluu9+4oSjrXHEdTk00KT RoPTh40SwK3M5zzIbiE5ju9TqtV4V6WMx2dpjV0W7cIr0bgEuNMdUBE0/Ax2ZL9+Tupk MQ8A== X-Gm-Message-State: AJcUukcsSNH/1EVdvot2lgiSmSmBIDcKMmJ7M5wPLWsFlFK2PtDE4osR fn1aM8SiIBv/Mnn6XEVdQyo0pP92lcU= X-Google-Smtp-Source: ALg8bN6NqKYR0lzgMGhbp0vnBgWSq6XGd6g1l8JhsOfBr+bKAIIv5GWbYBSaj8gKGeZZFvfhjCFo3g== X-Received: by 2002:a1c:9dc4:: with SMTP id g187mr93193wme.152.1545598376538; Sun, 23 Dec 2018 12:52:56 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-24a3-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:24a3::5]) by smtp.gmail.com with ESMTPSA id g198sm25456920wmd.23.2018.12.23.12.52.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Dec 2018 12:52:56 -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: Sun, 23 Dec 2018 21:52:08 +0100 Message-Id: <3cdadfc819548ae32d9c90877de7382c391d0371.1545598229.git.DirtY.iCE.hu@gmail.com> 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::341 Subject: [Qemu-devel] [PATCH v2 32/52] 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 c49f2df4b3..6a3a1c418b 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -40,10 +40,9 @@ typedef struct NoVoiceIn { int64_t old_ticks; } NoVoiceIn; -static int no_run_out (HWVoiceOut *hw, int live) +static size_t no_write(HWVoiceOut *hw, void *buf, size_t len) { NoVoiceOut *no = (NoVoiceOut *) hw; - int decr, samples; int64_t now; int64_t ticks; int64_t bytes; @@ -51,13 +50,9 @@ static int no_run_out (HWVoiceOut *hw, int 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, INT_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 int 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; - int live = audio_pcm_hw_get_live_in (hw); - int dead = hw->samples - live; - int 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, INT_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 };