From 38999db39bd9d03bd37be6fc4acb268c295027d6 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 19 Apr 2013 13:57:31 +0200 Subject: snd_worker: Make sure we never send an empty volume message 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 --- server/snd_worker.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'server') diff --git a/server/snd_worker.c b/server/snd_worker.c index 010c1527..2647d878 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); } -- cgit