From 71ec9577cf052558cfddb051c7d038c91b397bc5 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Wed, 2 Mar 2011 02:06:54 +0530 Subject: sink: Remove PASSTHROUGH flag This removes the passthrough flag from sinks since we will drop exclusively passthrough sinks in favour of providing a list of formats supported by each sink. We can still determine whether a sink is in passthrough mode by checking if any non-PCM streams are attached to it. --- src/modules/alsa/alsa-sink.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/modules/alsa/alsa-sink.c') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index ccbc0628..ec840afd 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1707,13 +1707,6 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v return 0; } - /* FIXME: need automatic detection rather than hard-coded path */ - if (!strcmp(u->mixer_path->name, "iec958-passthrough-output")) { - u->sink->flags |= PA_SINK_PASSTHROUGH; - } else { - u->sink->flags &= ~PA_SINK_PASSTHROUGH; - } - if (!u->mixer_path->has_volume) pa_log_info("Driver does not support hardware volume control, falling back to software volume control."); else { -- cgit From 49b10ba6941ea61e551ccee482b12bb78db8a4b3 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Tue, 8 Mar 2011 14:22:24 +0530 Subject: alsa: Reconfigure sink sample rate for passthrough inputs When a passthrough sink-input is added, we need to reconfigure the sink's sample rate since no resampling occurs. We revert to the original rate when the passthrough sink-input is removed. --- src/modules/alsa/alsa-sink.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/modules/alsa/alsa-sink.c') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index ec840afd..3f8f6d20 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -108,6 +108,8 @@ struct userdata { pa_cvolume hardware_volume; + uint32_t old_rate; + size_t frame_size, fragment_size, @@ -1051,6 +1053,56 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse switch (code) { + case PA_SINK_MESSAGE_FINISH_MOVE: + case PA_SINK_MESSAGE_ADD_INPUT: { + pa_sink_input *i = PA_SINK_INPUT(data); + int r = 0; + + if (PA_LIKELY(pa_format_info_is_pcm(i->format))) + break; + + u->old_rate = u->sink->sample_spec.rate; + + /* Passthrough format, see if we need to reset sink sample rate */ + if (u->sink->sample_spec.rate == i->thread_info.sample_spec.rate) + break; + + /* .. we do */ + if ((r = suspend(u)) < 0) + return r; + + u->sink->sample_spec.rate = i->thread_info.sample_spec.rate; + + if ((r = unsuspend(u)) < 0) + return r; + + break; + } + + case PA_SINK_MESSAGE_START_MOVE: + case PA_SINK_MESSAGE_REMOVE_INPUT: { + pa_sink_input *i = PA_SINK_INPUT(data); + int r = 0; + + if (PA_LIKELY(pa_format_info_is_pcm(i->format))) + break; + + /* Passthrough format, see if we need to reset sink sample rate */ + if (u->sink->sample_spec.rate == u->old_rate) + break; + + /* .. we do */ + if ((r = suspend(u)) < 0) + return r; + + u->sink->sample_spec.rate = u->old_rate; + + if ((r = unsuspend(u)) < 0) + return r; + + break; + } + case PA_SINK_MESSAGE_GET_LATENCY: { pa_usec_t r = 0; -- cgit From 4fb68b91acef3cb37c014814d9e9de8ca9f22bf4 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Wed, 16 Mar 2011 16:08:23 +0530 Subject: core: Factor out passthrough checks into their own functions Since we currently have two mechanisms to signal a passthrough connection (non-PCM format or PA_SINK_INPUT_PASSTHROUGH flag), we move all the related checks into functions and use those everywhere. This makes things more consistent, and should we decide to get rid of the flag, we only need to change pa_sink_input_*_is_passthrough() accordingly. --- src/modules/alsa/alsa-sink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules/alsa/alsa-sink.c') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 3f8f6d20..b98340b7 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1058,7 +1058,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse pa_sink_input *i = PA_SINK_INPUT(data); int r = 0; - if (PA_LIKELY(pa_format_info_is_pcm(i->format))) + if (PA_LIKELY(!pa_sink_input_is_passthrough(i))) break; u->old_rate = u->sink->sample_spec.rate; @@ -1084,7 +1084,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse pa_sink_input *i = PA_SINK_INPUT(data); int r = 0; - if (PA_LIKELY(pa_format_info_is_pcm(i->format))) + if (PA_LIKELY(!pa_sink_input_is_passthrough(i))) break; /* Passthrough format, see if we need to reset sink sample rate */ -- cgit