[Spice-commits] 6 commits - server/main-channel.c server/main-channel-client.c server/red-channel.c server/red-channel-client.c server/red-channel-client.h server/red-channel.h server/reds.c server/reds.h server/sound.c server/sound.h server/stream.c

Jonathon Jongsma jjongsma at kemper.freedesktop.org
Fri Apr 7 20:09:10 UTC 2017


 server/main-channel-client.c |    4 ++--
 server/main-channel.c        |   16 ++++++++++------
 server/red-channel-client.c  |    4 ++--
 server/red-channel-client.h  |    4 ++--
 server/red-channel.c         |   13 -------------
 server/red-channel.h         |    1 -
 server/reds.c                |    4 ++--
 server/reds.h                |    2 +-
 server/sound.c               |   20 ++++++++++----------
 server/sound.h               |    2 +-
 server/stream.c              |    2 +-
 11 files changed, 31 insertions(+), 41 deletions(-)

New commits:
commit 72d5a6bd8f549a72c62d3006665c5ad40ca2129a
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Apr 6 14:56:24 2017 -0500

    Test client caps separately
    
    in main_channel_push_agent_connected(), it used the convenience function
    red_channel_test_remote_cap() to determine whether to send the
    AGENT_CONNECTED_TOKENS message, or the AGENT_CONNECTED message. However,
    this function returns false if *any* one client doesn't support the
    capability. We should instead check each individual client separately to
    see if they support the capability.

diff --git a/server/main-channel.c b/server/main-channel.c
index be4f7580..d0183258 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -99,12 +99,16 @@ void main_channel_push_mouse_mode(MainChannel *main_chan, int current_mode,
 
 void main_channel_push_agent_connected(MainChannel *main_chan)
 {
-    if (red_channel_test_remote_cap(RED_CHANNEL(main_chan),
-                                    SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)) {
-        red_channel_pipes_add_type(RED_CHANNEL(main_chan),
-                                   RED_PIPE_ITEM_TYPE_MAIN_AGENT_CONNECTED_TOKENS);
-    } else {
-        red_channel_pipes_add_empty_msg(RED_CHANNEL(main_chan), SPICE_MSG_MAIN_AGENT_CONNECTED);
+    GListIter iter;
+    RedChannelClient *rcc;
+    FOREACH_CLIENT(RED_CHANNEL(main_chan), iter, rcc) {
+        if (red_channel_client_test_remote_cap(rcc,
+                                               SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)) {
+            red_channel_client_pipe_add_type(rcc,
+                                             RED_PIPE_ITEM_TYPE_MAIN_AGENT_CONNECTED_TOKENS);
+        } else {
+            red_channel_client_pipe_add_empty_msg(rcc, SPICE_MSG_MAIN_AGENT_CONNECTED);
+        }
     }
 }
 
commit 1b18fd76d1e9349bb115ff456aaf5bc840385f90
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Apr 6 14:50:54 2017 -0500

    Remove unused red_channel_test_remote_common_cap()
    
    This was a convenience function around
    red_channel_client_test_remote_common_cap() that simply iterated over
    each client (currently we only really support a single client anyway)
    and returned TRUE only if all clients supported the capability. But
    nobody ever called this wrapper function.

diff --git a/server/red-channel.c b/server/red-channel.c
index 21630669..9bd98234 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -314,19 +314,6 @@ void red_channel_add_client(RedChannel *channel, RedChannelClient *rcc)
     channel->priv->clients = g_list_prepend(channel->priv->clients, rcc);
 }
 
-bool red_channel_test_remote_common_cap(RedChannel *channel, uint32_t cap)
-{
-    GListIter iter;
-    RedChannelClient *rcc;
-
-    FOREACH_CLIENT(channel, iter, rcc) {
-        if (!red_channel_client_test_remote_common_cap(rcc, cap)) {
-            return FALSE;
-        }
-    }
-    return TRUE;
-}
-
 bool red_channel_test_remote_cap(RedChannel *channel, uint32_t cap)
 {
     GListIter iter;
diff --git a/server/red-channel.h b/server/red-channel.h
index cc116396..a9088a7d 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -157,7 +157,6 @@ bool red_channel_is_waiting_for_migrate_data(RedChannel *channel);
 void red_channel_destroy(RedChannel *channel);
 
 /* return true if all the channel clients support the cap */
-bool red_channel_test_remote_common_cap(RedChannel *channel, uint32_t cap);
 bool red_channel_test_remote_cap(RedChannel *channel, uint32_t cap);
 
 /* should be called when a new channel is ready to send messages */
commit a5c15dfadfb589b0cb215d2ec78268612cbf10e7
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Apr 6 11:23:26 2017 -0500

    Remove extra space between "!" and variable name

diff --git a/server/sound.c b/server/sound.c
index ff78c085..6a6d9650 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -976,7 +976,7 @@ void snd_set_playback_latency(RedClient *client, uint32_t latency)
 static int snd_desired_audio_mode(bool playback_compression, int frequency,
                                   bool client_can_celt, bool client_can_opus)
 {
-    if (! playback_compression)
+    if (!playback_compression)
         return SPICE_AUDIO_DATA_MODE_RAW;
 
     if (client_can_opus && snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_OPUS, frequency))
commit 9d49c6bb03d9da325645af2857be511f1d1136e3
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Apr 6 11:22:51 2017 -0500

    snd_desired_audio_mode: change arguments to bool
    
    client_can_celt and client_can_opus are true/false values, so use
    'bool' type instead of 'int.

diff --git a/server/sound.c b/server/sound.c
index ff9a37a1..ff78c085 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -974,7 +974,7 @@ void snd_set_playback_latency(RedClient *client, uint32_t latency)
 }
 
 static int snd_desired_audio_mode(bool playback_compression, int frequency,
-                                  int client_can_celt, int client_can_opus)
+                                  bool client_can_celt, bool client_can_opus)
 {
     if (! playback_compression)
         return SPICE_AUDIO_DATA_MODE_RAW;
commit 9b0824bae40924cab280d6af2bc8a361de4a4ca8
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Apr 6 11:21:09 2017 -0500

    red_channel_client_test_remote_cap() returns bool
    
    Both _test_remote_cap() and _test_remote_common_cap() are used as
    boolean values, so change the return type from int to bool to follow our
    coding standard.

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 8d3d9a4e..9eb60c99 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -620,8 +620,8 @@ gboolean main_channel_client_migrate_src_complete(MainChannelClient *mcc,
     gboolean ret = FALSE;
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(mcc);
     RedClient *client = red_channel_client_get_client(rcc);
-    int semi_seamless_support = red_channel_client_test_remote_cap(rcc,
-                                                                   SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE);
+    bool semi_seamless_support = red_channel_client_test_remote_cap(rcc,
+                                                                    SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE);
     if (semi_seamless_support && mcc->priv->mig_connect_ok) {
         if (success) {
             spice_printerr("client %p MIGRATE_END", client);
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index ef0e8926..4eac231b 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -664,14 +664,14 @@ static gboolean red_channel_client_pipe_remove(RedChannelClient *rcc, RedPipeIte
     return g_queue_remove(&rcc->priv->pipe, item);
 }
 
-int red_channel_client_test_remote_common_cap(RedChannelClient *rcc, uint32_t cap)
+bool red_channel_client_test_remote_common_cap(RedChannelClient *rcc, uint32_t cap)
 {
     return test_capability(rcc->priv->remote_caps.common_caps,
                            rcc->priv->remote_caps.num_common_caps,
                            cap);
 }
 
-int red_channel_client_test_remote_cap(RedChannelClient *rcc, uint32_t cap)
+bool red_channel_client_test_remote_cap(RedChannelClient *rcc, uint32_t cap)
 {
     return test_capability(rcc->priv->remote_caps.caps,
                            rcc->priv->remote_caps.num_caps,
diff --git a/server/red-channel-client.h b/server/red-channel-client.h
index ae83109d..52527399 100644
--- a/server/red-channel-client.h
+++ b/server/red-channel-client.h
@@ -51,8 +51,8 @@ gboolean red_channel_client_is_connected(RedChannelClient *rcc);
 void red_channel_client_default_migrate(RedChannelClient *rcc);
 bool red_channel_client_is_waiting_for_migrate_data(RedChannelClient *rcc);
 void red_channel_client_destroy(RedChannelClient *rcc);
-int red_channel_client_test_remote_common_cap(RedChannelClient *rcc, uint32_t cap);
-int red_channel_client_test_remote_cap(RedChannelClient *rcc, uint32_t cap);
+bool red_channel_client_test_remote_common_cap(RedChannelClient *rcc, uint32_t cap);
+bool red_channel_client_test_remote_cap(RedChannelClient *rcc, uint32_t cap);
 /* shutdown is the only safe thing to do out of the client/channel
  * thread. It will not touch the rings, just shutdown the socket.
  * It should be followed by some way to guarantee a disconnection. */
diff --git a/server/sound.c b/server/sound.c
index c80716d4..ff9a37a1 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -1044,9 +1044,9 @@ playback_channel_client_constructed(GObject *object)
     SND_CHANNEL_CLIENT(playback_client)->on_message_done = snd_playback_on_message_done;
 
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(playback_client);
-    int client_can_celt = red_channel_client_test_remote_cap(rcc,
+    bool client_can_celt = red_channel_client_test_remote_cap(rcc,
                                           SPICE_PLAYBACK_CAP_CELT_0_5_1);
-    int client_can_opus = red_channel_client_test_remote_cap(rcc,
+    bool client_can_opus = red_channel_client_test_remote_cap(rcc,
                                           SPICE_PLAYBACK_CAP_OPUS);
     bool playback_compression =
         reds_config_get_playback_compression(red_channel_get_server(red_channel));
@@ -1192,7 +1192,7 @@ SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance
 
 static uint32_t snd_get_best_rate(SndChannelClient *client, uint32_t cap_opus)
 {
-    int client_can_opus = TRUE;
+    bool client_can_opus = TRUE;
     if (client) {
         client_can_opus = red_channel_client_test_remote_cap(RED_CHANNEL_CLIENT(client), cap_opus);
     }
@@ -1460,9 +1460,9 @@ void snd_set_playback_compression(bool on)
         if (type == SPICE_CHANNEL_PLAYBACK && now->connection) {
             PlaybackChannelClient* playback = (PlaybackChannelClient*)now->connection;
             RedChannelClient *rcc = RED_CHANNEL_CLIENT(playback);
-            int client_can_celt = red_channel_client_test_remote_cap(rcc,
+            bool client_can_celt = red_channel_client_test_remote_cap(rcc,
                                     SPICE_PLAYBACK_CAP_CELT_0_5_1);
-            int client_can_opus = red_channel_client_test_remote_cap(rcc,
+            bool client_can_opus = red_channel_client_test_remote_cap(rcc,
                                     SPICE_PLAYBACK_CAP_OPUS);
             int desired_mode = snd_desired_audio_mode(on, now->frequency,
                                                       client_can_opus, client_can_celt);
diff --git a/server/stream.c b/server/stream.c
index 04af0505..f6ff0de3 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -689,7 +689,7 @@ static VideoEncoder* dcc_create_video_encoder(DisplayChannelClient *dcc,
                                               VideoEncoderRateControlCbs *cbs)
 {
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(dcc);
-    int client_has_multi_codec = red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_MULTI_CODEC);
+    bool client_has_multi_codec = red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_MULTI_CODEC);
     int i;
     GArray *video_codecs;
 
commit 332ad521438ba5d93805602606c38891b60797b8
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Apr 6 11:10:28 2017 -0500

    Change playback_compression to bool type
    
    This is a setting for determining whether to compress the audio playback
    channel or not. It is variously typed as int or uint32_t. Convert it to
    a 'bool' to make it more clear that it is a true/false value rather than
    an enumeration or something like that.

diff --git a/server/reds.c b/server/reds.c
index 49b0ef00..2a8f905b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -182,7 +182,7 @@ struct RedServerConfig {
     uint32_t streaming_video;
     GArray* video_codecs;
     SpiceImageCompression image_compression;
-    uint32_t playback_compression;
+    bool playback_compression;
     spice_wan_compression_t jpeg_state;
     spice_wan_compression_t zlib_glz_state;
 
@@ -593,7 +593,7 @@ static void reds_mig_disconnect(RedsState *reds)
     }
 }
 
-int reds_config_get_playback_compression(RedsState *reds)
+bool reds_config_get_playback_compression(RedsState *reds)
 {
     return reds->config->playback_compression;
 }
diff --git a/server/reds.h b/server/reds.h
index 7466c602..e5f70d57 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -51,7 +51,7 @@ RedChannel *reds_find_channel(RedsState *reds, uint32_t type, uint32_t id);
 int reds_get_mouse_mode(RedsState *reds); // used by inputs_channel
 gboolean reds_config_get_agent_mouse(const RedsState *reds); // used by inputs_channel
 int reds_has_vdagent(RedsState *reds); // used by inputs channel
-int reds_config_get_playback_compression(RedsState *reds); // used by playback channel
+bool reds_config_get_playback_compression(RedsState *reds); // used by playback channel
 
 void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mouse_state); // used by inputs_channel
 
diff --git a/server/sound.c b/server/sound.c
index 75bd0e7d..c80716d4 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -973,7 +973,7 @@ void snd_set_playback_latency(RedClient *client, uint32_t latency)
     }
 }
 
-static int snd_desired_audio_mode(int playback_compression, int frequency,
+static int snd_desired_audio_mode(bool playback_compression, int frequency,
                                   int client_can_celt, int client_can_opus)
 {
     if (! playback_compression)
@@ -1048,7 +1048,7 @@ playback_channel_client_constructed(GObject *object)
                                           SPICE_PLAYBACK_CAP_CELT_0_5_1);
     int client_can_opus = red_channel_client_test_remote_cap(rcc,
                                           SPICE_PLAYBACK_CAP_OPUS);
-    int playback_compression =
+    bool playback_compression =
         reds_config_get_playback_compression(red_channel_get_server(red_channel));
     int desired_mode = snd_desired_audio_mode(playback_compression, channel->frequency,
                                               client_can_celt, client_can_opus);
@@ -1450,7 +1450,7 @@ void snd_detach_record(SpiceRecordInstance *sin)
     snd_detach_common(&sin->st->channel);
 }
 
-void snd_set_playback_compression(int on)
+void snd_set_playback_compression(bool on)
 {
     SndChannel *now = snd_channels;
 
diff --git a/server/sound.h b/server/sound.h
index f7bcaa64..2f0a2b93 100644
--- a/server/sound.h
+++ b/server/sound.h
@@ -28,7 +28,7 @@ void snd_detach_playback(SpicePlaybackInstance *sin);
 void snd_attach_record(RedsState *reds, SpiceRecordInstance *sin);
 void snd_detach_record(SpiceRecordInstance *sin);
 
-void snd_set_playback_compression(int on);
+void snd_set_playback_compression(bool on);
 
 void snd_set_playback_latency(struct RedClient *client, uint32_t latency);
 


More information about the Spice-commits mailing list