diff mbox

[v4,0/2] Improve audio output quality

Message ID 1508309285.10073.6.camel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gerd Hoffmann Oct. 18, 2017, 6:48 a.m. UTC
Hi,

> This is still missing proper handling for VMState-migration, which I
> will need a bit of assistance with.

See attachment.  It adds a bool to the state and a property to turn
on/off the timer.  It also adds a vmstate subsection, which will only
saved in case the timer is in use.  Also extends the compat list so the
timer will be turned off for old machine types (-M pc-i440fx-2.10 &
older).

Background: Using "-M pc-i440fx-2.10" instead of "-M pc" puts qemu into
2.10 compatibility mode.  Live migration is supposed to work even
between different qemu versions as long as they use the same machine
type.

Missing:  Continue to use the old code in case the timer is turned off
(needed for backward compatibility).  Most of the changes are in the
callbacks, probably it is easiest to rename the existing callbacks
(_compat or _notimer postfix for example) and register the old or new
ones depending on the use_timer variable.

> Sorry for v4 already, having a hard time with the style checker
> bots... :(

There is scripts/checkpatch.pl to run those tests locally.

Which guests did you test with?

I did a brief test with Windows 7 and still have sound dropouts, even
though it seems to not be as bad as before.  Didn't investigate yet
why.

cheers,
  Gerd

Comments

Gerd Hoffmann Oct. 18, 2017, 10:57 a.m. UTC | #1
Hi,

> Which guests did you test with?
> 
> I did a brief test with Windows 7 and still have sound dropouts, even
> though it seems to not be as bad as before.  Didn't investigate yet
> why.

Played around a bit more.  Windows 10 seems to work a bit better. 
Pushed some incremental patches.

https://www.kraxel.org/cgit/qemu/log/?h=testing/hda

cheers,
  Gerd
diff mbox

Patch

From 7f7a8b2bb818ff7a76cfa592e06b2d271a0f8bcd Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 16 Oct 2017 12:22:57 +0200
Subject: [PATCH] hda buffer compatibility fluff

---
 include/hw/compat.h  |  4 ++++
 hw/audio/hda-codec.c | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/include/hw/compat.h b/include/hw/compat.h
index cf389b4e85..22d154035e 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -10,6 +10,10 @@ 
         .driver   = "virtio-tablet-device",\
         .property = "wheel-axis",\
         .value    = "false",\
+    },{\
+        .driver   = "hda-audio",\
+        .property = "use-timer",\
+        .value    = "false",\
     },
 
 #define HW_COMPAT_2_9 \
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index ab89158bfc..df7fc87f96 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -185,6 +185,7 @@  struct HDAAudioState {
     /* properties */
     uint32_t debug;
     bool     mixer;
+    bool     use_timer;
 };
 
 static inline int64_t hda_bytes_per_second(HDAAudioStream *st)
@@ -696,6 +697,26 @@  static void hda_audio_reset(DeviceState *dev)
     }
 }
 
+static bool vmstate_hda_audio_stream_buf_needed(void *opaque)
+{
+    HDAAudioStream *st = opaque;
+    return st->state->use_timer;
+}
+
+static const VMStateDescription vmstate_hda_audio_stream_buf = {
+    .name = "hda-audio-stream/buffer",
+    .version_id = 1,
+    .needed = vmstate_hda_audio_stream_buf_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_BUFFER(buf, HDAAudioStream),
+        VMSTATE_INT64(rpos, HDAAudioStream),
+        VMSTATE_INT64(wpos, HDAAudioStream),
+        VMSTATE_TIMER_PTR(buft, HDAAudioStream),
+        VMSTATE_INT64(buft_start, HDAAudioStream),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_hda_audio_stream = {
     .name = "hda-audio-stream",
     .version_id = 1,
@@ -710,6 +731,10 @@  static const VMStateDescription vmstate_hda_audio_stream = {
         VMSTATE_UINT32(compat_bpos, HDAAudioStream),
         VMSTATE_BUFFER(compat_buf, HDAAudioStream),
         VMSTATE_END_OF_LIST()
+    },
+    .subsections = (const VMStateDescription * []) {
+        &vmstate_hda_audio_stream_buf,
+        NULL
     }
 };
 
@@ -730,6 +755,7 @@  static const VMStateDescription vmstate_hda_audio = {
 static Property hda_audio_properties[] = {
     DEFINE_PROP_UINT32("debug", HDAAudioState, debug,   0),
     DEFINE_PROP_BOOL("mixer", HDAAudioState, mixer,  true),
+    DEFINE_PROP_BOOL("use-timer", HDAAudioState, use_timer,  true),
     DEFINE_PROP_END_OF_LIST(),
 };
 
-- 
2.9.3