[PATCH v11 08/11] sound: Reuse code to set volume and mute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 server/sound.c | 51 +++++++++++++++++++++------------------------------
 1 file changed, 21 insertions(+), 30 deletions(-)

diff --git a/server/sound.c b/server/sound.c
index 3feddb9..f6a21a0 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -836,12 +836,11 @@ static void snd_set_command(SndChannelClient *client, uint32_t command)
     client->command |= command;
 }
 
-SPICE_GNUC_VISIBLE void spice_server_playback_set_volume(SpicePlaybackInstance *sin,
-                                                  uint8_t nchannels,
-                                                  uint16_t *volume)
+static void snd_channel_set_volume(SndChannel *channel,
+                                   uint8_t nchannels, uint16_t *volume)
 {
-    SpiceVolumeState *st = &sin->st->channel.volume;
-    SndChannelClient *client = sin->st->channel.connection;
+    SpiceVolumeState *st = &channel->volume;
+    SndChannelClient *client = channel->connection;
 
     st->volume_nchannels = nchannels;
     free(st->volume);
@@ -854,10 +853,17 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_volume(SpicePlaybackInstance *
     snd_send(client);
 }
 
-SPICE_GNUC_VISIBLE void spice_server_playback_set_mute(SpicePlaybackInstance *sin, uint8_t mute)
+SPICE_GNUC_VISIBLE void spice_server_playback_set_volume(SpicePlaybackInstance *sin,
+                                                  uint8_t nchannels,
+                                                  uint16_t *volume)
 {
-    SpiceVolumeState *st = &sin->st->channel.volume;
-    SndChannelClient *client = sin->st->channel.connection;
+    snd_channel_set_volume(&sin->st->channel, nchannels, volume);
+}
+
+static void snd_channel_set_mute(SndChannel *channel, uint8_t mute)
+{
+    SpiceVolumeState *st = &channel->volume;
+    SndChannelClient *client = channel->connection;
 
     st->mute = mute;
 
@@ -868,6 +874,11 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_mute(SpicePlaybackInstance *si
     snd_send(client);
 }
 
+SPICE_GNUC_VISIBLE void spice_server_playback_set_mute(SpicePlaybackInstance *sin, uint8_t mute)
+{
+    snd_channel_set_mute(&sin->st->channel, mute);
+}
+
 static void snd_playback_start(SndChannel *channel)
 {
     SndChannelClient *client = channel->connection;
@@ -1153,32 +1164,12 @@ SPICE_GNUC_VISIBLE void spice_server_record_set_volume(SpiceRecordInstance *sin,
                                                 uint8_t nchannels,
                                                 uint16_t *volume)
 {
-    SpiceVolumeState *st = &sin->st->channel.volume;
-    SndChannelClient *client = sin->st->channel.connection;
-
-    st->volume_nchannels = nchannels;
-    free(st->volume);
-    st->volume = spice_memdup(volume, sizeof(uint16_t) * nchannels);
-
-    if (!client || nchannels == 0)
-        return;
-
-    snd_set_command(client, SND_VOLUME_MUTE_MASK);
-    snd_send(client);
+    snd_channel_set_volume(&sin->st->channel, nchannels, volume);
 }
 
 SPICE_GNUC_VISIBLE void spice_server_record_set_mute(SpiceRecordInstance *sin, uint8_t mute)
 {
-    SpiceVolumeState *st = &sin->st->channel.volume;
-    SndChannelClient *client = sin->st->channel.connection;
-
-    st->mute = mute;
-
-    if (!client)
-        return;
-
-    snd_set_command(client, SND_VOLUME_MUTE_MASK);
-    snd_send(client);
+    snd_channel_set_mute(&sin->st->channel, mute);
 }
 
 static void snd_record_start(SndChannel *channel)
-- 
git-series 0.9.1
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]