[PATCH v2 04/21] source: Initialize pa_source.monitor_of already in pa_source_new()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The knowledge about whether the source is going to be a monitor source
is necessary already in pa_source_new(), because the monitor source
node will be created based on that information.
---
 src/pulsecore/sink.c   | 3 +--
 src/pulsecore/source.c | 8 +++++++-
 src/pulsecore/source.h | 2 ++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index f393d42..746ace1 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -350,6 +350,7 @@ pa_sink* pa_sink_new(
     source_data.driver = data->driver;
     source_data.module = data->module;
     source_data.card = data->card;
+    pa_source_new_data_set_monitor_of(&source_data, s);
 
     dn = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
     pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Monitor of %s", dn ? dn : s->name);
@@ -366,8 +367,6 @@ pa_sink* pa_sink_new(
         goto fail;
     }
 
-    s->monitor_source->monitor_of = s;
-
     pa_source_set_latency_range(s->monitor_source, s->thread_info.min_latency, s->thread_info.max_latency);
     pa_source_set_fixed_latency(s->monitor_source, s->thread_info.fixed_latency);
     pa_source_set_max_rewind(s->monitor_source, s->thread_info.max_rewind);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 09866ea..b252ed5 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -109,6 +109,12 @@ void pa_source_new_data_set_alternate_sample_rate(pa_source_new_data *data, cons
     data->alternate_sample_rate = alternate_sample_rate;
 }
 
+void pa_source_new_data_set_monitor_of(pa_source_new_data *data, pa_sink *monitor_of) {
+    pa_assert(data);
+
+    data->monitor_of = monitor_of;
+}
+
 void pa_source_new_data_set_volume(pa_source_new_data *data, const pa_cvolume *volume) {
     pa_assert(data);
 
@@ -250,7 +256,7 @@ pa_source* pa_source_new(
     }
 
     s->n_corked = 0;
-    s->monitor_of = NULL;
+    s->monitor_of = data->monitor_of;
     s->output_from_master = NULL;
 
     s->reference_volume = s->real_volume = data->volume;
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 99bdf83..d002835 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -275,6 +275,7 @@ typedef struct pa_source_new_data {
     const char *driver;
     pa_module *module;
     pa_card *card;
+    pa_sink *monitor_of;
 
     pa_hashmap *ports;
     char *active_port;
@@ -305,6 +306,7 @@ void pa_source_new_data_set_name(pa_source_new_data *data, const char *name);
 void pa_source_new_data_set_sample_spec(pa_source_new_data *data, const pa_sample_spec *spec);
 void pa_source_new_data_set_channel_map(pa_source_new_data *data, const pa_channel_map *map);
 void pa_source_new_data_set_alternate_sample_rate(pa_source_new_data *data, const uint32_t alternate_sample_rate);
+void pa_source_new_data_set_monitor_of(pa_source_new_data *data, pa_sink *monitor_of);
 void pa_source_new_data_set_volume(pa_source_new_data *data, const pa_cvolume *volume);
 void pa_source_new_data_set_muted(pa_source_new_data *data, bool mute);
 void pa_source_new_data_set_port(pa_source_new_data *data, const char *port);
-- 
1.8.3.1



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux