summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/protocol-native.c16
-rw-r--r--src/pulsecore/sink-input.c44
-rw-r--r--src/pulsecore/sink-input.h3
-rw-r--r--src/pulsecore/sink.c18
4 files changed, 78 insertions, 3 deletions
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index f3d240b3..adb995f0 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -1873,7 +1873,9 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
dont_inhibit_auto_suspend = FALSE,
muted_set = FALSE,
fail_on_suspend = FALSE,
- relative_volume = FALSE;
+ relative_volume = FALSE,
+ passthrough = FALSE;
+
pa_sink_input_flags_t flags = 0;
pa_proplist *p;
pa_bool_t volume_set = TRUE;
@@ -1975,6 +1977,15 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
}
}
+ if (c->version >= 18) {
+
+ if (pa_tagstruct_get_boolean(t, &passthrough) < 0 ) {
+ protocol_error(c);
+ pa_proplist_free(p);
+ return;
+ }
+ }
+
if (!pa_tagstruct_eof(t)) {
protocol_error(c);
pa_proplist_free(p);
@@ -2008,7 +2019,8 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
(no_move ? PA_SINK_INPUT_DONT_MOVE : 0) |
(variable_rate ? PA_SINK_INPUT_VARIABLE_RATE : 0) |
(dont_inhibit_auto_suspend ? PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND : 0) |
- (fail_on_suspend ? PA_SINK_INPUT_NO_CREATE_ON_SUSPEND|PA_SINK_INPUT_KILL_ON_SUSPEND : 0);
+ (fail_on_suspend ? PA_SINK_INPUT_NO_CREATE_ON_SUSPEND|PA_SINK_INPUT_KILL_ON_SUSPEND : 0) |
+ (passthrough ? PA_SINK_INPUT_PASSTHROUGH : 0);
/* Only since protocol version 15 there's a seperate muted_set
* flag. For older versions we synthesize it here */
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 395110b7..190e2d01 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -55,6 +55,39 @@ static void sink_input_volume_ramping(pa_sink_input* i, pa_memchunk* chunk);
static void sink_input_rewind_ramp_info(pa_sink_input *i, size_t nbytes);
static void sink_input_release_envelope(pa_sink_input *i);
+static int check_passthrough_connection(pa_sink_input_flags_t flags, pa_sink *dest) {
+
+ if (dest->flags & PA_SINK_PASSTHROUGH) {
+
+ if (pa_idxset_size(dest->inputs) > 0) {
+
+ pa_sink_input *alt_i;
+ uint32_t idx;
+
+ alt_i = pa_idxset_first(dest->inputs, &idx);
+
+ /* only need to check the first input is not PASSTHROUGH */
+ if (alt_i->flags & PA_SINK_INPUT_PASSTHROUGH) {
+ pa_log_warn("Sink is already connected to PASSTHROUGH input");
+ return -PA_ERR_BUSY;
+ }
+
+ /* Current inputs are PCM, check new input is not PASSTHROUGH */
+ if (flags & PA_SINK_INPUT_PASSTHROUGH) {
+ pa_log_warn("Sink is already connected, cannot accept new PASSTHROUGH INPUT");
+ return -PA_ERR_BUSY;
+ }
+ }
+
+ } else {
+ if (flags & PA_SINK_INPUT_PASSTHROUGH) {
+ pa_log_warn("Cannot connect PASSTHROUGH sink input to sink without PASSTHROUGH capabilities");
+ return -PA_ERR_INVALID;
+ }
+ }
+ return PA_OK;
+}
+
pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data) {
pa_assert(data);
@@ -183,6 +216,9 @@ int pa_sink_input_new(
pa_return_val_if_fail(PA_SINK_IS_LINKED(pa_sink_get_state(data->sink)), -PA_ERR_BADSTATE);
pa_return_val_if_fail(!data->sync_base || (data->sync_base->sink == data->sink && pa_sink_input_get_state(data->sync_base) == PA_SINK_INPUT_CORKED), -PA_ERR_INVALID);
+ r = check_passthrough_connection(data->flags, data->sink);
+ pa_return_val_if_fail(r == PA_OK, r);
+
if (!data->sample_spec_is_set)
data->sample_spec = data->sink->sample_spec;
@@ -1020,6 +1056,11 @@ static void set_real_ratio(pa_sink_input *i, const pa_cvolume *v) {
/* Called from main context */
void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, pa_bool_t save, pa_bool_t absolute) {
+
+ /* Do not allow for volume changes for non-audio types */
+ if (i->flags & PA_SINK_INPUT_PASSTHROUGH)
+ return;
+
/* test ramping -> return pa_sink_input_set_volume_with_ramping(i, volume, save, absolute, 2000 * PA_USEC_PER_MSEC); */
return pa_sink_input_set_volume_with_ramping(i, volume, save, absolute, 0);
}
@@ -1162,6 +1203,9 @@ pa_bool_t pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest) {
return FALSE;
}
+ if (check_passthrough_connection(i->flags, dest) < 0)
+ return FALSE;
+
if (i->may_move_to)
if (!i->may_move_to(i, dest))
return FALSE;
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index 56ac3d60..4491d8a3 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -61,7 +61,8 @@ typedef enum pa_sink_input_flags {
PA_SINK_INPUT_FIX_CHANNELS = 128,
PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND = 256,
PA_SINK_INPUT_NO_CREATE_ON_SUSPEND = 512,
- PA_SINK_INPUT_KILL_ON_SUSPEND = 1024
+ PA_SINK_INPUT_KILL_ON_SUSPEND = 1024,
+ PA_SINK_INPUT_PASSTHROUGH = 2048
} pa_sink_input_flags_t;
struct pa_sink_input {
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index d69f0388..b68ad3aa 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1393,6 +1393,24 @@ void pa_sink_set_volume(
pa_assert(volume || (s->flags & PA_SINK_FLAT_VOLUME));
pa_assert(!volume || volume->channels == 1 || pa_cvolume_compatible(volume, &s->sample_spec));
+ /* make sure we don't change the volume when a PASSTHROUGH input is connected */
+ if (s->flags & PA_SINK_PASSTHROUGH) {
+ pa_sink_input *alt_i;
+ uint32_t idx;
+
+ /* one and only one PASSTHROUGH input can possibly be connected */
+ if (pa_idxset_size(s->inputs) == 1) {
+
+ alt_i = pa_idxset_first(s->inputs, &idx);
+
+ if (alt_i->flags & PA_SINK_INPUT_PASSTHROUGH) {
+ /* FIXME: Need to notify client that volume control is disabled */
+ pa_log_warn("Cannot change volume, Sink is connected to PASSTHROUGH input");
+ return;
+ }
+ }
+ }
+
/* As a special exception we accept mono volumes on all sinks --
* even on those with more complex channel maps */