[Spice-devel] [PATCH spice] snd_worker: Make sure we never send an empty volume message

Hans de Goede hdegoede at redhat.com
Fri Apr 19 05:01:07 PDT 2013


My commit 71315b2e "snd_worker: Don't send empty audio-volume messages",
fixes only one case of sending an empty volume message, if the client connects
to a vm early during its boot sequence, while the snd hardware is being reset
by the guest driver, qemu will call spice_server_playback_set_volume() with
0 channels from the reset handler.

This patch also applies both fixes to the record channel.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 server/snd_worker.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/server/snd_worker.c b/server/snd_worker.c
index 010c152..2647d87 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -984,7 +984,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_volume(SpicePlaybackInstance *
     free(st->volume);
     st->volume = spice_memdup(volume, sizeof(uint16_t) * nchannels);
 
-    if (!channel)
+    if (!channel || nchannels == 0)
         return;
 
     snd_playback_send_volume(playback_channel);
@@ -1222,7 +1222,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_set_volume(SpiceRecordInstance *sin,
     free(st->volume);
     st->volume = spice_memdup(volume, sizeof(uint16_t) * nchannels);
 
-    if (!channel)
+    if (!channel || nchannels == 0)
         return;
 
     snd_record_send_volume(record_channel);
@@ -1321,9 +1321,13 @@ SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance
 static void on_new_record_channel(SndWorker *worker)
 {
     RecordChannel *record_channel = (RecordChannel *)worker->connection;
+    SpiceRecordState *st = SPICE_CONTAINEROF(worker, SpiceRecordState, worker);
+
     spice_assert(record_channel);
 
-    snd_set_command((SndChannel *)record_channel, SND_RECORD_VOLUME_MASK);
+    if (st->volume.volume_nchannels) {
+        snd_set_command((SndChannel *)record_channel, SND_RECORD_VOLUME_MASK);
+    }
     if (record_channel->base.active) {
         snd_set_command((SndChannel *)record_channel, SND_RECORD_CTRL_MASK);
     }
-- 
1.8.2



More information about the Spice-devel mailing list