sink,source: Add a helper function to check whether this is a filter

This commit is contained in:
Arun Raghavan 2015-06-09 12:06:48 +05:30
parent 5adb126259
commit 81f7589a3f
5 changed files with 22 additions and 4 deletions

View file

@ -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) { PA_IDXSET_FOREACH(sink, u->core->sinks, idx) {
if (sink->module == m) { 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 = filter_new(name, sink->input_to_master->sink, NULL);
fltr->module_index = m->index; 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) { PA_IDXSET_FOREACH(source, u->core->sources, idx) {
if (source->module == m && !source->monitor_of) { if (source->module == m && !source->monitor_of) {
pa_assert(source->output_from_master != NULL); pa_assert(pa_source_is_filter(source));
if (!fltr) { if (!fltr) {
fltr = filter_new(name, NULL, source->output_from_master->source); fltr = filter_new(name, NULL, source->output_from_master->source);

View file

@ -580,7 +580,7 @@ void pa_sink_put(pa_sink* s) {
pa_assert_ctl_context(); pa_assert_ctl_context();
pa_assert(s->state == PA_SINK_INIT); 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() */ /* The following fields must be initialized properly when calling _put() */
pa_assert(s->asyncmsgq); pa_assert(s->asyncmsgq);
@ -1557,6 +1557,13 @@ pa_sink *pa_sink_get_master(pa_sink *s) {
return s; return 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 */ /* Called from main context */
bool pa_sink_is_passthrough(pa_sink *s) { bool pa_sink_is_passthrough(pa_sink *s) {
pa_sink_input *alt_i; pa_sink_input *alt_i;

View file

@ -440,6 +440,8 @@ bool pa_sink_flat_volume_enabled(pa_sink *s);
/* Get the master sink when sharing volumes */ /* Get the master sink when sharing volumes */
pa_sink *pa_sink_get_master(pa_sink *s); 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 /* Is the sink in passthrough mode? (that is, is there a passthrough sink input
* connected to this sink? */ * connected to this sink? */
bool pa_sink_is_passthrough(pa_sink *s); bool pa_sink_is_passthrough(pa_sink *s);

View file

@ -531,7 +531,7 @@ void pa_source_put(pa_source *s) {
pa_assert_ctl_context(); pa_assert_ctl_context();
pa_assert(s->state == PA_SOURCE_INIT); 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() */ /* The following fields must be initialized properly when calling _put() */
pa_assert(s->asyncmsgq); pa_assert(s->asyncmsgq);
@ -1172,6 +1172,13 @@ pa_source *pa_source_get_master(pa_source *s) {
return s; return 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 */ /* Called from main context */
bool pa_source_is_passthrough(pa_source *s) { bool pa_source_is_passthrough(pa_source *s) {

View file

@ -371,6 +371,8 @@ bool pa_source_flat_volume_enabled(pa_source *s);
/* Get the master source when sharing volumes */ /* Get the master source when sharing volumes */
pa_source *pa_source_get_master(pa_source *s); 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 /* 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. */ * that has a passthrough sink input connected to it. */
bool pa_source_is_passthrough(pa_source *s); bool pa_source_is_passthrough(pa_source *s);