[Spice-devel] [PATCH v9 06/11] sound: Reuse code for snd_set_{playback, record}_peer
Jonathon Jongsma
jjongsma at redhat.com
Thu Dec 22 17:09:02 UTC 2016
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
On Tue, 2016-12-20 at 17:44 +0000, Frediano Ziglio wrote:
> Almost identical beside the type.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/sound.c | 53 +++++++++++++++---------------------------------
> ---
> 1 file changed, 16 insertions(+), 37 deletions(-)
>
> diff --git a/server/sound.c b/server/sound.c
> index 9263a23..74a4cc2 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -1086,9 +1086,9 @@ playback_channel_client_constructed(GObject
> *object)
> snd_send(SND_CHANNEL_CLIENT(playback_client));
> }
>
> -static void snd_set_playback_peer(RedChannel *red_channel, RedClient
> *client, RedsStream *stream,
> - int migration, int
> num_common_caps, uint32_t *common_caps,
> - int num_caps, uint32_t *caps)
> +static void snd_set_peer(RedChannel *red_channel, RedClient *client,
> RedsStream *stream,
> + int migration, int num_common_caps,
> uint32_t *common_caps,
> + int num_caps, uint32_t *caps, GType type)
> {
> SndChannel *channel = SND_CHANNEL(red_channel);
> GArray *common_caps_array = NULL, *caps_array = NULL;
> @@ -1108,7 +1108,7 @@ static void snd_set_playback_peer(RedChannel
> *red_channel, RedClient *client, Re
> g_array_append_vals(caps_array, caps, num_caps);
> }
>
> - g_initable_new(TYPE_PLAYBACK_CHANNEL_CLIENT,
> + g_initable_new(type,
> NULL, NULL,
> "channel", channel,
> "client", client,
> @@ -1125,6 +1125,15 @@ static void snd_set_playback_peer(RedChannel
> *red_channel, RedClient *client, Re
> }
> }
>
> +static void snd_set_playback_peer(RedChannel *red_channel, RedClient
> *client, RedsStream *stream,
> + int migration, int
> num_common_caps, uint32_t *common_caps,
> + int num_caps, uint32_t *caps)
> +{
> + snd_set_peer(red_channel, client, stream, migration,
> + num_common_caps, common_caps, num_caps, caps,
> + TYPE_PLAYBACK_CHANNEL_CLIENT);
> +}
> +
> static void snd_record_migrate_channel_client(RedChannelClient *rcc)
> {
> SndChannel *channel;
> @@ -1342,39 +1351,9 @@ static void snd_set_record_peer(RedChannel
> *red_channel, RedClient *client, Reds
> int migration, int num_common_caps,
> uint32_t *common_caps,
> int num_caps, uint32_t *caps)
> {
> - SndChannel *channel = SND_CHANNEL(red_channel);
> - GArray *common_caps_array = NULL, *caps_array = NULL;
> -
> - if (channel->connection) {
> - red_channel_client_disconnect(RED_CHANNEL_CLIENT(channel-
> >connection));
> - channel->connection = NULL;
> - }
> -
> - if (common_caps) {
> - common_caps_array = g_array_sized_new(FALSE, FALSE, sizeof
> (*common_caps),
> - num_common_caps);
> - g_array_append_vals(common_caps_array, common_caps,
> num_common_caps);
> - }
> - if (caps) {
> - caps_array = g_array_sized_new(FALSE, FALSE, sizeof (*caps),
> num_caps);
> - g_array_append_vals(caps_array, caps, num_caps);
> - }
> -
> - g_initable_new(TYPE_RECORD_CHANNEL_CLIENT,
> - NULL, NULL,
> - "channel", channel,
> - "client", client,
> - "stream", stream,
> - "caps", caps_array,
> - "common-caps", common_caps_array,
> - NULL);
> -
> - if (caps_array) {
> - g_array_unref(caps_array);
> - }
> - if (common_caps_array) {
> - g_array_unref(common_caps_array);
> - }
> + snd_set_peer(red_channel, client, stream, migration,
> + num_common_caps, common_caps, num_caps, caps,
> + TYPE_RECORD_CHANNEL_CLIENT);
> }
>
> static void snd_playback_migrate_channel_client(RedChannelClient
> *rcc)
More information about the Spice-devel
mailing list