From patchwork Tue Apr 2 06:46:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10881139 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 6717C17E0 for ; Tue, 2 Apr 2019 07:06:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50E48287B1 for ; Tue, 2 Apr 2019 07:06:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44EB2287C5; Tue, 2 Apr 2019 07:06:07 +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 D9DB8287B1 for ; Tue, 2 Apr 2019 07:06:06 +0000 (UTC) Received: from localhost ([127.0.0.1]:40408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBDUk-0003w7-29 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 02 Apr 2019 03:06:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBDT3-0002bL-Um for qemu-devel@nongnu.org; Tue, 02 Apr 2019 03:04:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBDT1-0001Md-6w for qemu-devel@nongnu.org; Tue, 02 Apr 2019 03:04:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53646) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hBDC2-0005Su-5r for qemu-devel@nongnu.org; Tue, 02 Apr 2019 02:46:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7076B307D976; Tue, 2 Apr 2019 06:46:45 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A18260BEC; Tue, 2 Apr 2019 06:46:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2354AA1E9; Tue, 2 Apr 2019 08:46:40 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 2 Apr 2019 08:46:39 +0200 Message-Id: <20190402064639.27108-6-kraxel@redhat.com> In-Reply-To: <20190402064639.27108-1-kraxel@redhat.com> References: <20190402064639.27108-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 02 Apr 2019 06:46:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/5] audio: fix audio timer rate conversion bug 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: =?utf-8?q?Volker_R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Volker Rümelin Currently the default audio timer frequency is 10000Hz instead of a period of 10000us. Also the audiodev timer-period property gets converted like a frequency. Only handling of the legacy QEMU_AUDIO_TIMER_PERIOD environment variable is correct because it's actually a frequency. With this patch the property timer-period is really a timer period and QEMU_AUDIO_TIMER_PERIOD remains a frequency. Fixes: 71830221fb "-audiodev command line option basic implementation." Signed-off-by: Volker Rümelin Reviewed-by: Zoltán Kővágó Message-id: 90b95e4f-39ef-2b01-da6a-857ebaee1ec5@t-online.de Signed-off-by: Gerd Hoffmann --- audio/audio.c | 2 +- audio/audio_legacy.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index 5fd9a58a808f..2040762feff1 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1471,7 +1471,7 @@ static int audio_init(Audiodev *dev) if (dev->timer_period <= 0) { s->period_ticks = 1; } else { - s->period_ticks = NANOSECONDS_PER_SECOND / dev->timer_period; + s->period_ticks = dev->timer_period * SCALE_US; } e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 6d140119d98a..2fd58cb8ef25 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -26,6 +26,7 @@ #include "audio_int.h" #include "qemu-common.h" #include "qemu/cutils.h" +#include "qemu/timer.h" #include "qapi/error.h" #include "qapi/qapi-visit-audio.h" #include "qapi/visitor-impl.h" @@ -338,8 +339,13 @@ static AudiodevListEntry *legacy_opt(const char *drvname) handle_per_direction(audio_get_pdo_in(e->dev), "QEMU_AUDIO_ADC_"); handle_per_direction(audio_get_pdo_out(e->dev), "QEMU_AUDIO_DAC_"); + /* Original description: Timer period in HZ (0 - use lowest possible) */ get_int("QEMU_AUDIO_TIMER_PERIOD", &e->dev->timer_period, &e->dev->has_timer_period); + if (e->dev->has_timer_period && e->dev->timer_period) { + e->dev->timer_period = NANOSECONDS_PER_SECOND / 1000 / + e->dev->timer_period; + } switch (e->dev->driver) { case AUDIODEV_DRIVER_ALSA: