]> code.delx.au - pulseaudio/commitdiff
sink: Remove PASSTHROUGH flag
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Tue, 1 Mar 2011 20:36:54 +0000 (02:06 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 2 May 2011 06:24:48 +0000 (11:54 +0530)
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
src/pulse/def.h
src/pulsecore/sink-input.c
src/pulsecore/sink.c
src/pulsecore/sink.h

index ccbc0628b1f03d244e161258e0f8a63ef7fa46f1..ec840afd26987bd4cf0addfe305317483172ff73 100644 (file)
@@ -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 {
index a3b862234e8e65d8c9f11617aae40689b895c145..91a027e3480f228fc0d59332fa91f10d13c4cbf7 100644 (file)
@@ -739,12 +739,7 @@ typedef enum pa_sink_flags {
     /**< The latency can be adjusted dynamically depending on the
      * needs of the connected streams. \since 0.9.15 */
 
-    PA_SINK_PASSTHROUGH = 0x0100U,
-    /**< This sink has support for passthrough mode. The data will be left
-     * as is and not reformatted, resampled, mixed.
-     * \since 1.0 */
-
-    PA_SINK_SYNC_VOLUME = 0x0200U,
+    PA_SINK_SYNC_VOLUME = 0x0100U,
     /**< The HW volume changes are syncronized with SW volume.
      * \since 1.0 */
 
@@ -753,7 +748,7 @@ typedef enum pa_sink_flags {
      * The server will filter out these flags anyway, so you should never see
      * these flags in sinks. */
 
-    PA_SINK_SHARE_VOLUME_WITH_MASTER = 0x0400U,
+    PA_SINK_SHARE_VOLUME_WITH_MASTER = 0x0200U,
     /**< This sink shares the volume with the master sink (used by some filter
      * sinks). */
 /** \endcond */
@@ -769,7 +764,6 @@ typedef enum pa_sink_flags {
 #define PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME
 #define PA_SINK_FLAT_VOLUME PA_SINK_FLAT_VOLUME
 #define PA_SINK_DYNAMIC_LATENCY PA_SINK_DYNAMIC_LATENCY
-#define PA_SINK_PASSTHROUGH PA_SINK_PASSTHROUGH
 #define PA_SINK_SYNC_VOLUME PA_SINK_SYNC_VOLUME
 #define PA_SINK_SHARE_VOLUME_WITH_MASTER PA_SINK_SHARE_VOLUME_WITH_MASTER
 
index 3df499e4097e66bd1063f4a9564efb9796b442ef..b05373f8bbd8e1aec2d048b801f210ed115e1017 100644 (file)
@@ -50,36 +50,19 @@ PA_DEFINE_PUBLIC_CLASS(pa_sink_input, pa_msgobject);
 static void sink_input_free(pa_object *o);
 static void set_real_ratio(pa_sink_input *i, const pa_cvolume *v);
 
-static int check_passthrough_connection(pa_sink_input_flags_t flags, pa_sink *dest) {
+static int check_passthrough_connection(pa_format_info *format, 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;
-            }
-        }
+    if (pa_sink_is_passthrough(dest)) {
+        pa_log_warn("Sink is already connected to 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;
-        }
+    /* If current input(s) exist, check new input is not PASSTHROUGH */
+    if (pa_idxset_size(dest->inputs) > 0 && !pa_format_info_is_pcm(format)) {
+        pa_log_warn("Sink is already connected, cannot accept new PASSTHROUGH INPUT");
+        return -PA_ERR_BUSY;
     }
+
     return PA_OK;
 }
 
@@ -313,7 +296,7 @@ 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);
+    r = check_passthrough_connection(data->format, data->sink);
     pa_return_val_if_fail(r == PA_OK, r);
 
     if (!data->sample_spec_is_set)
@@ -1355,7 +1338,7 @@ 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)
+    if (check_passthrough_connection(i->format, dest) < 0)
         return FALSE;
 
     if (i->may_move_to)
index 345d090c1dd43cf831e6ff3ec415eda5724b2d75..33923e1f2d7821d949c43f9654f38778670d8441 100644 (file)
@@ -1241,6 +1241,24 @@ pa_bool_t pa_sink_flat_volume_enabled(pa_sink *s) {
     return (s->flags & PA_SINK_FLAT_VOLUME);
 }
 
+/* Called from main context */
+pa_bool_t pa_sink_is_passthrough(pa_sink *s) {
+    pa_sink_input *alt_i;
+    uint32_t idx;
+
+    pa_sink_assert_ref(s);
+
+    /* 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 (!pa_format_info_is_pcm(alt_i->format))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
 /* Called from main context. */
 static void compute_reference_ratio(pa_sink_input *i) {
     unsigned c = 0;
@@ -1632,21 +1650,10 @@ void pa_sink_set_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;
-            }
-        }
+    if (pa_sink_is_passthrough(s)) {
+        /* FIXME: Need to notify client that volume control is disabled */
+        pa_log_warn("Cannot change volume, Sink is connected to PASSTHROUGH input");
+        return;
     }
 
     /* In case of volume sharing, the volume is set for the root sink first,
index a96dd90a69560cda93d897f1aa6cba4bb709cdaa..492abf68e6f9e228d78b46018d97c36426e369eb 100644 (file)
@@ -382,6 +382,10 @@ int pa_sink_suspend_all(pa_core *c, pa_bool_t suspend, pa_suspend_cause_t cause)
 /* Use this instead of checking s->flags & PA_SINK_FLAT_VOLUME directly. */
 pa_bool_t pa_sink_flat_volume_enabled(pa_sink *s);
 
+/* Is the sink in passthrough mode? (that is, is there a passthrough sink input
+ * connected to this sink? */
+pa_bool_t pa_sink_is_passthrough(pa_sink *s);
+
 void pa_sink_set_volume(pa_sink *sink, const pa_cvolume *volume, pa_bool_t sendmsg, pa_bool_t save);
 const pa_cvolume *pa_sink_get_volume(pa_sink *sink, pa_bool_t force_refresh);