[Spice-devel] [PATCH v6 06/18] sound: Reuse client variable if available

Jonathon Jongsma jjongsma at redhat.com
Fri Dec 2 21:33:51 UTC 2016


Acked-by: Jonathon Jongsma <jjongsma at redhat.com>


On Fri, 2016-12-02 at 10:53 +0000, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/sound.c | 37 ++++++++++++++++++-------------------
>  1 file changed, 18 insertions(+), 19 deletions(-)
> 
> diff --git a/server/sound.c b/server/sound.c
> index 59e2e4b..777cdbc 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -1169,15 +1169,15 @@ SPICE_GNUC_VISIBLE void
> spice_server_playback_stop(SpicePlaybackInstance *sin)
>      sin->st->channel.active = 0;
>      if (!client)
>          return;
> -    spice_assert(playback_client->base.active);
> +    spice_assert(client->active);
>      reds_enable_mm_time(snd_channel_get_server(client));
> -    playback_client->base.active = FALSE;
> -    if (playback_client->base.client_active) {
> -        snd_set_command(&playback_client->base, SND_CTRL_MASK);
> -        snd_playback_send(&playback_client->base);
> +    client->active = FALSE;
> +    if (client->client_active) {
> +        snd_set_command(client, SND_CTRL_MASK);
> +        snd_playback_send(client);
>      } else {
> -        playback_client->base.command &= ~SND_CTRL_MASK;
> -        playback_client->base.command &= ~SND_PLAYBACK_PCM_MASK;
> +        client->command &= ~SND_CTRL_MASK;
> +        client->command &= ~SND_PLAYBACK_PCM_MASK;
>  
>          if (playback_client->pending_frame) {
>              spice_assert(!playback_client->in_progress);
> @@ -1199,7 +1199,7 @@ SPICE_GNUC_VISIBLE void
> spice_server_playback_get_buffer(SpicePlaybackInstance *
>          *num_samples = 0;
>          return;
>      }
> -    spice_assert(playback_client->base.active);
> +    spice_assert(client->active);
>      if (!playback_client->free_frames->allocated) {
>          playback_client->free_frames->allocated = TRUE;
>          ++playback_client->frames->refs;
> @@ -1311,7 +1311,7 @@ static void
> snd_playback_cleanup(SndChannelClient *client)
>          free(playback_client->frames);
>      }
>  
> -    if (playback_client->base.active) {
> +    if (client->active) {
>          reds_enable_mm_time(snd_channel_get_server(client));
>      }
>  
> @@ -1447,18 +1447,17 @@ SPICE_GNUC_VISIBLE void
> spice_server_record_start(SpiceRecordInstance *sin)
>  SPICE_GNUC_VISIBLE void spice_server_record_stop(SpiceRecordInstance
> *sin)
>  {
>      SndChannelClient *client = sin->st->channel.connection;
> -    RecordChannelClient *record_client = SPICE_CONTAINEROF(client,
> RecordChannelClient, base);
>  
>      sin->st->channel.active = 0;
>      if (!client)
>          return;
> -    spice_assert(record_client->base.active);
> -    record_client->base.active = FALSE;
> -    if (record_client->base.client_active) {
> -        snd_set_command(&record_client->base, SND_CTRL_MASK);
> -        snd_record_send(&record_client->base);
> +    spice_assert(client->active);
> +    client->active = FALSE;
> +    if (client->client_active) {
> +        snd_set_command(client, SND_CTRL_MASK);
> +        snd_record_send(client);
>      } else {
> -        record_client->base.command &= ~SND_CTRL_MASK;
> +        client->command &= ~SND_CTRL_MASK;
>      }
>  }
>  
> @@ -1473,7 +1472,7 @@ SPICE_GNUC_VISIBLE uint32_t
> spice_server_record_get_samples(SpiceRecordInstance 
>  
>      if (!client)
>          return 0;
> -    spice_assert(record_client->base.active);
> +    spice_assert(client->active);
>  
>      if (record_client->write_pos < RECORD_SAMPLES_SIZE / 2) {
>          return 0;
> @@ -1482,8 +1481,8 @@ SPICE_GNUC_VISIBLE uint32_t
> spice_server_record_get_samples(SpiceRecordInstance 
>      len = MIN(record_client->write_pos - record_client->read_pos,
> bufsize);
>  
>      if (len < bufsize) {
> -        SndChannel *channel = record_client->base.channel;
> -        snd_receive(&record_client->base);
> +        SndChannel *channel = client->channel;
> +        snd_receive(client);
>          if (!channel->connection) {
>              return 0;
>          }


More information about the Spice-devel mailing list