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

Submitted by Frediano Ziglio on Dec. 2, 2016, 10:53 a.m.

Details

Message ID 9b455f13a5a5fa4161e32a8c2be20a371d3645e4.1480676032.git-series.fziglio@redhat.com
State Accepted
Commit f191fb4717156300a7fc5c02952c01b1fb2aef1a
Headers show
Series "Remove DummyChannel* objects" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Dec. 2, 2016, 10:53 a.m.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/sound.c | 37 ++++++++++++++++++-------------------
 1 file changed, 18 insertions(+), 19 deletions(-)

Patch hide | download patch | download mbox

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;
         }

Comments

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


On Fri, 2016-12-02 at 10:53 +0000, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio@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;
>          }