From patchwork Thu Mar 14 13:38:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schrodt X-Patchwork-Id: 10852885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC48D139A for ; Thu, 14 Mar 2019 13:57:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C541D2A4D7 for ; Thu, 14 Mar 2019 13:57:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9F0E2A4CE; Thu, 14 Mar 2019 13:57:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9DD6D2A4E1 for ; Thu, 14 Mar 2019 13:57:01 +0000 (UTC) Received: from localhost ([127.0.0.1]:37884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4Qqz-0000F4-1E for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Mar 2019 09:57:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4Qha-0000hn-PV for qemu-devel@nongnu.org; Thu, 14 Mar 2019 09:47:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4QZi-0000Xo-Ie for qemu-devel@nongnu.org; Thu, 14 Mar 2019 09:39:12 -0400 Received: from zapp.schrodt.org ([46.4.119.246]:37898) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h4QZg-0000Tc-CP for qemu-devel@nongnu.org; Thu, 14 Mar 2019 09:39:08 -0400 Received: from schapa.schrodt.org ([46.237.225.84]:37390 helo=zoidberg.machine.schrodt.org) by zapp.schrodt.org with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1h4QZW-0003H5-Ts; Thu, 14 Mar 2019 14:38:58 +0100 Received: from spheenik by zoidberg.machine.schrodt.org with local (Exim 4.92) (envelope-from ) id 1h4QZW-0009uU-Le; Thu, 14 Mar 2019 14:38:58 +0100 From: Martin Schrodt To: qemu-devel@nongnu.org Date: Thu, 14 Mar 2019 14:38:57 +0100 Message-Id: <20190314133858.37970-3-martin@schrodt.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190314133858.37970-1-martin@schrodt.org> References: <20190314133858.37970-1-martin@schrodt.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.4.119.246 Subject: [Qemu-devel] [PATCH 2/3] make latency configurable 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: kraxel@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Martin Schrodt --- audio/paaudio.c | 18 +++++++----------- qapi/audio.json | 5 ++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 1a799ca3e7..c9007fdb01 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -500,16 +500,12 @@ static pa_stream *qpa_simple_new ( if (dir == PA_STREAM_PLAYBACK) { r = pa_stream_connect_playback (stream, dev, attr, PA_STREAM_INTERPOLATE_TIMING -#ifdef PA_STREAM_ADJUST_LATENCY |PA_STREAM_ADJUST_LATENCY -#endif |PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL); } else { r = pa_stream_connect_record (stream, dev, attr, PA_STREAM_INTERPOLATE_TIMING -#ifdef PA_STREAM_ADJUST_LATENCY |PA_STREAM_ADJUST_LATENCY -#endif |PA_STREAM_AUTO_TIMING_UPDATE); } @@ -549,12 +545,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as, ss.channels = as->nchannels; ss.rate = as->freq; - /* - * qemu audio tick runs at 100 Hz (by default), so processing - * data chunks worth 10 ms of sound should be a good fit. - */ - ba.tlength = pa_usec_to_bytes (10 * 1000, &ss); - ba.minreq = pa_usec_to_bytes (5 * 1000, &ss); + ba.tlength = pa_usec_to_bytes (ppdo->latency, &ss); + ba.minreq = -1; ba.maxlength = -1; ba.prebuf = -1; @@ -813,7 +805,11 @@ static int qpa_validate_per_direction_opts (Audiodev *dev, AudiodevPaPerDirectio { if (!pdo->has_buffer_length) { pdo->has_buffer_length = true; - pdo->buffer_length = dev->timer_period * 4; + pdo->buffer_length = dev->timer_period * 9 / 2; + } + if (!pdo->has_latency) { + pdo->has_latency = true; + pdo->latency = 15000; } return 1; } diff --git a/qapi/audio.json b/qapi/audio.json index 97aee37288..3717d552cd 100644 --- a/qapi/audio.json +++ b/qapi/audio.json @@ -206,12 +206,15 @@ # # @name: name of the sink/source to use # +# @latency: latency you want PulseAudio to archieve in microseconds +# (default 15000) # Since: 4.0 ## { 'struct': 'AudiodevPaPerDirectionOptions', 'base': 'AudiodevPerDirectionOptions', 'data': { - '*name': 'str' } } + '*name': 'str', + '*latency': 'uint32' } } ## # @AudiodevPaOptions: