[pulseaudio-discuss] [PATCH 2/2] allow-passthrough: Setup sink & formats if not set yet
Sjoerd Simons
sjoerd.simons at collabora.co.uk
Mon May 19 06:58:19 PDT 2014
If at the point the module gets notified about the new stream no format
& sink have yet been select, select the default ones such that it can be
determined if the stream will be using audio passthrough rather than a
PCM format.
---
src/modules/module-allow-passthrough.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/modules/module-allow-passthrough.c b/src/modules/module-allow-passthrough.c
index 310f5af..e7d78d9 100644
--- a/src/modules/module-allow-passthrough.c
+++ b/src/modules/module-allow-passthrough.c
@@ -177,6 +177,28 @@ static pa_hook_result_t new_normal_stream(struct userdata *u, pa_core *c, pa_sin
static pa_hook_result_t sink_input_new_cb(pa_core *core, pa_sink_input_new_data *new_data, struct userdata *u) {
pa_core_assert_ref(core);
+
+ /* This is a bit of a hack, to determine whether the input stream will use
+ * a passthrough stream, the sink should have been selected and a format
+ * renegotiated. This can either happen by an earlier module (e.g. one
+ * doing routing or other policies) and if not pulseaudio core will setup
+ * the defaults after all hooks for this event have been processed.
+ *
+ * Unfortunately if no other module decides on sink/format before this hook
+ * runs, pulse core doing it is too late, so if a sink and/or stream format
+ * haven't been setup & configured just yet do so now using the same code
+ * as pulsecore would use (default sink and higher priority negotiated
+ * format).
+ */
+ if (!new_data->sink) {
+ pa_sink *sink = pa_namereg_get(core, NULL, PA_NAMEREG_SINK);
+ pa_return_val_if_fail(sink, -PA_ERR_NOENTITY);
+ pa_sink_input_new_data_set_sink(new_data, sink, false);
+ }
+
+ if (!new_data->format && new_data->nego_formats && !pa_idxset_isempty(new_data->nego_formats))
+ new_data->format = pa_format_info_copy(pa_idxset_first(new_data->nego_formats, NULL));
+
if (stream_is_fake_passthrough (new_data->proplist) ||
pa_sink_input_new_data_is_passthrough(new_data))
return new_passthrough_stream(u, core, new_data);
--
2.0.0.rc2
More information about the pulseaudio-discuss
mailing list