[pulseaudio-discuss] [PATCH 1/4] devices: Deprecate the HW_VOLUME/MUTE_CTRL and DECIBEL_VOLUME device flags.

Colin Guthrie colin at mageia.org
Sat Jul 2 10:27:11 PDT 2011


These flags server virtually no purpose other than for information
to the user and to aid debugging. Due to these flags existing, it
is not possible to change from HW volume control to software when
changing ports, yet much hardware requires this change. At present
when dealing with such hardware this typically leads to us not being
able to adjust the alsa mixer values regardless of which port is
selected as we use a lowest common denominator approach (as
implemented in path_set_unify())

This change does not really do much other than stop any internal
use of these flags and relax or drop a few asserts that used
them.
---
 src/modules/alsa/alsa-sink.c                    |   26 ++++++++++-------
 src/modules/alsa/alsa-source.c                  |   26 ++++++++++-------
 src/modules/bluetooth/module-bluetooth-device.c |    4 +-
 src/modules/dbus/iface-device.c                 |   24 ++++++----------
 src/modules/echo-cancel/module-echo-cancel.c    |    2 -
 src/modules/module-equalizer-sink.c             |    1 -
 src/modules/module-ladspa-sink.c                |    1 -
 src/modules/module-solaris.c                    |    4 +-
 src/modules/module-tunnel.c                     |    2 +-
 src/modules/oss/module-oss.c                    |    7 +++--
 src/modules/raop/module-raop-sink.c             |    2 +-
 src/pulse/def.h                                 |   14 ++++-----
 src/pulse/proplist.h                            |    9 ++++++
 src/pulsecore/cli-text.c                        |   34 +++++++++-------------
 src/pulsecore/sink.c                            |   20 +------------
 src/pulsecore/source.c                          |   20 +------------
 src/utils/pactl.c                               |   30 ++++++++------------
 17 files changed, 94 insertions(+), 132 deletions(-)

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 0164040..0ad8f12 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1759,9 +1759,15 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
             return 0;
     }
 
-    if (!u->mixer_path->has_volume)
+    pa_proplist_sets(u->sink->proplist, PA_PROP_DEVICE_HW_VOLUME, pa_yes_no(u->mixer_path->has_volume));
+    pa_proplist_sets(u->sink->proplist, PA_PROP_DEVICE_DECIBEL, pa_yes_no(u->mixer_path->has_volume && u->mixer_path->has_dB));
+    if (!u->mixer_path->has_volume) {
+        u->sink->get_volume = NULL;
+        u->sink->set_volume = NULL;
+        u->sink->write_volume = NULL;
+
         pa_log_info("Driver does not support hardware volume control, falling back to software volume control.");
-    else {
+    } else {
 
         if (u->mixer_path->has_dB) {
             pa_log_info("Hardware volume ranges from %0.2f dB to %0.2f dB.", u->mixer_path->min_dB, u->mixer_path->max_dB);
@@ -1781,28 +1787,26 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
         u->sink->set_volume = sink_set_volume_cb;
         u->sink->write_volume = sink_write_volume_cb;
 
-        u->sink->flags |= PA_SINK_HW_VOLUME_CTRL;
-        if (u->mixer_path->has_dB) {
-            u->sink->flags |= PA_SINK_DECIBEL_VOLUME;
-            if (sync_volume) {
-                u->sink->flags |= PA_SINK_SYNC_VOLUME;
-                pa_log_info("Successfully enabled synchronous volume.");
-            }
+        if (u->mixer_path->has_dB && sync_volume) {
+            u->sink->flags |= PA_SINK_SYNC_VOLUME;
+            pa_log_info("Successfully enabled synchronous volume.");
         }
 
         pa_log_info("Using hardware volume control. Hardware dB scale %s.", u->mixer_path->has_dB ? "supported" : "not supported");
     }
 
+    pa_proplist_sets(u->sink->proplist, PA_PROP_DEVICE_HW_MUTE, pa_yes_no(u->mixer_path->has_mute));
     if (!u->mixer_path->has_mute) {
+        u->sink->get_mute = NULL;
+        u->sink->set_mute = NULL;
         pa_log_info("Driver does not support hardware mute control, falling back to software mute control.");
     } else {
         u->sink->get_mute = sink_get_mute_cb;
         u->sink->set_mute = sink_set_mute_cb;
-        u->sink->flags |= PA_SINK_HW_MUTE_CTRL;
         pa_log_info("Using hardware mute control.");
     }
 
-    if (u->sink->flags & (PA_SINK_HW_VOLUME_CTRL|PA_SINK_HW_MUTE_CTRL)) {
+    if (u->mixer_path->has_volume || u->mixer_path->has_mute) {
         int (*mixer_callback)(snd_mixer_elem_t *, unsigned int);
         if (u->sink->flags & PA_SINK_SYNC_VOLUME) {
             u->mixer_pd = pa_alsa_mixer_pdata_new();
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index f847b1e..33ed330 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1534,9 +1534,15 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
             return 0;
     }
 
-    if (!u->mixer_path->has_volume)
+    pa_proplist_sets(u->source->proplist, PA_PROP_DEVICE_HW_VOLUME, pa_yes_no(u->mixer_path->has_volume));
+    pa_proplist_sets(u->source->proplist, PA_PROP_DEVICE_DECIBEL, pa_yes_no(u->mixer_path->has_volume && u->mixer_path->has_dB));
+    if (!u->mixer_path->has_volume) {
+        u->source->get_volume = NULL;
+        u->source->set_volume = NULL;
+        u->source->write_volume = NULL;
+
         pa_log_info("Driver does not support hardware volume control, falling back to software volume control.");
-    else {
+    } else {
 
         if (u->mixer_path->has_dB) {
             pa_log_info("Hardware volume ranges from %0.2f dB to %0.2f dB.", u->mixer_path->min_dB, u->mixer_path->max_dB);
@@ -1556,28 +1562,26 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
         u->source->set_volume = source_set_volume_cb;
         u->source->write_volume = source_write_volume_cb;
 
-        u->source->flags |= PA_SOURCE_HW_VOLUME_CTRL;
-        if (u->mixer_path->has_dB) {
-            u->source->flags |= PA_SOURCE_DECIBEL_VOLUME;
-            if (sync_volume) {
-                u->source->flags |= PA_SOURCE_SYNC_VOLUME;
-                pa_log_info("Successfully enabled synchronous volume.");
-            }
+        if (u->mixer_path->has_dB && sync_volume) {
+            u->source->flags |= PA_SOURCE_SYNC_VOLUME;
+            pa_log_info("Successfully enabled synchronous volume.");
         }
 
         pa_log_info("Using hardware volume control. Hardware dB scale %s.", u->mixer_path->has_dB ? "supported" : "not supported");
     }
 
+    pa_proplist_sets(u->source->proplist, PA_PROP_DEVICE_HW_MUTE, pa_yes_no(u->mixer_path->has_mute));
     if (!u->mixer_path->has_mute) {
+        u->source->get_mute = NULL;
+        u->source->set_mute = NULL;
         pa_log_info("Driver does not support hardware mute control, falling back to software mute control.");
     } else {
         u->source->get_mute = source_get_mute_cb;
         u->source->set_mute = source_set_mute_cb;
-        u->source->flags |= PA_SOURCE_HW_MUTE_CTRL;
         pa_log_info("Using hardware mute control.");
     }
 
-    if (u->source->flags & (PA_SOURCE_HW_VOLUME_CTRL|PA_SOURCE_HW_MUTE_CTRL)) {
+    if (u->mixer_path->has_volume || u->mixer_path->has_mute) {
         int (*mixer_callback)(snd_mixer_elem_t *, unsigned int);
         if (u->source->flags & PA_SOURCE_SYNC_VOLUME) {
             u->mixer_pd = pa_alsa_mixer_pdata_new();
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 288ad2f..448e252 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -2022,7 +2022,7 @@ static int add_sink(struct userdata *u) {
             return -1;
         }
 
-        u->sink = pa_sink_new(u->core, &data, PA_SINK_HARDWARE|PA_SINK_LATENCY | (u->profile == PROFILE_HSP ? PA_SINK_HW_VOLUME_CTRL : 0));
+        u->sink = pa_sink_new(u->core, &data, PA_SINK_HARDWARE|PA_SINK_LATENCY);
         pa_sink_new_data_done(&data);
 
         if (!u->sink) {
@@ -2084,7 +2084,7 @@ static int add_source(struct userdata *u) {
             return -1;
         }
 
-        u->source = pa_source_new(u->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY | (u->profile == PROFILE_HSP ? PA_SOURCE_HW_VOLUME_CTRL : 0));
+        u->source = pa_source_new(u->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY);
         pa_source_new_data_done(&data);
 
         if (!u->source) {
diff --git a/src/modules/dbus/iface-device.c b/src/modules/dbus/iface-device.c
index 652790f..2e99e99 100644
--- a/src/modules/dbus/iface-device.c
+++ b/src/modules/dbus/iface-device.c
@@ -473,9 +473,7 @@ static void handle_get_has_convertible_to_decibel_volume(DBusConnection *conn, D
     pa_assert(msg);
     pa_assert(d);
 
-    has_convertible_to_decibel_volume = (d->type == DEVICE_TYPE_SINK)
-                                        ? (d->sink->flags & PA_SINK_DECIBEL_VOLUME)
-                                        : (d->source->flags & PA_SOURCE_DECIBEL_VOLUME);
+    has_convertible_to_decibel_volume = FALSE;
 
     pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_BOOLEAN, &has_convertible_to_decibel_volume);
 }
@@ -543,9 +541,7 @@ static void handle_get_has_hardware_volume(DBusConnection *conn, DBusMessage *ms
     pa_assert(msg);
     pa_assert(d);
 
-    has_hardware_volume = (d->type == DEVICE_TYPE_SINK)
-                          ? (d->sink->flags & PA_SINK_HW_VOLUME_CTRL)
-                          : (d->source->flags & PA_SOURCE_HW_VOLUME_CTRL);
+    has_hardware_volume = FALSE;
 
     pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_BOOLEAN, &has_hardware_volume);
 }
@@ -558,9 +554,7 @@ static void handle_get_has_hardware_mute(DBusConnection *conn, DBusMessage *msg,
     pa_assert(msg);
     pa_assert(d);
 
-    has_hardware_mute = (d->type == DEVICE_TYPE_SINK)
-                        ? (d->sink->flags & PA_SINK_HW_MUTE_CTRL)
-                        : (d->source->flags & PA_SOURCE_HW_MUTE_CTRL);
+    has_hardware_mute = FALSE;
 
     pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_BOOLEAN, &has_hardware_mute);
 }
@@ -828,11 +822,11 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
         sample_rate = d->sink->sample_spec.rate;
         channel_map = &d->sink->channel_map;
         has_flat_volume = d->sink->flags & PA_SINK_FLAT_VOLUME;
-        has_convertible_to_decibel_volume = d->sink->flags & PA_SINK_DECIBEL_VOLUME;
+        has_convertible_to_decibel_volume = FALSE;
         base_volume = d->sink->base_volume;
         volume_steps = d->sink->n_volume_steps;
-        has_hardware_volume = d->sink->flags & PA_SINK_HW_VOLUME_CTRL;
-        has_hardware_mute = d->sink->flags & PA_SINK_HW_MUTE_CTRL;
+        has_hardware_volume = FALSE;
+        has_hardware_mute = FALSE;
         configured_latency = pa_sink_get_requested_latency(d->sink);
         has_dynamic_latency = d->sink->flags & PA_SINK_DYNAMIC_LATENCY;
         latency = pa_sink_get_latency(d->sink);
@@ -849,11 +843,11 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
         sample_rate = d->source->sample_spec.rate;
         channel_map = &d->source->channel_map;
         has_flat_volume = FALSE;
-        has_convertible_to_decibel_volume = d->source->flags & PA_SOURCE_DECIBEL_VOLUME;
+        has_convertible_to_decibel_volume = FALSE;
         base_volume = d->source->base_volume;
         volume_steps = d->source->n_volume_steps;
-        has_hardware_volume = d->source->flags & PA_SOURCE_HW_VOLUME_CTRL;
-        has_hardware_mute = d->source->flags & PA_SOURCE_HW_MUTE_CTRL;
+        has_hardware_volume = FALSE;
+        has_hardware_mute = FALSE;
         configured_latency = pa_source_get_requested_latency(d->source);
         has_dynamic_latency = d->source->flags & PA_SOURCE_DYNAMIC_LATENCY;
         latency = pa_source_get_latency(d->source);
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index b84bf1d..c1935e9 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -1519,7 +1519,6 @@ int pa__init(pa_module*m) {
     }
 
     u->source = pa_source_new(m->core, &source_data,
-                          PA_SOURCE_HW_MUTE_CTRL|PA_SOURCE_HW_VOLUME_CTRL|PA_SOURCE_DECIBEL_VOLUME|
                           (source_master->flags & (PA_SOURCE_LATENCY|PA_SOURCE_DYNAMIC_LATENCY)));
     pa_source_new_data_done(&source_data);
 
@@ -1567,7 +1566,6 @@ int pa__init(pa_module*m) {
     }
 
     u->sink = pa_sink_new(m->core, &sink_data,
-                          PA_SINK_HW_MUTE_CTRL|PA_SINK_HW_VOLUME_CTRL|PA_SINK_DECIBEL_VOLUME|
                           (sink_master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)));
     pa_sink_new_data_done(&sink_data);
 
diff --git a/src/modules/module-equalizer-sink.c b/src/modules/module-equalizer-sink.c
index e7d8790..917c6e9 100644
--- a/src/modules/module-equalizer-sink.c
+++ b/src/modules/module-equalizer-sink.c
@@ -1178,7 +1178,6 @@ int pa__init(pa_module*m) {
     }
 
     u->sink = pa_sink_new(m->core, &sink_data,
-                          PA_SINK_HW_MUTE_CTRL|PA_SINK_HW_VOLUME_CTRL|PA_SINK_DECIBEL_VOLUME|
                           (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)));
     pa_sink_new_data_done(&sink_data);
 
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 9cce269..c5458cd 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -883,7 +883,6 @@ int pa__init(pa_module*m) {
     }
 
     u->sink = pa_sink_new(m->core, &sink_data,
-                          PA_SINK_HW_MUTE_CTRL|PA_SINK_HW_VOLUME_CTRL|PA_SINK_DECIBEL_VOLUME|
                           (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)));
     pa_sink_new_data_done(&sink_data);
 
diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index 0e4e401..89ebdee 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -933,7 +933,7 @@ int pa__init(pa_module *m) {
             goto fail;
         }
 
-        u->source = pa_source_new(m->core, &source_new_data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY|PA_SOURCE_HW_VOLUME_CTRL);
+        u->source = pa_source_new(m->core, &source_new_data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY);
         pa_source_new_data_done(&source_new_data);
         pa_xfree(name_buf);
 
@@ -981,7 +981,7 @@ int pa__init(pa_module *m) {
             goto fail;
         }
 
-        u->sink = pa_sink_new(m->core, &sink_new_data, PA_SINK_HARDWARE|PA_SINK_LATENCY|PA_SINK_HW_VOLUME_CTRL|PA_SINK_HW_MUTE_CTRL);
+        u->sink = pa_sink_new(m->core, &sink_new_data, PA_SINK_HARDWARE|PA_SINK_LATENCY);
         pa_sink_new_data_done(&sink_new_data);
 
         pa_assert(u->sink);
diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index 4b1ae7d..aa7ad13 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -2003,7 +2003,7 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    u->sink = pa_sink_new(m->core, &data, PA_SINK_NETWORK|PA_SINK_LATENCY|PA_SINK_HW_VOLUME_CTRL|PA_SINK_HW_MUTE_CTRL);
+    u->sink = pa_sink_new(m->core, &data, PA_SINK_NETWORK|PA_SINK_LATENCY);
     pa_sink_new_data_done(&data);
 
     if (!u->sink) {
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 2a99d11..33510dd 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -1416,13 +1416,14 @@ int pa__init(pa_module*m) {
     if ((u->mixer_fd = pa_oss_open_mixer_for_device(u->device_name)) >= 0) {
         pa_bool_t do_close = TRUE;
 
+        pa_proplist_sets(u->sink->proplist, PA_PROP_DEVICE_HW_VOLUME, pa_yes_no(FALSE));
+        pa_proplist_sets(u->source->proplist, PA_PROP_DEVICE_HW_VOLUME, pa_yes_no(FALSE));
         if (ioctl(fd, SOUND_MIXER_READ_DEVMASK, &u->mixer_devmask) < 0)
             pa_log_warn("SOUND_MIXER_READ_DEVMASK failed: %s", pa_cstrerror(errno));
-
         else {
             if (u->sink && (u->mixer_devmask & (SOUND_MASK_VOLUME|SOUND_MASK_PCM))) {
                 pa_log_debug("Found hardware mixer track for playback.");
-                u->sink->flags |= PA_SINK_HW_VOLUME_CTRL;
+                pa_proplist_sets(u->sink->proplist, PA_PROP_DEVICE_HW_VOLUME, pa_yes_no(TRUE));
                 u->sink->get_volume = sink_get_volume;
                 u->sink->set_volume = sink_set_volume;
                 u->sink->n_volume_steps = 101;
@@ -1431,7 +1432,7 @@ int pa__init(pa_module*m) {
 
             if (u->source && (u->mixer_devmask & (SOUND_MASK_RECLEV|SOUND_MASK_IGAIN))) {
                 pa_log_debug("Found hardware mixer track for recording.");
-                u->source->flags |= PA_SOURCE_HW_VOLUME_CTRL;
+                pa_proplist_sets(u->source->proplist, PA_PROP_DEVICE_HW_VOLUME, pa_yes_no(TRUE));
                 u->source->get_volume = source_get_volume;
                 u->source->set_volume = source_set_volume;
                 u->source->n_volume_steps = 101;
diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c
index 87e7bc1..b62d8fc 100644
--- a/src/modules/raop/module-raop-sink.c
+++ b/src/modules/raop/module-raop-sink.c
@@ -596,7 +596,7 @@ int pa__init(pa_module*m) {
     u->sink->userdata = u;
     u->sink->set_volume = sink_set_volume_cb;
     u->sink->set_mute = sink_set_mute_cb;
-    u->sink->flags = PA_SINK_LATENCY|PA_SINK_NETWORK|PA_SINK_HW_VOLUME_CTRL;
+    u->sink->flags = PA_SINK_LATENCY|PA_SINK_NETWORK;
 
     pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
     pa_sink_set_rtpoll(u->sink, u->rtpoll);
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 16b2e59..6dbaf75 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -712,7 +712,7 @@ typedef enum pa_sink_flags {
     /**< Flag to pass when no specific options are needed (used to avoid casting)  \since 0.9.19 */
 
     PA_SINK_HW_VOLUME_CTRL = 0x0001U,
-    /**< Supports hardware volume control */
+    /**< \deprecated \since 1.0 */
 
     PA_SINK_LATENCY = 0x0002U,
     /**< Supports latency querying */
@@ -725,11 +725,10 @@ typedef enum pa_sink_flags {
     /**< Is a networked sink of some kind. \since 0.9.7 */
 
     PA_SINK_HW_MUTE_CTRL = 0x0010U,
-    /**< Supports hardware mute control \since 0.9.11 */
+    /**< \deprecated \since 1.0 */
 
     PA_SINK_DECIBEL_VOLUME = 0x0020U,
-    /**< Volume can be translated to dB with pa_sw_volume_to_dB()
-     * \since 0.9.11 */
+    /**< \deprecated \since 1.0 */
 
     PA_SINK_FLAT_VOLUME = 0x0040U,
     /**< This sink is in flat volume mode, i.e. always the maximum of
@@ -820,7 +819,7 @@ typedef enum pa_source_flags {
     /**< Flag to pass when no specific options are needed (used to avoid casting)  \since 0.9.19 */
 
     PA_SOURCE_HW_VOLUME_CTRL = 0x0001U,
-    /**< Supports hardware volume control */
+    /**< \deprecated \since 1.0 */
 
     PA_SOURCE_LATENCY = 0x0002U,
     /**< Supports latency querying */
@@ -833,11 +832,10 @@ typedef enum pa_source_flags {
     /**< Is a networked source of some kind. \since 0.9.7 */
 
     PA_SOURCE_HW_MUTE_CTRL = 0x0010U,
-    /**< Supports hardware mute control \since 0.9.11 */
+    /**< \deprecated \since 1.0 */
 
     PA_SOURCE_DECIBEL_VOLUME = 0x0020U,
-    /**< Volume can be translated to dB with pa_sw_volume_to_dB()
-     * \since 0.9.11 */
+    /**< \deprecated \since 1.0 */
 
     PA_SOURCE_DYNAMIC_LATENCY = 0x0040U,
     /**< The latency can be adjusted dynamically depending on the
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index a641f24..05b1205 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -242,6 +242,15 @@ PA_C_DECL_BEGIN
 /** For devices: human readable one-line description of the profile this device is in. e.g. "Analog Stereo", ... */
 #define PA_PROP_DEVICE_PROFILE_DESCRIPTION     "device.profile.description"
 
+/** For devices: does the device support hardware volume controls (for information only) \since 1.0 */
+#define PA_PROP_DEVICE_HW_VOLUME               "device.hardware_volume"
+
+/** For devices: does the device support hardware mute controls (for information only) \since 1.0 */
+#define PA_PROP_DEVICE_HW_MUTE                 "device.hardware_mute"
+
+/** For devices: does the device support decibel volumes (for information only) \since 1.0 */
+#define PA_PROP_DEVICE_DECIBEL                 "device.decibel"
+
 /** For modules: the author's name, formatted as UTF-8 string. e.g. "Lennart Poettering" */
 #define PA_PROP_MODULE_AUTHOR                  "module.author"
 
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index 5498744..f10d597 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -226,13 +226,15 @@ char *pa_sink_list_to_string(pa_core *c) {
             "  %c index: %u\n"
             "\tname: <%s>\n"
             "\tdriver: <%s>\n"
-            "\tflags: %s%s%s%s%s%s%s%s\n"
+            "\tflags: %s%s%s%s%s\n"
             "\tstate: %s\n"
             "\tsuspend cause: %s%s%s%s\n"
             "\tpriority: %u\n"
-            "\tvolume: %s%s%s\n"
+            "\tvolume: %s\n"
+            "\t        %s\n"
             "\t        balance %0.2f\n"
-            "\tbase volume: %s%s%s\n"
+            "\tbase volume: %s\n"
+            "\t             %s\n"
             "\tvolume steps: %u\n"
             "\tmuted: %s\n"
             "\tcurrent latency: %0.2f ms\n"
@@ -249,9 +251,6 @@ char *pa_sink_list_to_string(pa_core *c) {
             sink->driver,
             sink->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
             sink->flags & PA_SINK_NETWORK ? "NETWORK " : "",
-            sink->flags & PA_SINK_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
-            sink->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
-            sink->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
             sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
             sink->flags & PA_SINK_FLAT_VOLUME ? "FLAT_VOLUME " : "",
             sink->flags & PA_SINK_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
@@ -262,12 +261,10 @@ char *pa_sink_list_to_string(pa_core *c) {
             sink->suspend_cause & PA_SUSPEND_SESSION ? "SESSION" : "",
             sink->priority,
             pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, FALSE)),
-            sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t        " : "",
-            sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, FALSE)) : "",
+            pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, FALSE)),
             pa_cvolume_get_balance(pa_sink_get_volume(sink, FALSE), &sink->channel_map),
             pa_volume_snprint(v, sizeof(v), sink->base_volume),
-            sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t             " : "",
-            sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), sink->base_volume) : "",
+            pa_sw_volume_snprint_dB(vdb, sizeof(vdb), sink->base_volume),
             sink->n_volume_steps,
             pa_yes_no(pa_sink_get_mute(sink, FALSE)),
             (double) pa_sink_get_latency(sink) / (double) PA_USEC_PER_MSEC,
@@ -352,13 +349,15 @@ char *pa_source_list_to_string(pa_core *c) {
             "  %c index: %u\n"
             "\tname: <%s>\n"
             "\tdriver: <%s>\n"
-            "\tflags: %s%s%s%s%s%s%s\n"
+            "\tflags: %s%s%s%s\n"
             "\tstate: %s\n"
             "\tsuspend cause: %s%s%s%s\n"
             "\tpriority: %u\n"
-            "\tvolume: %s%s%s\n"
+            "\tvolume: %s\n"
+            "\t        %s\n"
             "\t        balance %0.2f\n"
-            "\tbase volume: %s%s%s\n"
+            "\tbase volume: %s\n"
+            "\t             %s\n"
             "\tvolume steps: %u\n"
             "\tmuted: %s\n"
             "\tcurrent latency: %0.2f ms\n"
@@ -373,9 +372,6 @@ char *pa_source_list_to_string(pa_core *c) {
             source->driver,
             source->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
             source->flags & PA_SOURCE_NETWORK ? "NETWORK " : "",
-            source->flags & PA_SOURCE_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
-            source->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
-            source->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
             source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
             source->flags & PA_SOURCE_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
             source_state_to_string(pa_source_get_state(source)),
@@ -385,12 +381,10 @@ char *pa_source_list_to_string(pa_core *c) {
             source->suspend_cause & PA_SUSPEND_SESSION ? "SESSION" : "",
             source->priority,
             pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, FALSE)),
-            source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t        " : "",
-            source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, FALSE)) : "",
+            pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, FALSE)),
             pa_cvolume_get_balance(pa_source_get_volume(source, FALSE), &source->channel_map),
             pa_volume_snprint(v, sizeof(v), source->base_volume),
-            source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t             " : "",
-            source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), source->base_volume) : "",
+            pa_sw_volume_snprint_dB(vdb, sizeof(vdb), source->base_volume),
             source->n_volume_steps,
             pa_yes_no(pa_source_get_mute(source, FALSE)),
             (double) pa_source_get_latency(source) / PA_USEC_PER_MSEC,
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 45761a6..bbd012b 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -465,17 +465,7 @@ void pa_sink_put(pa_sink* s) {
      * special exception we allow volume related flags to be set
      * between _new() and _put(). */
 
-    /* XXX: Currently decibel volume is disabled for all sinks that use volume
-     * sharing. When the master sink supports decibel volume, it would be good
-     * to have the flag also in the filter sink, but currently we don't do that
-     * so that the flags of the filter sink never change when it's moved from
-     * a master sink to another. One solution for this problem would be to
-     * remove user-visible volume altogether from filter sinks when volume
-     * sharing is used, but the current approach was easier to implement... */
-    if (!(s->flags & PA_SINK_HW_VOLUME_CTRL) && !(s->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER))
-        s->flags |= PA_SINK_DECIBEL_VOLUME;
-
-    if ((s->flags & PA_SINK_DECIBEL_VOLUME) && s->core->flat_volumes)
+    if (s->core->flat_volumes)
         s->flags |= PA_SINK_FLAT_VOLUME;
 
     if (s->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER) {
@@ -499,17 +489,11 @@ void pa_sink_put(pa_sink* s) {
     s->thread_info.soft_muted = s->muted;
     pa_sw_cvolume_multiply(&s->thread_info.current_hw_volume, &s->soft_volume, &s->real_volume);
 
-    pa_assert((s->flags & PA_SINK_HW_VOLUME_CTRL)
-              || (s->base_volume == PA_VOLUME_NORM
-                  && ((s->flags & PA_SINK_DECIBEL_VOLUME || (s->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER)))));
-    pa_assert(!(s->flags & PA_SINK_DECIBEL_VOLUME) || s->n_volume_steps == PA_VOLUME_NORM+1);
     pa_assert(!(s->flags & PA_SINK_DYNAMIC_LATENCY) == (s->thread_info.fixed_latency != 0));
     pa_assert(!(s->flags & PA_SINK_LATENCY) == !(s->monitor_source->flags & PA_SOURCE_LATENCY));
     pa_assert(!(s->flags & PA_SINK_DYNAMIC_LATENCY) == !(s->monitor_source->flags & PA_SOURCE_DYNAMIC_LATENCY));
-    pa_assert(!(s->flags & PA_SINK_HW_VOLUME_CTRL) || s->set_volume);
-    pa_assert(!(s->flags & PA_SINK_SYNC_VOLUME) || (s->flags & PA_SINK_HW_VOLUME_CTRL));
+    pa_assert(!(s->flags & PA_SINK_SYNC_VOLUME) || (s->set_volume && s->get_volume));
     pa_assert(!(s->flags & PA_SINK_SYNC_VOLUME) || s->write_volume);
-    pa_assert(!(s->flags & PA_SINK_HW_MUTE_CTRL) || s->set_mute);
 
     pa_assert(s->monitor_source->thread_info.fixed_latency == s->thread_info.fixed_latency);
     pa_assert(s->monitor_source->thread_info.min_latency == s->thread_info.min_latency);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 7024802..4150c48 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -397,17 +397,7 @@ void pa_source_put(pa_source *s) {
      * special exception we allow volume related flags to be set
      * between _new() and _put(). */
 
-    /* XXX: Currently decibel volume is disabled for all sources that use volume
-     * sharing. When the master source supports decibel volume, it would be good
-     * to have the flag also in the filter source, but currently we don't do that
-     * so that the flags of the filter source never change when it's moved from
-     * a master source to another. One solution for this problem would be to
-     * remove user-visible volume altogether from filter sources when volume
-     * sharing is used, but the current approach was easier to implement... */
-    if (!(s->flags & PA_SOURCE_HW_VOLUME_CTRL) && !(s->flags & PA_SOURCE_SHARE_VOLUME_WITH_MASTER))
-        s->flags |= PA_SOURCE_DECIBEL_VOLUME;
-
-    if ((s->flags & PA_SOURCE_DECIBEL_VOLUME) && s->core->flat_volumes)
+    if (s->core->flat_volumes)
         s->flags |= PA_SOURCE_FLAT_VOLUME;
 
     if (s->flags & PA_SOURCE_SHARE_VOLUME_WITH_MASTER) {
@@ -431,15 +421,9 @@ void pa_source_put(pa_source *s) {
     s->thread_info.soft_muted = s->muted;
     pa_sw_cvolume_multiply(&s->thread_info.current_hw_volume, &s->soft_volume, &s->real_volume);
 
-    pa_assert((s->flags & PA_SOURCE_HW_VOLUME_CTRL)
-              || (s->base_volume == PA_VOLUME_NORM
-                  && ((s->flags & PA_SOURCE_DECIBEL_VOLUME || (s->flags & PA_SOURCE_SHARE_VOLUME_WITH_MASTER)))));
-    pa_assert(!(s->flags & PA_SOURCE_DECIBEL_VOLUME) || s->n_volume_steps == PA_VOLUME_NORM+1);
     pa_assert(!(s->flags & PA_SOURCE_DYNAMIC_LATENCY) == (s->thread_info.fixed_latency != 0));
-    pa_assert(!(s->flags & PA_SOURCE_HW_VOLUME_CTRL) || s->set_volume);
-    pa_assert(!(s->flags & PA_SOURCE_SYNC_VOLUME) || (s->flags & PA_SOURCE_HW_VOLUME_CTRL));
+    pa_assert(!(s->flags & PA_SOURCE_SYNC_VOLUME) || (s->set_volume && s->get_volume));
     pa_assert(!(s->flags & PA_SOURCE_SYNC_VOLUME) || s->write_volume);
-    pa_assert(!(s->flags & PA_SOURCE_HW_MUTE_CTRL) || s->set_mute);
 
     pa_assert_se(source_set_state(s, PA_SOURCE_IDLE) == 0);
 
diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index e6f9c17..fa8872b 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -262,9 +262,11 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
              "\tChannel Map: %s\n"
              "\tOwner Module: %u\n"
              "\tMute: %s\n"
-             "\tVolume: %s%s%s\n"
+             "\tVolume: %s\n"
+             "\t        %s\n"
              "\t        balance %0.2f\n"
-             "\tBase Volume: %s%s%s\n"
+             "\tBase Volume: %s\n"
+             "\t             %s\n"
              "\tMonitor Source: %s\n"
              "\tLatency: %0.0f usec, configured %0.0f usec\n"
              "\tFlags: %s%s%s%s%s%s\n"
@@ -279,19 +281,14 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
            i->owner_module,
            pa_yes_no(i->mute),
            pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
-           i->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t        " : "",
-           i->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume) : "",
+           pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume),
            pa_cvolume_get_balance(&i->volume, &i->channel_map),
            pa_volume_snprint(v, sizeof(v), i->base_volume),
-           i->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t             " : "",
-           i->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), i->base_volume) : "",
+           pa_sw_volume_snprint_dB(vdb, sizeof(vdb), i->base_volume),
            pa_strnull(i->monitor_source_name),
            (double) i->latency, (double) i->configured_latency,
            i->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
            i->flags & PA_SINK_NETWORK ? "NETWORK " : "",
-           i->flags & PA_SINK_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
-           i->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
-           i->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
            i->flags & PA_SINK_LATENCY ? "LATENCY " : "",
            pl = pa_proplist_to_string_sep(i->proplist, "\n\t\t"));
 
@@ -373,9 +370,11 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
              "\tChannel Map: %s\n"
              "\tOwner Module: %u\n"
              "\tMute: %s\n"
-             "\tVolume: %s%s%s\n"
+             "\tVolume: %s\n"
+             "\t        %s\n"
              "\t        balance %0.2f\n"
-             "\tBase Volume: %s%s%s\n"
+             "\tBase Volume: %s\n"
+             "\t             %s\n"
              "\tMonitor of Sink: %s\n"
              "\tLatency: %0.0f usec, configured %0.0f usec\n"
              "\tFlags: %s%s%s%s%s%s\n"
@@ -390,19 +389,14 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
            i->owner_module,
            pa_yes_no(i->mute),
            pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
-           i->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t        " : "",
-           i->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume) : "",
+           pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume),
            pa_cvolume_get_balance(&i->volume, &i->channel_map),
            pa_volume_snprint(v, sizeof(v), i->base_volume),
-           i->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t             " : "",
-           i->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), i->base_volume) : "",
+           pa_sw_volume_snprint_dB(vdb, sizeof(vdb), i->base_volume),
            i->monitor_of_sink_name ? i->monitor_of_sink_name : _("n/a"),
            (double) i->latency, (double) i->configured_latency,
            i->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
            i->flags & PA_SOURCE_NETWORK ? "NETWORK " : "",
-           i->flags & PA_SOURCE_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
-           i->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
-           i->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
            i->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
            pl = pa_proplist_to_string_sep(i->proplist, "\n\t\t"));
 
-- 
1.7.6



More information about the pulseaudio-discuss mailing list