summaryrefslogtreecommitdiffstats
path: root/src/polyp
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2006-03-07 18:29:27 +0000
committerPierre Ossman <ossman@cendio.se>2006-03-07 18:29:27 +0000
commit528d15095dd27d401be5d138d144a9df8ba7803a (patch)
tree1b738052d9ad37272dbe15acbfd93168868d4816 /src/polyp
parentb67963cec233f9c4d8c431f560475735e813c7b7 (diff)
The extra stream ref actually did some good. Re-add it, but with some more
symmetry, assertions and comments. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@635 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polyp')
-rw-r--r--src/polyp/stream.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/polyp/stream.c b/src/polyp/stream.c
index 746ea9f9..f4436ff5 100644
--- a/src/polyp/stream.c
+++ b/src/polyp/stream.c
@@ -103,6 +103,10 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
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 hashmap_free_func(void *p, void *userdata) {
}
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 @@ void pa_stream_set_state(pa_stream *s, pa_stream_state_t st) {
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);
}
@@ -358,6 +369,9 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
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;
pa_operation_unref(pa_stream_get_latency_info(s, NULL, NULL));