[pulseaudio-discuss] [PATCH 1/4] sink, source: Add a helper function to check whether this is a filter

arun at accosted.net arun at accosted.net
Tue Jun 9 00:08:43 PDT 2015


From: Arun Raghavan <git at arunraghavan.net>

---
 src/modules/module-filter-apply.c | 4 ++--
 src/pulsecore/sink.c              | 9 ++++++++-
 src/pulsecore/sink.h              | 2 ++
 src/pulsecore/source.c            | 9 ++++++++-
 src/pulsecore/source.h            | 2 ++
 5 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index 5a927a3..c3f83ce 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -356,7 +356,7 @@ static void find_filters_for_module(struct userdata *u, pa_module *m, const char
 
     PA_IDXSET_FOREACH(sink, u->core->sinks, idx) {
         if (sink->module == m) {
-            pa_assert(sink->input_to_master != NULL);
+            pa_assert(pa_sink_is_filter(sink));
 
             fltr = filter_new(name, sink->input_to_master->sink, NULL);
             fltr->module_index = m->index;
@@ -368,7 +368,7 @@ static void find_filters_for_module(struct userdata *u, pa_module *m, const char
 
     PA_IDXSET_FOREACH(source, u->core->sources, idx) {
         if (source->module == m && !source->monitor_of) {
-            pa_assert(source->output_from_master != NULL);
+            pa_assert(pa_source_is_filter(source));
 
             if (!fltr) {
                 fltr = filter_new(name, NULL, source->output_from_master->source);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 6cb4263..e3425ea 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -580,7 +580,7 @@ void pa_sink_put(pa_sink* s) {
     pa_assert_ctl_context();
 
     pa_assert(s->state == PA_SINK_INIT);
-    pa_assert(!(s->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER) || s->input_to_master);
+    pa_assert(!(s->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER) || pa_sink_is_filter(s));
 
     /* The following fields must be initialized properly when calling _put() */
     pa_assert(s->asyncmsgq);
@@ -1558,6 +1558,13 @@ pa_sink *pa_sink_get_master(pa_sink *s) {
 }
 
 /* Called from main context */
+bool pa_sink_is_filter(pa_sink *s) {
+    pa_sink_assert_ref(s);
+
+    return (s->input_to_master != NULL);
+}
+
+/* Called from main context */
 bool pa_sink_is_passthrough(pa_sink *s) {
     pa_sink_input *alt_i;
     uint32_t idx;
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index ed0f9ee..3ae8240 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -440,6 +440,8 @@ bool pa_sink_flat_volume_enabled(pa_sink *s);
 /* Get the master sink when sharing volumes */
 pa_sink *pa_sink_get_master(pa_sink *s);
 
+bool pa_sink_is_filter(pa_sink *s);
+
 /* Is the sink in passthrough mode? (that is, is there a passthrough sink input
  * connected to this sink? */
 bool pa_sink_is_passthrough(pa_sink *s);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 4be7306..2dd7a28 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -531,7 +531,7 @@ void pa_source_put(pa_source *s) {
     pa_assert_ctl_context();
 
     pa_assert(s->state == PA_SOURCE_INIT);
-    pa_assert(!(s->flags & PA_SOURCE_SHARE_VOLUME_WITH_MASTER) || s->output_from_master);
+    pa_assert(!(s->flags & PA_SOURCE_SHARE_VOLUME_WITH_MASTER) || pa_source_is_filter(s));
 
     /* The following fields must be initialized properly when calling _put() */
     pa_assert(s->asyncmsgq);
@@ -1173,6 +1173,13 @@ pa_source *pa_source_get_master(pa_source *s) {
 }
 
 /* Called from main context */
+bool pa_source_is_filter(pa_source *s) {
+    pa_source_assert_ref(s);
+
+    return (s->output_from_master != NULL);
+}
+
+/* Called from main context */
 bool pa_source_is_passthrough(pa_source *s) {
 
     pa_source_assert_ref(s);
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index e7fc3e2..9ee0783 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -371,6 +371,8 @@ bool pa_source_flat_volume_enabled(pa_source *s);
 /* Get the master source when sharing volumes */
 pa_source *pa_source_get_master(pa_source *s);
 
+bool pa_source_is_filter(pa_source *s);
+
 /* Is the source in passthrough mode? (that is, is this a monitor source for a sink
  * that has a passthrough sink input connected to it. */
 bool pa_source_is_passthrough(pa_source *s);
-- 
2.4.2



More information about the pulseaudio-discuss mailing list