volume: introduce pa_cvolume_{get|set}_position()

This commit is contained in:
Lennart Poettering 2009-05-13 15:20:45 +02:00
parent 28069ef0f7
commit 905c8004a0
2 changed files with 59 additions and 0 deletions

View file

@ -685,3 +685,49 @@ pa_cvolume* pa_cvolume_set_fade(pa_cvolume *v, const pa_channel_map *map, float
return v; return v;
} }
pa_cvolume* pa_cvolume_set_position(
pa_cvolume *cv,
const pa_channel_map *map,
pa_channel_position_t t,
pa_volume_t v) {
unsigned c;
pa_bool_t good = FALSE;
pa_assert(cv);
pa_assert(map);
pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(cv, map), NULL);
pa_return_val_if_fail(t < PA_CHANNEL_POSITION_MAX, NULL);
for (c = 0; c < map->channels; c++)
if (map->map[c] == t) {
cv->values[c] = v;
good = TRUE;
}
return good ? cv : NULL;
}
pa_volume_t pa_cvolume_get_position(
pa_cvolume *cv,
const pa_channel_map *map,
pa_channel_position_t t) {
unsigned c;
pa_volume_t v = PA_VOLUME_MUTED;
pa_assert(cv);
pa_assert(map);
pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(cv, map), PA_VOLUME_MUTED);
pa_return_val_if_fail(t < PA_CHANNEL_POSITION_MAX, PA_VOLUME_MUTED);
for (c = 0; c < map->channels; c++)
if (map->map[c] == t)
if (cv->values[c] > v)
v = cv->values[c];
return v;
}

View file

@ -283,6 +283,19 @@ pa_cvolume* pa_cvolume_set_fade(pa_cvolume *v, const pa_channel_map *map, float
* volumes are kept. \since 0.9.15 */ * volumes are kept. \since 0.9.15 */
pa_cvolume* pa_cvolume_scale(pa_cvolume *v, pa_volume_t max); pa_cvolume* pa_cvolume_scale(pa_cvolume *v, pa_volume_t max);
/** Set the passed volume to all channels at the specified channel
* position. Will return the updated volume struct, or NULL if there
* is no channel at the position specified. You can check if a channel
* map includes a specific position by calling
* pa_channel_map_has_position(). \since 0.9.16 */
pa_cvolume* pa_cvolume_set_position(pa_cvolume *cv, const pa_channel_map *map, pa_channel_position_t t, pa_volume_t v);
/** Get the maximum volume of all channels at the specified channel
* position. Will return 0 if there is no channel at the position
* specified. You can check if a channel map includes a specific
* 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_C_DECL_END PA_C_DECL_END
#endif #endif