mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-10 13:29:58 -05:00
add new API call pa_cvolume_snprint_dB()
This commit is contained in:
parent
be77bcd9ad
commit
619ed8a82d
4 changed files with 56 additions and 2 deletions
|
|
@ -141,7 +141,7 @@ double pa_sw_volume_to_linear(pa_volume_t v) {
|
|||
|
||||
char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
|
||||
unsigned channel;
|
||||
int first = 1;
|
||||
pa_bool_t first = TRUE;
|
||||
char *e;
|
||||
|
||||
pa_assert(s);
|
||||
|
|
@ -164,7 +164,38 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
|
|||
(c->values[channel]*100)/PA_VOLUME_NORM);
|
||||
|
||||
e = strchr(e, 0);
|
||||
first = 0;
|
||||
first = FALSE;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
char *pa_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c) {
|
||||
unsigned channel;
|
||||
pa_bool_t first = TRUE;
|
||||
char *e;
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
pa_assert(c);
|
||||
|
||||
pa_init_i18n();
|
||||
|
||||
if (!pa_cvolume_valid(c)) {
|
||||
pa_snprintf(s, l, _("(invalid)"));
|
||||
return s;
|
||||
}
|
||||
|
||||
*(e = s) = 0;
|
||||
|
||||
for (channel = 0; channel < c->channels && l > 1; channel++) {
|
||||
l -= pa_snprintf(e, l, "%s%u: %0.2f dB",
|
||||
first ? "" : " ",
|
||||
channel,
|
||||
pa_sw_volume_to_dB(c->values[channel]));
|
||||
|
||||
e = strchr(e, 0);
|
||||
first = FALSE;
|
||||
}
|
||||
|
||||
return s;
|
||||
|
|
|
|||
|
|
@ -136,6 +136,16 @@ pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v);
|
|||
/** Pretty print a volume structure */
|
||||
char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c);
|
||||
|
||||
/** Maximum length of the strings returned by
|
||||
* pa_cvolume_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.13 */
|
||||
#define PA_CVOLUME_SNPRINT_DB_MAX 448
|
||||
|
||||
/** Pretty print a volume structure but show dB values. \since 0.9.13 */
|
||||
char *pa_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c);
|
||||
|
||||
/** Return the average volume of all channels */
|
||||
pa_volume_t pa_cvolume_avg(const pa_cvolume *a) PA_GCC_PURE;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue