[Spice-devel] [PATCH v4 01/17] sound: Use worker directly

Christophe Fergeau cfergeau at redhat.com
Thu Dec 1 15:59:45 UTC 2016


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Thu, Dec 01, 2016 at 11:24:23AM +0000, Frediano Ziglio wrote:
> SpicePlaybackState and SpiceRecordState have same structures
> changing only slightly the behaviour.
> Using SndWorker instead allows some minor simplification and
> more code reuse.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/sound.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/server/sound.c b/server/sound.c
> index 8eddd2b..beab473 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -179,8 +179,8 @@ typedef struct RecordChannel {
>  static SndWorker *workers;
>  
>  static void snd_receive(SndChannel *channel);
> -static void snd_playback_start(SpicePlaybackState *st);
> -static void snd_record_start(SpiceRecordState *st);
> +static void snd_playback_start(SndWorker *worker);
> +static void snd_record_start(SndWorker *worker);
>  
>  static SndChannel *snd_channel_ref(SndChannel *channel)
>  {
> @@ -1026,11 +1026,11 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_mute(SpicePlaybackInstance *si
>      snd_playback_send_mute(playback_channel);
>  }
>  
> -static void snd_playback_start(SpicePlaybackState *st)
> +static void snd_playback_start(SndWorker *worker)
>  {
> -    SndChannel *channel = st->worker.connection;
> +    SndChannel *channel = worker->connection;
>  
> -    st->worker.active = 1;
> +    worker->active = 1;
>      if (!channel)
>          return;
>      spice_assert(!channel->active);
> @@ -1046,7 +1046,7 @@ static void snd_playback_start(SpicePlaybackState *st)
>  
>  SPICE_GNUC_VISIBLE void spice_server_playback_start(SpicePlaybackInstance *sin)
>  {
> -    return snd_playback_start(sin->st);
> +    return snd_playback_start(&sin->st->worker);
>  }
>  
>  SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
> @@ -1195,7 +1195,6 @@ static void snd_set_playback_peer(RedChannel *channel, RedClient *client, RedsSt
>  {
>      SndWorker *worker = g_object_get_data(G_OBJECT(channel), "sound-worker");
>      PlaybackChannel *playback_channel;
> -    SpicePlaybackState *st = SPICE_CONTAINEROF(worker, SpicePlaybackState, worker);
>  
>      snd_disconnect_channel(worker->connection);
>  
> @@ -1240,7 +1239,7 @@ static void snd_set_playback_peer(RedChannel *channel, RedClient *client, RedsSt
>      }
>  
>      if (worker->active) {
> -        snd_playback_start(st);
> +        snd_playback_start(worker);
>      }
>      snd_playback_send(worker->connection);
>  }
> @@ -1294,12 +1293,12 @@ SPICE_GNUC_VISIBLE void spice_server_record_set_mute(SpiceRecordInstance *sin, u
>      snd_record_send_mute(record_channel);
>  }
>  
> -static void snd_record_start(SpiceRecordState *st)
> +static void snd_record_start(SndWorker *worker)
>  {
> -    SndChannel *channel = st->worker.connection;
> +    SndChannel *channel = worker->connection;
>      RecordChannel *record_channel = SPICE_CONTAINEROF(channel, RecordChannel, base);
>  
> -    st->worker.active = 1;
> +    worker->active = 1;
>      if (!channel)
>          return;
>      spice_assert(!channel->active);
> @@ -1316,7 +1315,7 @@ static void snd_record_start(SpiceRecordState *st)
>  
>  SPICE_GNUC_VISIBLE void spice_server_record_start(SpiceRecordInstance *sin)
>  {
> -    snd_record_start(sin->st);
> +    snd_record_start(&sin->st->worker);
>  }
>  
>  SPICE_GNUC_VISIBLE void spice_server_record_stop(SpiceRecordInstance *sin)
> @@ -1442,7 +1441,6 @@ static void snd_set_record_peer(RedChannel *channel, RedClient *client, RedsStre
>  {
>      SndWorker *worker = g_object_get_data(G_OBJECT(channel), "sound-worker");
>      RecordChannel *record_channel;
> -    SpiceRecordState *st = SPICE_CONTAINEROF(worker, SpiceRecordState, worker);
>  
>      snd_disconnect_channel(worker->connection);
>  
> @@ -1465,7 +1463,7 @@ static void snd_set_record_peer(RedChannel *channel, RedClient *client, RedsStre
>  
>      on_new_record_channel(worker, &record_channel->base);
>      if (worker->active) {
> -        snd_record_start(st);
> +        snd_record_start(worker);
>      }
>      snd_record_send(worker->connection);
>  }
> -- 
> git-series 0.9.1
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161201/90493e97/attachment.sig>


More information about the Spice-devel mailing list