[pulseaudio-discuss] [PATCH v0 01/16] sink, source: Fix missing pa_asyncmsgq_ref()
Mikel Astiz
mikel.astiz.oss at gmail.com
Fri Sep 28 08:45:25 PDT 2012
From: Mikel Astiz <mikel.astiz at bmw-carit.de>
Sinks and sources hold a pointer to asyncmsgq, so they should use the
reference counting mechanism to make sure this queue is not freed.
---
src/pulsecore/sink.c | 9 +++++++++
src/pulsecore/source.c | 9 +++++++++
2 files changed, 18 insertions(+)
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 9958be6..5d849f1 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -725,6 +725,9 @@ static void sink_free(pa_object *o) {
pa_log_info("Freeing sink %u \"%s\"", s->index, s->name);
+ if (s->asyncmsgq)
+ pa_asyncmsgq_unref(s->asyncmsgq);
+
if (s->monitor_source) {
pa_source_unref(s->monitor_source);
s->monitor_source = NULL;
@@ -757,8 +760,14 @@ void pa_sink_set_asyncmsgq(pa_sink *s, pa_asyncmsgq *q) {
pa_sink_assert_ref(s);
pa_assert_ctl_context();
+ if (s->asyncmsgq)
+ pa_asyncmsgq_unref(s->asyncmsgq);
+
s->asyncmsgq = q;
+ if (q)
+ pa_asyncmsgq_ref(q);
+
if (s->monitor_source)
pa_source_set_asyncmsgq(s->monitor_source, q);
}
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 7af86f5..2a356f0 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -660,6 +660,9 @@ static void source_free(pa_object *o) {
pa_log_info("Freeing source %u \"%s\"", s->index, s->name);
+ if (s->asyncmsgq)
+ pa_asyncmsgq_unref(s->asyncmsgq);
+
pa_idxset_free(s->outputs, NULL, NULL);
while ((so = pa_hashmap_steal_first(s->thread_info.outputs)))
@@ -687,7 +690,13 @@ void pa_source_set_asyncmsgq(pa_source *s, pa_asyncmsgq *q) {
pa_source_assert_ref(s);
pa_assert_ctl_context();
+ if (s->asyncmsgq)
+ pa_asyncmsgq_unref(s->asyncmsgq);
+
s->asyncmsgq = q;
+
+ if (q)
+ pa_asyncmsgq_ref(q);
}
/* Called from main context, and not while the IO thread is active, please */
--
1.7.11.4
More information about the pulseaudio-discuss
mailing list