[Spice-devel] [PATCH v3 02/17] sound: Rename SndChannel to SndChannelClient

Frediano Ziglio fziglio at redhat.com
Tue Nov 29 14:57:02 UTC 2016


SndWorker has been historically based on RedChannel, initial git commit
has:
struct SndWorker {
     Channel base;
     ...
};

SndChannel, contrary to what its name may imply is more focused on
marshalling/sending of sound data, which is the responsibility of
RedChannelClient for the other SPICE channels.

This commit and following ones make the naming of these 2 types more
consistent with how the rest of the code is structured.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/sound.c | 112 +++++++++++++++++++++++++-------------------------
 1 file changed, 56 insertions(+), 56 deletions(-)

diff --git a/server/sound.c b/server/sound.c
index beab473..5afc7c6 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -73,16 +73,16 @@ enum PlaybackCommand {
 #define SND_PLAYBACK_PCM_MASK (1 << SND_PLAYBACK_PCM)
 #define SND_PLAYBACK_LATENCY_MASK ( 1 << SND_PLAYBACK_LATENCY)
 
-typedef struct SndChannel SndChannel;
+typedef struct SndChannelClient SndChannelClient;
 typedef void (*snd_channel_send_messages_proc)(void *in_channel);
-typedef int (*snd_channel_handle_message_proc)(SndChannel *channel, size_t size, uint32_t type, void *message);
-typedef void (*snd_channel_on_message_done_proc)(SndChannel *channel);
-typedef void (*snd_channel_cleanup_channel_proc)(SndChannel *channel);
+typedef int (*snd_channel_handle_message_proc)(SndChannelClient *channel, size_t size, uint32_t type, void *message);
+typedef void (*snd_channel_on_message_done_proc)(SndChannelClient *channel);
+typedef void (*snd_channel_cleanup_channel_proc)(SndChannelClient *channel);
 
 typedef struct SndWorker SndWorker;
 
 /* Connects an audio channel to a Spice client */
-struct SndChannel {
+struct SndChannelClient {
     RedsStream *stream;
     SndWorker *worker;
     spice_parse_channel_func_t parser;
@@ -127,7 +127,7 @@ struct AudioFrame {
 };
 
 struct PlaybackChannel {
-    SndChannel base;
+    SndChannelClient base;
     AudioFrame frames[3];
     AudioFrame *free_frames;
     AudioFrame *in_progress;   /* Frame being sent to the client */
@@ -147,7 +147,7 @@ typedef struct SpiceVolumeState {
 /* Base class for SpicePlaybackState and SpiceRecordState */
 struct SndWorker {
     RedChannel *base_channel;
-    SndChannel *connection; /* Only one client is supported */
+    SndChannelClient *connection; /* Only one client is supported */
     SndWorker *next; /* For the global SndWorker list */
 
     int active;
@@ -164,7 +164,7 @@ struct SpiceRecordState {
 };
 
 typedef struct RecordChannel {
-    SndChannel base;
+    SndChannelClient base;
     uint32_t samples[RECORD_SAMPLES_SIZE];
     uint32_t write_pos;
     uint32_t read_pos;
@@ -178,33 +178,33 @@ typedef struct RecordChannel {
 /* A list of all Spice{Playback,Record}State objects */
 static SndWorker *workers;
 
-static void snd_receive(SndChannel *channel);
+static void snd_receive(SndChannelClient *channel);
 static void snd_playback_start(SndWorker *worker);
 static void snd_record_start(SndWorker *worker);
 
-static SndChannel *snd_channel_ref(SndChannel *channel)
+static SndChannelClient *snd_channel_ref(SndChannelClient *channel)
 {
     channel->refs++;
     return channel;
 }
 
-static SndChannel *snd_channel_unref(SndChannel *channel)
+static SndChannelClient *snd_channel_unref(SndChannelClient *channel)
 {
     if (!--channel->refs) {
-        spice_printerr("SndChannel=%p freed", channel);
+        spice_printerr("SndChannelClient=%p freed", channel);
         free(channel);
         return NULL;
     }
     return channel;
 }
 
-static RedsState* snd_channel_get_server(SndChannel *channel)
+static RedsState* snd_channel_get_server(SndChannelClient *channel)
 {
     g_return_val_if_fail(channel != NULL, NULL);
     return red_channel_get_server(channel->worker->base_channel);
 }
 
-static void snd_disconnect_channel(SndChannel *channel)
+static void snd_disconnect_channel(SndChannelClient *channel)
 {
     SndWorker *worker;
     RedsState *reds;
@@ -218,7 +218,7 @@ static void snd_disconnect_channel(SndChannel *channel)
     red_channel = red_channel_client_get_channel(channel->channel_client);
     reds = snd_channel_get_server(channel);
     g_object_get(red_channel, "channel-type", &type, NULL);
-    spice_debug("SndChannel=%p rcc=%p type=%d",
+    spice_debug("SndChannelClient=%p rcc=%p type=%d",
                  channel, channel->channel_client, type);
     worker = channel->worker;
     channel->cleanup(channel);
@@ -240,7 +240,7 @@ static void snd_playback_free_frame(PlaybackChannel *playback_channel, AudioFram
     playback_channel->free_frames = frame;
 }
 
-static void snd_playback_on_message_done(SndChannel *channel)
+static void snd_playback_on_message_done(SndChannelClient *channel)
 {
     PlaybackChannel *playback_channel = (PlaybackChannel *)channel;
     if (playback_channel->in_progress) {
@@ -252,11 +252,11 @@ static void snd_playback_on_message_done(SndChannel *channel)
     }
 }
 
-static void snd_record_on_message_done(SndChannel *channel)
+static void snd_record_on_message_done(SndChannelClient *channel)
 {
 }
 
-static int snd_send_data(SndChannel *channel)
+static int snd_send_data(SndChannelClient *channel)
 {
     uint32_t n;
 
@@ -356,7 +356,7 @@ static int snd_record_handle_write(RecordChannel *record_channel, size_t size, v
     return TRUE;
 }
 
-static int snd_playback_handle_message(SndChannel *channel, size_t size, uint32_t type, void *message)
+static int snd_playback_handle_message(SndChannelClient *channel, size_t size, uint32_t type, void *message)
 {
     if (!channel) {
         return FALSE;
@@ -372,7 +372,7 @@ static int snd_playback_handle_message(SndChannel *channel, size_t size, uint32_
     return TRUE;
 }
 
-static int snd_record_handle_message(SndChannel *channel, size_t size, uint32_t type, void *message)
+static int snd_record_handle_message(SndChannelClient *channel, size_t size, uint32_t type, void *message)
 {
     RecordChannel *record_channel = (RecordChannel *)channel;
 
@@ -420,7 +420,7 @@ static int snd_record_handle_message(SndChannel *channel, size_t size, uint32_t 
     return TRUE;
 }
 
-static void snd_receive(SndChannel *channel)
+static void snd_receive(SndChannelClient *channel)
 {
     SpiceDataHeaderOpaque *header;
 
@@ -502,7 +502,7 @@ static void snd_receive(SndChannel *channel)
 
 static void snd_event(int fd, int event, void *data)
 {
-    SndChannel *channel = data;
+    SndChannelClient *channel = data;
 
     if (event & SPICE_WATCH_EVENT_READ) {
         snd_receive(channel);
@@ -512,7 +512,7 @@ static void snd_event(int fd, int event, void *data)
     }
 }
 
-static inline int snd_reset_send_data(SndChannel *channel, uint16_t verb)
+static inline int snd_reset_send_data(SndChannelClient *channel, uint16_t verb)
 {
     SpiceDataHeaderOpaque *header;
 
@@ -538,7 +538,7 @@ static inline int snd_reset_send_data(SndChannel *channel, uint16_t verb)
     return TRUE;
 }
 
-static int snd_begin_send_message(SndChannel *channel)
+static int snd_begin_send_message(SndChannelClient *channel)
 {
     SpiceDataHeaderOpaque *header = &channel->channel_client->priv->send_data.header;
 
@@ -548,7 +548,7 @@ static int snd_begin_send_message(SndChannel *channel)
     return snd_send_data(channel);
 }
 
-static int snd_channel_send_migrate(SndChannel *channel)
+static int snd_channel_send_migrate(SndChannelClient *channel)
 {
     SpiceMsgMigrate migrate;
 
@@ -567,7 +567,7 @@ static int snd_playback_send_migrate(PlaybackChannel *channel)
     return snd_channel_send_migrate(&channel->base);
 }
 
-static int snd_send_volume(SndChannel *channel, uint32_t cap, int msg)
+static int snd_send_volume(SndChannelClient *channel, uint32_t cap, int msg)
 {
     SpiceMsgAudioVolume *vol;
     uint8_t c;
@@ -597,7 +597,7 @@ static int snd_playback_send_volume(PlaybackChannel *playback_channel)
                            SPICE_MSG_PLAYBACK_VOLUME);
 }
 
-static int snd_send_mute(SndChannel *channel, uint32_t cap, int msg)
+static int snd_send_mute(SndChannelClient *channel, uint32_t cap, int msg)
 {
     SpiceMsgAudioMute mute;
     SpiceVolumeState *st = &channel->worker->volume;
@@ -623,7 +623,7 @@ static int snd_playback_send_mute(PlaybackChannel *playback_channel)
 
 static int snd_playback_send_latency(PlaybackChannel *playback_channel)
 {
-    SndChannel *channel = &playback_channel->base;
+    SndChannelClient *channel = &playback_channel->base;
     SpiceMsgPlaybackLatency latency_msg;
 
     spice_debug("latency %u", playback_channel->latency);
@@ -637,7 +637,7 @@ static int snd_playback_send_latency(PlaybackChannel *playback_channel)
 }
 static int snd_playback_send_start(PlaybackChannel *playback_channel)
 {
-    SndChannel *channel = (SndChannel *)playback_channel;
+    SndChannelClient *channel = (SndChannelClient *)playback_channel;
     SpiceMsgPlaybackStart start;
 
     if (!snd_reset_send_data(channel, SPICE_MSG_PLAYBACK_START)) {
@@ -656,7 +656,7 @@ static int snd_playback_send_start(PlaybackChannel *playback_channel)
 
 static int snd_playback_send_stop(PlaybackChannel *playback_channel)
 {
-    SndChannel *channel = (SndChannel *)playback_channel;
+    SndChannelClient *channel = (SndChannelClient *)playback_channel;
 
     if (!snd_reset_send_data(channel, SPICE_MSG_PLAYBACK_STOP)) {
         return FALSE;
@@ -667,7 +667,7 @@ static int snd_playback_send_stop(PlaybackChannel *playback_channel)
 
 static int snd_playback_send_ctl(PlaybackChannel *playback_channel)
 {
-    SndChannel *channel = (SndChannel *)playback_channel;
+    SndChannelClient *channel = (SndChannelClient *)playback_channel;
 
     if ((channel->client_active = channel->active)) {
         return snd_playback_send_start(playback_channel);
@@ -678,7 +678,7 @@ static int snd_playback_send_ctl(PlaybackChannel *playback_channel)
 
 static int snd_record_send_start(RecordChannel *record_channel)
 {
-    SndChannel *channel = (SndChannel *)record_channel;
+    SndChannelClient *channel = (SndChannelClient *)record_channel;
     SpiceMsgRecordStart start;
 
     if (!snd_reset_send_data(channel, SPICE_MSG_RECORD_START)) {
@@ -696,7 +696,7 @@ static int snd_record_send_start(RecordChannel *record_channel)
 
 static int snd_record_send_stop(RecordChannel *record_channel)
 {
-    SndChannel *channel = (SndChannel *)record_channel;
+    SndChannelClient *channel = (SndChannelClient *)record_channel;
 
     if (!snd_reset_send_data(channel, SPICE_MSG_RECORD_STOP)) {
         return FALSE;
@@ -707,7 +707,7 @@ static int snd_record_send_stop(RecordChannel *record_channel)
 
 static int snd_record_send_ctl(RecordChannel *record_channel)
 {
-    SndChannel *channel = (SndChannel *)record_channel;
+    SndChannelClient *channel = (SndChannelClient *)record_channel;
 
     if ((channel->client_active = channel->active)) {
         return snd_record_send_start(record_channel);
@@ -739,7 +739,7 @@ static int snd_record_send_migrate(RecordChannel *record_channel)
 
 static int snd_playback_send_write(PlaybackChannel *playback_channel)
 {
-    SndChannel *channel = (SndChannel *)playback_channel;
+    SndChannelClient *channel = (SndChannelClient *)playback_channel;
     AudioFrame *frame;
     SpiceMsgPlaybackPacket msg;
 
@@ -774,7 +774,7 @@ static int snd_playback_send_write(PlaybackChannel *playback_channel)
 
 static int playback_send_mode(PlaybackChannel *playback_channel)
 {
-    SndChannel *channel = (SndChannel *)playback_channel;
+    SndChannelClient *channel = (SndChannelClient *)playback_channel;
     SpiceMsgPlaybackMode mode;
 
     if (!snd_reset_send_data(channel, SPICE_MSG_PLAYBACK_MODE)) {
@@ -790,7 +790,7 @@ static int playback_send_mode(PlaybackChannel *playback_channel)
 static void snd_playback_send(void* data)
 {
     PlaybackChannel *playback_channel = (PlaybackChannel*)data;
-    SndChannel *channel = (SndChannel*)playback_channel;
+    SndChannelClient *channel = (SndChannelClient*)playback_channel;
 
     if (!playback_channel || !snd_send_data(data)) {
         return;
@@ -844,7 +844,7 @@ static void snd_playback_send(void* data)
 static void snd_record_send(void* data)
 {
     RecordChannel *record_channel = (RecordChannel*)data;
-    SndChannel *channel = (SndChannel*)record_channel;
+    SndChannelClient *channel = (SndChannelClient*)record_channel;
 
     if (!record_channel || !snd_send_data(data)) {
         return;
@@ -873,7 +873,7 @@ static void snd_record_send(void* data)
     }
 }
 
-static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_id,
+static SndChannelClient *__new_channel(SndWorker *worker, int size, uint32_t channel_id,
                                  RedClient *client,
                                  RedsStream *stream,
                                  int migrate,
@@ -884,7 +884,7 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
                                  uint32_t *common_caps, int num_common_caps,
                                  uint32_t *caps, int num_caps)
 {
-    SndChannel *channel;
+    SndChannelClient *channel;
     int delay_val;
     int flags;
 #ifdef SO_PRIORITY
@@ -986,7 +986,7 @@ static void snd_disconnect_channel_client(RedChannelClient *rcc)
     }
 }
 
-static void snd_set_command(SndChannel *channel, uint32_t command)
+static void snd_set_command(SndChannelClient *channel, uint32_t command)
 {
     if (!channel) {
         return;
@@ -999,7 +999,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_volume(SpicePlaybackInstance *
                                                   uint16_t *volume)
 {
     SpiceVolumeState *st = &sin->st->worker.volume;
-    SndChannel *channel = sin->st->worker.connection;
+    SndChannelClient *channel = sin->st->worker.connection;
     PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
 
     st->volume_nchannels = nchannels;
@@ -1015,7 +1015,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_volume(SpicePlaybackInstance *
 SPICE_GNUC_VISIBLE void spice_server_playback_set_mute(SpicePlaybackInstance *sin, uint8_t mute)
 {
     SpiceVolumeState *st = &sin->st->worker.volume;
-    SndChannel *channel = sin->st->worker.connection;
+    SndChannelClient *channel = sin->st->worker.connection;
     PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
 
     st->mute = mute;
@@ -1028,7 +1028,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_mute(SpicePlaybackInstance *si
 
 static void snd_playback_start(SndWorker *worker)
 {
-    SndChannel *channel = worker->connection;
+    SndChannelClient *channel = worker->connection;
 
     worker->active = 1;
     if (!channel)
@@ -1051,7 +1051,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_start(SpicePlaybackInstance *sin)
 
 SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
 {
-    SndChannel *channel = sin->st->worker.connection;
+    SndChannelClient *channel = sin->st->worker.connection;
     PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
 
     sin->st->worker.active = 0;
@@ -1079,7 +1079,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
 SPICE_GNUC_VISIBLE void spice_server_playback_get_buffer(SpicePlaybackInstance *sin,
                                                          uint32_t **frame, uint32_t *num_samples)
 {
-    SndChannel *channel = sin->st->worker.connection;
+    SndChannelClient *channel = sin->st->worker.connection;
     PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
 
     if (!channel || !playback_channel->free_frames) {
@@ -1159,7 +1159,7 @@ static int snd_desired_audio_mode(int playback_compression, int frequency,
     return SPICE_AUDIO_DATA_MODE_RAW;
 }
 
-static void on_new_playback_channel(SndWorker *worker, SndChannel *snd_channel)
+static void on_new_playback_channel(SndWorker *worker, SndChannelClient *snd_channel)
 {
     RedsState *reds = red_channel_get_server(worker->base_channel);
 
@@ -1178,7 +1178,7 @@ static void on_new_playback_channel(SndWorker *worker, SndChannel *snd_channel)
     }
 }
 
-static void snd_playback_cleanup(SndChannel *channel)
+static void snd_playback_cleanup(SndChannelClient *channel)
 {
     PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
 
@@ -1266,7 +1266,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_set_volume(SpiceRecordInstance *sin,
                                                 uint16_t *volume)
 {
     SpiceVolumeState *st = &sin->st->worker.volume;
-    SndChannel *channel = sin->st->worker.connection;
+    SndChannelClient *channel = sin->st->worker.connection;
     RecordChannel *record_channel = SPICE_CONTAINEROF(channel, RecordChannel, base);
 
     st->volume_nchannels = nchannels;
@@ -1282,7 +1282,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_set_volume(SpiceRecordInstance *sin,
 SPICE_GNUC_VISIBLE void spice_server_record_set_mute(SpiceRecordInstance *sin, uint8_t mute)
 {
     SpiceVolumeState *st = &sin->st->worker.volume;
-    SndChannel *channel = sin->st->worker.connection;
+    SndChannelClient *channel = sin->st->worker.connection;
     RecordChannel *record_channel = SPICE_CONTAINEROF(channel, RecordChannel, base);
 
     st->mute = mute;
@@ -1295,7 +1295,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_set_mute(SpiceRecordInstance *sin, u
 
 static void snd_record_start(SndWorker *worker)
 {
-    SndChannel *channel = worker->connection;
+    SndChannelClient *channel = worker->connection;
     RecordChannel *record_channel = SPICE_CONTAINEROF(channel, RecordChannel, base);
 
     worker->active = 1;
@@ -1320,7 +1320,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_start(SpiceRecordInstance *sin)
 
 SPICE_GNUC_VISIBLE void spice_server_record_stop(SpiceRecordInstance *sin)
 {
-    SndChannel *channel = sin->st->worker.connection;
+    SndChannelClient *channel = sin->st->worker.connection;
     RecordChannel *record_channel = SPICE_CONTAINEROF(channel, RecordChannel, base);
 
     sin->st->worker.active = 0;
@@ -1339,7 +1339,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_stop(SpiceRecordInstance *sin)
 SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance *sin,
                                                             uint32_t *samples, uint32_t bufsize)
 {
-    SndChannel *channel = sin->st->worker.connection;
+    SndChannelClient *channel = sin->st->worker.connection;
     RecordChannel *record_channel = SPICE_CONTAINEROF(channel, RecordChannel, base);
     uint32_t read_pos;
     uint32_t now;
@@ -1374,7 +1374,7 @@ SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance 
     return len;
 }
 
-static uint32_t snd_get_best_rate(SndChannel *channel, uint32_t cap_opus)
+static uint32_t snd_get_best_rate(SndChannelClient *channel, uint32_t cap_opus)
 {
     int client_can_opus = TRUE;
     if (channel) {
@@ -1416,7 +1416,7 @@ SPICE_GNUC_VISIBLE void spice_server_set_record_rate(SpiceRecordInstance *sin, u
     snd_set_rate(&sin->st->worker, frequency, SPICE_RECORD_CAP_OPUS);
 }
 
-static void on_new_record_channel(SndWorker *worker, SndChannel *snd_channel)
+static void on_new_record_channel(SndWorker *worker, SndChannelClient *snd_channel)
 {
     spice_assert(snd_channel);
 
@@ -1429,7 +1429,7 @@ static void on_new_record_channel(SndWorker *worker, SndChannel *snd_channel)
     }
 }
 
-static void snd_record_cleanup(SndChannel *channel)
+static void snd_record_cleanup(SndChannelClient *channel)
 {
     RecordChannel *record_channel = SPICE_CONTAINEROF(channel, RecordChannel, base);
     snd_codec_destroy(&record_channel->codec);
-- 
git-series 0.9.1


More information about the Spice-devel mailing list