[spice.git PATCH 2/2] server: Access the correct SndChannel for a given AudioFrame

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The client of _get_samples() holds a ref to the SndChannel, and we
should access that SndChannel when _put_samples() is called, not the one
that happens to currently be attached to the Interface.
---

(Apologies, both of these are meant for spice.git.)

 server/snd_worker.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/server/snd_worker.c b/server/snd_worker.c
index 13f8c4d..6034aec 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -122,10 +122,14 @@ struct SndChannel {
     snd_channel_cleanup_channel_proc cleanup;
 };
 
+struct PlaybackChannel;
+typedef struct PlaybackChannel PlaybackChannel;
+
 typedef struct AudioFrame AudioFrame;
 struct AudioFrame {
     uint32_t time;
     uint32_t samples[FRAME_SIZE];
+    PlaybackChannel *channel;
     AudioFrame *next;
 };
 
@@ -227,6 +231,7 @@ static void snd_disconnect_channel(SndChannel *channel)
 
 static void snd_playback_free_frame(PlaybackChannel *playback_channel, AudioFrame *frame)
 {
+    frame->channel = playback_channel;
     frame->next = playback_channel->free_frames;
     playback_channel->free_frames = frame;
 }
@@ -1067,14 +1072,16 @@ SPICE_GNUC_VISIBLE void spice_server_playback_get_buffer(SpicePlaybackInstance *
 
 SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance *sin, uint32_t *samples)
 {
-    SndChannel *channel = sin->st->worker.connection;
-    PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
+    PlaybackChannel *playback_channel;
     AudioFrame *frame;
 
-    if (!channel) {
+    if (!sin->st->worker.connection) {
         return;
     }
-    if (!snd_channel_put(channel)) {
+
+    frame = SPICE_CONTAINEROF(samples, AudioFrame, samples);
+    playback_channel = frame->channel;
+    if (!snd_channel_put(&playback_channel->base) || !playback_channel->base.worker->connection) {
         /* lost last reference, channel has been destroyed previously */
         return;
     }
@@ -1083,7 +1090,6 @@ SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance
     if (playback_channel->pending_frame) {
         snd_playback_free_frame(playback_channel, playback_channel->pending_frame);
     }
-    frame = SPICE_CONTAINEROF(samples, AudioFrame, samples);
     frame->time = reds_get_mm_time();
     red_dispatcher_set_mm_time(frame->time);
     playback_channel->pending_frame = frame;
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]