mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 13:29:59 -05:00
Merge branch 'master' of git://0pointer.de/pulseaudio into dbus-work
This commit is contained in:
commit
292d6dcb5f
64 changed files with 6601 additions and 3909 deletions
|
|
@ -219,11 +219,11 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
|
|||
|
||||
case 6:
|
||||
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
|
||||
m->map[1] = PA_CHANNEL_POSITION_REAR_LEFT;
|
||||
m->map[1] = PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER;
|
||||
m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
|
||||
m->map[3] = PA_CHANNEL_POSITION_FRONT_RIGHT;
|
||||
m->map[4] = PA_CHANNEL_POSITION_REAR_RIGHT;
|
||||
m->map[5] = PA_CHANNEL_POSITION_LFE;
|
||||
m->map[4] = PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER;
|
||||
m->map[5] = PA_CHANNEL_POSITION_REAR_CENTER;
|
||||
return m;
|
||||
|
||||
case 5:
|
||||
|
|
@ -247,7 +247,7 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
|
|||
m->map[0] = PA_CHANNEL_POSITION_LEFT;
|
||||
m->map[1] = PA_CHANNEL_POSITION_CENTER;
|
||||
m->map[2] = PA_CHANNEL_POSITION_RIGHT;
|
||||
m->map[3] = PA_CHANNEL_POSITION_LFE;
|
||||
m->map[3] = PA_CHANNEL_POSITION_REAR_CENTER;
|
||||
return m;
|
||||
|
||||
default:
|
||||
|
|
@ -299,6 +299,8 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
|
|||
|
||||
case PA_CHANNEL_MAP_WAVEEX:
|
||||
|
||||
/* Following http://www.microsoft.com/whdc/device/audio/multichaud.mspx#EKLAC */
|
||||
|
||||
switch (channels) {
|
||||
case 1:
|
||||
m->map[0] = PA_CHANNEL_POSITION_MONO;
|
||||
|
|
@ -451,6 +453,10 @@ int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) {
|
|||
pa_assert(b);
|
||||
|
||||
pa_return_val_if_fail(pa_channel_map_valid(a), 0);
|
||||
|
||||
if (PA_UNLIKELY(a == b))
|
||||
return 1;
|
||||
|
||||
pa_return_val_if_fail(pa_channel_map_valid(b), 0);
|
||||
|
||||
if (a->channels != b->channels)
|
||||
|
|
@ -639,6 +645,10 @@ int pa_channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) {
|
|||
pa_assert(b);
|
||||
|
||||
pa_return_val_if_fail(pa_channel_map_valid(a), 0);
|
||||
|
||||
if (PA_UNLIKELY(a == b))
|
||||
return 1;
|
||||
|
||||
pa_return_val_if_fail(pa_channel_map_valid(b), 0);
|
||||
|
||||
am = pa_channel_map_mask(a);
|
||||
|
|
|
|||
|
|
@ -216,17 +216,27 @@ typedef enum pa_channel_map_def {
|
|||
PA_CHANNEL_MAP_AIFF,
|
||||
/**< The mapping from RFC3551, which is based on AIFF-C */
|
||||
|
||||
/** \cond fulldocs */
|
||||
PA_CHANNEL_MAP_ALSA,
|
||||
/**< The default mapping used by ALSA */
|
||||
/**< The default mapping used by ALSA. This mapping is probably
|
||||
* not too useful since ALSA's default channel mapping depends on
|
||||
* the device string used. */
|
||||
/** \endcond */
|
||||
|
||||
PA_CHANNEL_MAP_AUX,
|
||||
/**< Only aux channels */
|
||||
|
||||
PA_CHANNEL_MAP_WAVEEX,
|
||||
/**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
|
||||
/**< Microsoft's WAVEFORMATEXTENSIBLE mapping. This mapping works
|
||||
* as if all LSBs of dwChannelMask are set. */
|
||||
|
||||
/** \cond fulldocs */
|
||||
PA_CHANNEL_MAP_OSS,
|
||||
/**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
|
||||
/**< The default channel mapping used by OSS as defined in the OSS
|
||||
* 4.0 API specs. This mapping is probably not too useful since
|
||||
* the OSS API has changed in this respect and no longer knows a
|
||||
* default channel mapping based on the number of channels. */
|
||||
/** \endcond */
|
||||
|
||||
/**< Upper limit of valid channel mapping definitions */
|
||||
PA_CHANNEL_MAP_DEF_MAX,
|
||||
|
|
@ -282,7 +292,7 @@ pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels,
|
|||
/** Return a text label for the specified channel position */
|
||||
const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE;
|
||||
|
||||
/* The inverse of pa_channel_position_to_string(). \since 0.9.16 */
|
||||
/** The inverse of pa_channel_position_to_string(). \since 0.9.16 */
|
||||
pa_channel_position_t pa_channel_position_from_string(const char *s) PA_GCC_PURE;
|
||||
|
||||
/** Return a human readable text label for the specified channel position. \since 0.9.7 */
|
||||
|
|
|
|||
|
|
@ -125,6 +125,10 @@ int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) {
|
|||
pa_assert(b);
|
||||
|
||||
pa_return_val_if_fail(pa_sample_spec_valid(a), 0);
|
||||
|
||||
if (PA_UNLIKELY(a == b))
|
||||
return 1;
|
||||
|
||||
pa_return_val_if_fail(pa_sample_spec_valid(b), 0);
|
||||
|
||||
return
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) {
|
|||
pa_assert(b);
|
||||
|
||||
pa_return_val_if_fail(pa_cvolume_valid(a), 0);
|
||||
|
||||
if (PA_UNLIKELY(a == b))
|
||||
return 1;
|
||||
|
||||
pa_return_val_if_fail(pa_cvolume_valid(b), 0);
|
||||
|
||||
if (a->channels != b->channels)
|
||||
|
|
@ -122,7 +126,7 @@ pa_volume_t pa_cvolume_avg_mask(const pa_cvolume *a, const pa_channel_map *cm, p
|
|||
}
|
||||
|
||||
pa_volume_t pa_cvolume_max(const pa_cvolume *a) {
|
||||
pa_volume_t m = 0;
|
||||
pa_volume_t m = PA_VOLUME_MUTED;
|
||||
unsigned c;
|
||||
|
||||
pa_assert(a);
|
||||
|
|
@ -135,8 +139,22 @@ pa_volume_t pa_cvolume_max(const pa_cvolume *a) {
|
|||
return m;
|
||||
}
|
||||
|
||||
pa_volume_t pa_cvolume_min(const pa_cvolume *a) {
|
||||
pa_volume_t m = PA_VOLUME_MAX;
|
||||
unsigned c;
|
||||
|
||||
pa_assert(a);
|
||||
pa_return_val_if_fail(pa_cvolume_valid(a), PA_VOLUME_MUTED);
|
||||
|
||||
for (c = 0; c < a->channels; c++)
|
||||
if (a->values[c] < m)
|
||||
m = a->values[c];
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) {
|
||||
pa_volume_t m = 0;
|
||||
pa_volume_t m = PA_VOLUME_MUTED;
|
||||
unsigned c, n;
|
||||
|
||||
pa_assert(a);
|
||||
|
|
@ -158,17 +176,42 @@ pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, p
|
|||
return m;
|
||||
}
|
||||
|
||||
pa_volume_t pa_cvolume_min_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) {
|
||||
pa_volume_t m = PA_VOLUME_MAX;
|
||||
unsigned c, n;
|
||||
|
||||
pa_assert(a);
|
||||
|
||||
if (!cm)
|
||||
return pa_cvolume_min(a);
|
||||
|
||||
pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(a, cm), PA_VOLUME_MUTED);
|
||||
|
||||
for (c = n = 0; c < a->channels; c++) {
|
||||
|
||||
if (!(PA_CHANNEL_POSITION_MASK(cm->map[c]) & mask))
|
||||
continue;
|
||||
|
||||
if (a->values[c] < m)
|
||||
m = a->values[c];
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b) {
|
||||
return pa_sw_volume_from_linear(pa_sw_volume_to_linear(a) * pa_sw_volume_to_linear(b));
|
||||
|
||||
/* cbrt((a/PA_VOLUME_NORM)^3*(b/PA_VOLUME_NORM)^3)*PA_VOLUME_NORM = a*b/PA_VOLUME_NORM */
|
||||
|
||||
return (pa_volume_t) (((uint64_t) a * (uint64_t) b + (uint64_t) PA_VOLUME_NORM / 2ULL) / (uint64_t) PA_VOLUME_NORM);
|
||||
}
|
||||
|
||||
pa_volume_t pa_sw_volume_divide(pa_volume_t a, pa_volume_t b) {
|
||||
double v = pa_sw_volume_to_linear(b);
|
||||
|
||||
if (v <= 0)
|
||||
if (b <= PA_VOLUME_MUTED)
|
||||
return 0;
|
||||
|
||||
return pa_sw_volume_from_linear(pa_sw_volume_to_linear(a) / v);
|
||||
return (pa_volume_t) (((uint64_t) a * (uint64_t) PA_VOLUME_NORM + (uint64_t) b / 2ULL) / (uint64_t) b);
|
||||
}
|
||||
|
||||
/* Amplitude, not power */
|
||||
|
|
@ -249,7 +292,7 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
|
|||
l -= pa_snprintf(e, l, "%s%u: %3u%%",
|
||||
first ? "" : " ",
|
||||
channel,
|
||||
(c->values[channel]*100)/PA_VOLUME_NORM);
|
||||
(c->values[channel]*100+PA_VOLUME_NORM/2)/PA_VOLUME_NORM);
|
||||
|
||||
e = strchr(e, 0);
|
||||
first = FALSE;
|
||||
|
|
@ -269,7 +312,7 @@ char *pa_volume_snprint(char *s, size_t l, pa_volume_t v) {
|
|||
return s;
|
||||
}
|
||||
|
||||
pa_snprintf(s, l, "%3u%%", (v*100)/PA_VOLUME_NORM);
|
||||
pa_snprintf(s, l, "%3u%%", (v*100+PA_VOLUME_NORM/2)/PA_VOLUME_NORM);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -815,3 +858,55 @@ pa_volume_t pa_cvolume_get_position(
|
|||
|
||||
return v;
|
||||
}
|
||||
|
||||
pa_cvolume* pa_cvolume_merge(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b) {
|
||||
unsigned i;
|
||||
|
||||
pa_assert(dest);
|
||||
pa_assert(a);
|
||||
pa_assert(b);
|
||||
|
||||
pa_return_val_if_fail(pa_cvolume_valid(a), NULL);
|
||||
pa_return_val_if_fail(pa_cvolume_valid(b), NULL);
|
||||
|
||||
for (i = 0; i < a->channels && i < b->channels; i++)
|
||||
dest->values[i] = PA_MAX(a->values[i], b->values[i]);
|
||||
|
||||
dest->channels = (uint8_t) i;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc) {
|
||||
pa_volume_t m;
|
||||
|
||||
pa_assert(v);
|
||||
|
||||
pa_return_val_if_fail(pa_cvolume_valid(v), NULL);
|
||||
|
||||
m = pa_cvolume_max(v);
|
||||
|
||||
if (m >= PA_VOLUME_MAX - inc)
|
||||
m = PA_VOLUME_MAX;
|
||||
else
|
||||
m += inc;
|
||||
|
||||
return pa_cvolume_scale(v, m);
|
||||
}
|
||||
|
||||
pa_cvolume* pa_cvolume_dec(pa_cvolume *v, pa_volume_t dec) {
|
||||
pa_volume_t m;
|
||||
|
||||
pa_assert(v);
|
||||
|
||||
pa_return_val_if_fail(pa_cvolume_valid(v), NULL);
|
||||
|
||||
m = pa_cvolume_max(v);
|
||||
|
||||
if (m <= PA_VOLUME_MUTED + dec)
|
||||
m = PA_VOLUME_MUTED;
|
||||
else
|
||||
m -= dec;
|
||||
|
||||
return pa_cvolume_scale(v, m);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,6 +195,16 @@ pa_volume_t pa_cvolume_max(const pa_cvolume *a) PA_GCC_PURE;
|
|||
* \since 0.9.16 */
|
||||
pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) PA_GCC_PURE;
|
||||
|
||||
/** Return the minimum volume of all channels. \since 0.9.16 */
|
||||
pa_volume_t pa_cvolume_min(const pa_cvolume *a) PA_GCC_PURE;
|
||||
|
||||
/** Return the minimum volume of all channels that are included in the
|
||||
* specified channel map with the specified channel position mask. If
|
||||
* cm is NULL this call is identical to pa_cvolume_min(). If no
|
||||
* channel is selected the returned value will be PA_VOLUME_MUTED.
|
||||
* \since 0.9.16 */
|
||||
pa_volume_t pa_cvolume_min_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) PA_GCC_PURE;
|
||||
|
||||
/** Return TRUE when the passed cvolume structure is valid, FALSE otherwise */
|
||||
int pa_cvolume_valid(const pa_cvolume *v) PA_GCC_PURE;
|
||||
|
||||
|
|
@ -213,11 +223,13 @@ int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) PA_GCC_PURE
|
|||
pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b) PA_GCC_CONST;
|
||||
|
||||
/** Multiply two per-channel volumes and return the result in
|
||||
* *dest. This is only valid for software volumes! */
|
||||
* *dest. This is only valid for software volumes! a, b and dest may
|
||||
* point to the same structure. */
|
||||
pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
|
||||
|
||||
/** Multiply a per-channel volume with a scalar volume and return the
|
||||
* result in *dest. This is only valid for software volumes! \since
|
||||
* result in *dest. This is only valid for software volumes! a
|
||||
* and dest may point to the same structure. \since
|
||||
* 0.9.16 */
|
||||
pa_cvolume *pa_sw_cvolume_multiply_scalar(pa_cvolume *dest, const pa_cvolume *a, pa_volume_t b);
|
||||
|
||||
|
|
@ -228,11 +240,13 @@ pa_cvolume *pa_sw_cvolume_multiply_scalar(pa_cvolume *dest, const pa_cvolume *a,
|
|||
pa_volume_t pa_sw_volume_divide(pa_volume_t a, pa_volume_t b) PA_GCC_CONST;
|
||||
|
||||
/** Divide two per-channel volumes and return the result in
|
||||
* *dest. This is only valid for software volumes! \since 0.9.13 */
|
||||
* *dest. This is only valid for software volumes! a, b
|
||||
* and dest may point to the same structure. \since 0.9.13 */
|
||||
pa_cvolume *pa_sw_cvolume_divide(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
|
||||
|
||||
/** Divide a per-channel volume by a scalar volume and return the
|
||||
* result in *dest. This is only valid for software volumes! \since
|
||||
* result in *dest. This is only valid for software volumes! a
|
||||
* and dest may point to the same structure. \since
|
||||
* 0.9.16 */
|
||||
pa_cvolume *pa_sw_cvolume_divide_scalar(pa_cvolume *dest, const pa_cvolume *a, pa_volume_t b);
|
||||
|
||||
|
|
@ -326,6 +340,19 @@ pa_cvolume* pa_cvolume_set_position(pa_cvolume *cv, const pa_channel_map *map, p
|
|||
* position by calling pa_channel_map_has_position(). \since 0.9.16 */
|
||||
pa_volume_t pa_cvolume_get_position(pa_cvolume *cv, const pa_channel_map *map, pa_channel_position_t t) PA_GCC_PURE;
|
||||
|
||||
/** This goes through all channels in a and b and sets the
|
||||
* corresponding channel in dest to the greater volume of both. a, b
|
||||
* and dest may point to the same structure. \since 0.9.16 */
|
||||
pa_cvolume* pa_cvolume_merge(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
|
||||
|
||||
/** Increase the volume passed in by 'inc'. The proportions between
|
||||
* the channels are kept. \since 0.9.16 */
|
||||
pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc);
|
||||
|
||||
/** Increase the volume passed in by 'inc'. The proportions between
|
||||
* the channels are kept. \since 0.9.16 */
|
||||
pa_cvolume* pa_cvolume_dec(pa_cvolume *v, pa_volume_t dec);
|
||||
|
||||
PA_C_DECL_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue