From patchwork Thu Jan 14 13:45:44 2016 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: 567470 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 677A41402E2 for ; Fri, 15 Jan 2016 01:06:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=1FNMC1hP; dkim-atps=neutral Received: from localhost ([::1]:42700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJiXG-0007kU-4G for incoming@patchwork.ozlabs.org; Thu, 14 Jan 2016 09:05:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJiEW-0001Yc-4R for qemu-devel@nongnu.org; Thu, 14 Jan 2016 08:46:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJiEV-0003Vy-3D for qemu-devel@nongnu.org; Thu, 14 Jan 2016 08:46:36 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJiEU-0003VT-RR for qemu-devel@nongnu.org; Thu, 14 Jan 2016 08:46:35 -0500 Received: by mail-wm0-x242.google.com with SMTP id u188so43610434wmu.0 for ; Thu, 14 Jan 2016 05:46:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=FB44/+JfLVii7jIjndh7CX4Da04+QLLhDDqX1A06cx0=; b=1FNMC1hPwOia0PcG+U7IJpImhj61ppeir4h0dph0tD0Jr/r6WalowQQ0NECas2Xa8h cO8hvqbD4WMJ/Y2qw5gg4UtoC7L6RI+ZAwGszQokyB9LdL5I6O+0D/rD4p/Aa561DzHs ormYESJhdgVdhMmuGqpCzDeiq3T09zAzU1ddvEArG5Y9IU+QuOC1AAAXVMq+gKBjYklT pYhlVlb18dYTZDrERvfylcpEyE0Y0oAdJ3X2Z+OE+NWM0ecejt9WSUWrgPLuk6c4J8Wh FN+tXyM90/O7Xwz8w+mYcZnko4N/9htbUpDwMleJESC9qSVImebYG0tTx2IV5behl0y5 pkGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=FB44/+JfLVii7jIjndh7CX4Da04+QLLhDDqX1A06cx0=; b=CpM83wf38eM3OqaZL9SclJmHA8/JQSJ+fGq2NrVvsQu/Xngwr/5r98F2tW/4jmdVnB 7/zrrG0OXQtBn5hkT2x5bj0BkCtB65v2jTqMznfecqJ5Y3n6rHYZIhIDmvrdZEQ+TO9T B19TfpcJk29yQ9JgxFjQ1F5p06AsjuzfNGi0qAGNp+x0l+mgj+MZDr9NjyqHde6lcy0k uHK7iiRm5Dl4i58fu1p+u6Dh3Oq7ehwvP8mq9mWnlbpgGfiuGJR9mJBfvdOapJkTrELw G4f67pG8T8b7G6DZe8j5eLbbVsLBlN56qpxOKq4jSwplZb9XIzK5N1kuxZJAl8QfEKVF OMpA== X-Gm-Message-State: ALoCoQnL+2JCvsxEI5jv78JCUJSzRmil9pZ3S2Fd/Kd7ddBmYajbG19tO0c5fqvH7KUaGr93jA1U6jM40Z3Wkk0yjkcA1YpJxQ== X-Received: by 10.194.77.137 with SMTP id s9mr4023308wjw.171.1452779194168; Thu, 14 Jan 2016 05:46:34 -0800 (PST) Received: from nullptr.home.dirty-ice.org (188-143-126-18.pool.digikabel.hu. [188.143.126.18]) by smtp.gmail.com with ESMTPSA id 79sm7398061wmo.7.2016.01.14.05.46.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Jan 2016 05:46:33 -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, 14 Jan 2016 14:45:44 +0100 Message-Id: <8a83a68b5ef32ab8ef4be1f8226cd0b5c4ef5ae5.1452776884.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 31/51] noaudio: port to the new audio backend api X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 28c72d5..c7e47ae 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -38,10 +38,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; @@ -49,13 +48,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, get_ticks_per_sec ()); - 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) @@ -89,25 +84,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, get_ticks_per_sec ()); + 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, get_ticks_per_sec ()); - 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, ...) @@ -130,12 +121,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 };