qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	"Volker Rümelin" <vr_qemu@t-online.de>
Subject: [Qemu-devel] [PULL 5/5] audio: fix audio timer rate conversion bug
Date: Tue,  2 Apr 2019 08:46:39 +0200	[thread overview]
Message-ID: <20190402064639.27108-6-kraxel@redhat.com> (raw)
In-Reply-To: <20190402064639.27108-1-kraxel@redhat.com>

From: Volker Rümelin <vr_qemu@t-online.de>

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 <vr_qemu@t-online.de>
Reviewed-by: Zoltán Kővágó <DirtY.iCE.hu@gmail.com>
Message-id: 90b95e4f-39ef-2b01-da6a-857ebaee1ec5@t-online.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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:
-- 
2.18.1

  parent reply	other threads:[~2019-04-02  7:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02  6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 1/5] Revert "audio: fix pc speaker init" Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 2/5] hw/usb/bus.c: Handle "no speed matched" case in usb_mask_to_str() Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 3/5] usb-mtp: fix return status of delete Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 4/5] usb-mtp: remove usb_mtp_object_free_one Gerd Hoffmann
2019-04-02  6:46 ` Gerd Hoffmann [this message]
2019-04-02  8:33 ` [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190402064639.27108-6-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vr_qemu@t-online.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).