summaryrefslogtreecommitdiffstats
path: root/src/pulse
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulse')
-rw-r--r--src/pulse/introspect.c10
-rw-r--r--src/pulse/introspect.h2
-rw-r--r--src/pulse/volume.c43
-rw-r--r--src/pulse/volume.h20
4 files changed, 70 insertions, 5 deletions
diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
index 38091581..8056a5a1 100644
--- a/src/pulse/introspect.c
+++ b/src/pulse/introspect.c
@@ -154,6 +154,7 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
memset(&i, 0, sizeof(i));
i.proplist = pa_proplist_new();
+ i.base_volume = PA_VOLUME_NORM;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -170,7 +171,9 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
pa_tagstruct_getu32(t, &flags) < 0 ||
(o->context->version >= 13 &&
(pa_tagstruct_get_proplist(t, i.proplist) < 0 ||
- pa_tagstruct_get_usec(t, &i.configured_latency) < 0))) {
+ pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) ||
+ (o->context->version >= 15 &&
+ pa_tagstruct_get_volume(t, &i.base_volume) < 0)) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
pa_proplist_free(i.proplist);
@@ -275,6 +278,7 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
memset(&i, 0, sizeof(i));
i.proplist = pa_proplist_new();
+ i.base_volume = PA_VOLUME_NORM;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -291,7 +295,9 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
pa_tagstruct_getu32(t, &flags) < 0 ||
(o->context->version >= 13 &&
(pa_tagstruct_get_proplist(t, i.proplist) < 0 ||
- pa_tagstruct_get_usec(t, &i.configured_latency) < 0))) {
+ pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) ||
+ (o->context->version >= 15 &&
+ pa_tagstruct_get_volume(t, &i.base_volume) < 0)) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
pa_proplist_free(i.proplist);
diff --git a/src/pulse/introspect.h b/src/pulse/introspect.h
index 087bd9f9..b409cadb 100644
--- a/src/pulse/introspect.h
+++ b/src/pulse/introspect.h
@@ -231,6 +231,7 @@ typedef struct pa_sink_info {
pa_sink_flags_t flags; /**< Flags */
pa_proplist *proplist; /**< Property list \since 0.9.11 */
pa_usec_t configured_latency; /**< The latency this device has been configured to. \since 0.9.11 */
+ pa_volume_t base_volume; /**< Some kind of "base" volume that refers to unamplified/unattenuated volume in the context of the output device. \since 0.9.14 */
} pa_sink_info;
/** Callback prototype for pa_context_get_sink_info_by_name() and friends */
@@ -286,6 +287,7 @@ typedef struct pa_source_info {
pa_source_flags_t flags; /**< Flags */
pa_proplist *proplist; /**< Property list \since 0.9.11 */
pa_usec_t configured_latency; /**< The latency this device has been configured to. \since 0.9.11 */
+ pa_volume_t base_volume; /**< Some kind of "base" volume that refers to unamplified/unattenuated volume in the context of the input device. \since 0.9.14 */
} pa_source_info;
/** Callback prototype for pa_context_get_source_info_by_name() and friends */
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index 99a85f44..ace5c4d6 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -179,6 +179,21 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
return s;
}
+char *pa_volume_snprint(char *s, size_t l, pa_volume_t v) {
+ pa_assert(s);
+ pa_assert(l > 0);
+
+ pa_init_i18n();
+
+ if (v == (pa_volume_t) -1) {
+ pa_snprintf(s, l, _("(invalid)"));
+ return s;
+ }
+
+ pa_snprintf(s, l, "%3u%%", (v*100)/PA_VOLUME_NORM);
+ return s;
+}
+
char *pa_sw_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c) {
unsigned channel;
pa_bool_t first = TRUE;
@@ -198,10 +213,12 @@ char *pa_sw_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c) {
*(e = s) = 0;
for (channel = 0; channel < c->channels && l > 1; channel++) {
+ double f = pa_sw_volume_to_dB(c->values[channel]);
+
l -= pa_snprintf(e, l, "%s%u: %0.2f dB",
- first ? "" : " ",
- channel,
- pa_sw_volume_to_dB(c->values[channel]));
+ first ? "" : " ",
+ channel,
+ isinf(f) < 0 || f <= -USER_DECIBEL_RANGE ? -INFINITY : f);
e = strchr(e, 0);
first = FALSE;
@@ -210,6 +227,26 @@ char *pa_sw_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c) {
return s;
}
+char *pa_sw_volume_snprint_dB(char *s, size_t l, pa_volume_t v) {
+ double f;
+
+ pa_assert(s);
+ pa_assert(l > 0);
+
+ pa_init_i18n();
+
+ if (v == (pa_volume_t) -1) {
+ pa_snprintf(s, l, _("(invalid)"));
+ return s;
+ }
+
+ f = pa_sw_volume_to_dB(v);
+ pa_snprintf(s, l, "%0.2f dB",
+ isinf(f) < 0 || f <= -USER_DECIBEL_RANGE ? -INFINITY : f);
+
+ return s;
+}
+
/** Return non-zero if the volume of all channels is equal to the specified value */
int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) {
unsigned c;
diff --git a/src/pulse/volume.h b/src/pulse/volume.h
index 75051af5..5815c906 100644
--- a/src/pulse/volume.h
+++ b/src/pulse/volume.h
@@ -150,6 +150,26 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c);
/** Pretty print a volume structure but show dB values. \since 0.9.13 */
char *pa_sw_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c);
+/** Maximum length of the strings returned by
+ * pa_volume_snprint(). Please note that this value can change with
+ * any release without warning and without being considered API or ABI
+ * breakage. You should not use this definition anywhere where it
+ * might become part of an ABI. \since 0.9.14 */
+#define PA_VOLUME_SNPRINT_MAX 10
+
+/** Pretty print a volume \since 0.9.14 */
+char *pa_volume_snprint(char *s, size_t l, pa_volume_t v);
+
+/** Maximum length of the strings returned by
+ * pa_volume_snprint_dB(). Please note that this value can change with
+ * any release without warning and without being considered API or ABI
+ * breakage. You should not use this definition anywhere where it
+ * might become part of an ABI. \since 0.9.14 */
+#define PA_SW_VOLUME_SNPRINT_DB_MAX 10
+
+/** Pretty print a volume but show dB values. \since 0.9.14 */
+char *pa_sw_volume_snprint_dB(char *s, size_t l, pa_volume_t v);
+
/** Return the average volume of all channels */
pa_volume_t pa_cvolume_avg(const pa_cvolume *a) PA_GCC_PURE;