diff mbox

[07/11] audio/spice: add support for volume control

Message ID 1316621468-32171-8-git-send-email-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Sept. 21, 2011, 4:11 p.m. UTC
---
 audio/spiceaudio.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

Comments

Gerd Hoffmann Oct. 11, 2011, 8:49 a.m. UTC | #1
Hi,

> +#else
> +#warning "Spice playback volume unsupported"
> +#endif

> +#else
> +#warning "Spice record volume unsupported"
> +#endif

One warning is enougth.  But given that qemu builds with -Werror by 
default printing a warning just because of an older spice-server version 
is a bad idea IMHO.

> @@ -337,6 +379,7 @@ struct audio_driver spice_audio_driver = {
>       .max_voices_in  = 1,
>       .voice_size_out = sizeof (SpiceVoiceOut),
>       .voice_size_in  = sizeof (SpiceVoiceIn),
> +    .ctl_caps       = VOICE_VOLUME_CAP

This should be #ifdef'ed too I guess?

cheers,
   Gerd
Marc-André Lureau Oct. 13, 2011, 12:06 p.m. UTC | #2
Hi

On Tue, Oct 11, 2011 at 10:49 AM, Gerd Hoffmann <kraxel@redhat.com> wrote:
>> +#else
>> +#warning "Spice playback volume unsupported"
>> +#endif
>
>> +#else
>> +#warning "Spice record volume unsupported"
>> +#endif
>
> One warning is enougth.  But given that qemu builds with -Werror by default
> printing a warning just because of an older spice-server version is a bad
> idea IMHO.

There were 2 warnings, because the interfaces checked are different.
But since qemu build with -Werror, let's just remove them.

>> @@ -337,6 +379,7 @@ struct audio_driver spice_audio_driver = {
>>      .max_voices_in  = 1,
>>      .voice_size_out = sizeof (SpiceVoiceOut),
>>      .voice_size_in  = sizeof (SpiceVoiceIn),
>> +    .ctl_caps       = VOICE_VOLUME_CAP
>
> This should be #ifdef'ed too I guess?

Agreed, to fallback on mixemu volume in that case.
diff mbox

Patch

diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index f972110..2df0957 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -202,7 +202,28 @@  static int line_out_ctl (HWVoiceOut *hw, int cmd, ...)
         }
         spice_server_playback_stop (&out->sin);
         break;
+    case VOICE_VOLUME:
+        {
+#if ((SPICE_INTERFACE_PLAYBACK_MAJOR >= 1) && (SPICE_INTERFACE_PLAYBACK_MINOR >= 2))
+            SWVoiceOut *sw;
+            va_list ap;
+            uint16_t vol[2];
+
+            va_start (ap, cmd);
+            sw = va_arg (ap, SWVoiceOut *);
+            va_end (ap);
+
+            vol[0] = sw->vol.l >> 16;
+            vol[1] = sw->vol.r >> 16;
+            spice_server_playback_set_volume (&out->sin, 2, vol);
+            spice_server_playback_set_mute (&out->sin, sw->vol.mute);
+#else
+#warning "Spice playback volume unsupported"
+#endif
+            break;
+        }
     }
+
     return 0;
 }
 
@@ -304,7 +325,28 @@  static int line_in_ctl (HWVoiceIn *hw, int cmd, ...)
         in->active = 0;
         spice_server_record_stop (&in->sin);
         break;
+    case VOICE_VOLUME:
+        {
+#if ((SPICE_INTERFACE_RECORD_MAJOR >= 2) && (SPICE_INTERFACE_RECORD_MINOR >= 2))
+            SWVoiceIn *sw;
+            va_list ap;
+            uint16_t vol[2];
+
+            va_start (ap, cmd);
+            sw = va_arg (ap, SWVoiceIn *);
+            va_end (ap);
+
+            vol[0] = sw->vol.l >> 16;
+            vol[1] = sw->vol.r >> 16;
+            spice_server_record_set_volume (&in->sin, 2, vol);
+            spice_server_record_set_mute (&in->sin, sw->vol.mute);
+#else
+#warning "Spice record volume unsupported"
+#endif
+            break;
+        }
     }
+
     return 0;
 }
 
@@ -337,6 +379,7 @@  struct audio_driver spice_audio_driver = {
     .max_voices_in  = 1,
     .voice_size_out = sizeof (SpiceVoiceOut),
     .voice_size_in  = sizeof (SpiceVoiceIn),
+    .ctl_caps       = VOICE_VOLUME_CAP
 };
 
 void qemu_spice_audio_init (void)