[polypaudio-commits] r635 - /trunk/src/polyp/stream.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Tue Mar 7 10:29:27 PST 2006


Author: ossman
Date: Tue Mar  7 19:29:27 2006
New Revision: 635

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=635&root=polypaudio&view=rev
Log:
The extra stream ref actually did some good. Re-add it, but with some more
symmetry, assertions and comments.

Modified:
    trunk/src/polyp/stream.c

Modified: trunk/src/polyp/stream.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/stream.c?rev=635&root=polypaudio&r1=634&r2=635&view=diff
==============================================================================
--- trunk/src/polyp/stream.c (original)
+++ trunk/src/polyp/stream.c Tue Mar  7 19:29:27 2006
@@ -103,6 +103,10 @@
 
     PA_LLIST_PREPEND(pa_stream, c->streams, s);
 
+    /* The context and stream will point at each other. We cannot ref count
+       both though since that will create a loop. */
+    pa_context_ref(s->context);
+
     return s;
 }
 
@@ -111,7 +115,11 @@
 }
 
 static void stream_free(pa_stream *s) {
-    assert(s);
+    assert(s && s->context && !s->channel_valid);
+
+    PA_LLIST_REMOVE(pa_stream, s->context->streams, s);
+
+    pa_context_unref(s->context);
 
     if (s->ipol_event) {
         assert(s->mainloop);
@@ -187,7 +195,10 @@
         if (s->channel_valid)
             pa_dynarray_put((s->direction == PA_STREAM_PLAYBACK) ? s->context->playback_streams : s->context->record_streams, s->channel, NULL);
 
-        PA_LLIST_REMOVE(pa_stream, s->context->streams, s);
+        s->channel = 0;
+        s->channel_valid = 0;
+
+        /* We keep a ref as long as we're connected */
         pa_stream_unref(s);
     }
 
@@ -357,6 +368,9 @@
 
     s->channel_valid = 1;
     pa_dynarray_put((s->direction == PA_STREAM_RECORD) ? s->context->record_streams : s->context->playback_streams, s->channel, s);
+
+    /* We add an extra ref as long as we're connected (i.e. in the dynarray) */
+    pa_stream_ref(s);
 
     if (s->interpolate) {
         struct timeval tv;




More information about the pulseaudio-commits mailing list