mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
sink, source: Add a way to change channel map
This adds functions to allow changing the channel map on a sink or source. We make module-null-sink use this function instead of changing the channel map manually to allow for logging and notifications. The source function is currently unused but we add it to maintain symmetry with the sink.
This commit is contained in:
parent
e4a085f6d3
commit
47298b8de8
5 changed files with 54 additions and 3 deletions
|
|
@ -182,9 +182,12 @@ static int sink_reconfigure_cb(pa_sink *s, pa_sample_spec *spec, pa_channel_map
|
|||
s->sample_spec = *spec;
|
||||
|
||||
if (map)
|
||||
s->channel_map = *map;
|
||||
else
|
||||
pa_channel_map_init_auto(&s->channel_map, spec->channels, PA_CHANNEL_MAP_DEFAULT);
|
||||
pa_sink_set_channel_map(s, map);
|
||||
else {
|
||||
pa_channel_map def_map;
|
||||
pa_channel_map_init_auto(&def_map, spec->channels, PA_CHANNEL_MAP_DEFAULT);
|
||||
pa_sink_set_channel_map(s, &def_map);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4083,6 +4083,29 @@ void pa_sink_set_sample_rate(pa_sink *s, uint32_t rate) {
|
|||
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
|
||||
}
|
||||
|
||||
/* Called from the main thread */
|
||||
void pa_sink_set_channel_map(pa_sink *s, pa_channel_map *map) {
|
||||
pa_channel_map old_map;
|
||||
char old_map_str[PA_CHANNEL_MAP_SNPRINT_MAX];
|
||||
char new_map_str[PA_CHANNEL_MAP_SNPRINT_MAX];
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(map);
|
||||
pa_assert(pa_channel_map_valid(map));
|
||||
|
||||
old_map = s->channel_map;
|
||||
if (pa_channel_map_equal(&old_map, map))
|
||||
return;
|
||||
|
||||
pa_log_info("%s: channel map: %s -> %s", s->name,
|
||||
pa_channel_map_snprint(old_map_str, sizeof(old_map_str), &old_map),
|
||||
pa_channel_map_snprint(new_map_str, sizeof(new_map_str), map));
|
||||
|
||||
s->channel_map = *map;
|
||||
|
||||
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
|
||||
}
|
||||
|
||||
/* Called from the main thread. */
|
||||
void pa_sink_set_reference_volume_direct(pa_sink *s, const pa_cvolume *volume) {
|
||||
pa_cvolume old_volume;
|
||||
|
|
|
|||
|
|
@ -529,6 +529,7 @@ pa_idxset* pa_sink_check_formats(pa_sink *s, pa_idxset *in_formats);
|
|||
|
||||
void pa_sink_set_sample_format(pa_sink *s, pa_sample_format_t format);
|
||||
void pa_sink_set_sample_rate(pa_sink *s, uint32_t rate);
|
||||
void pa_sink_set_channel_map(pa_sink *s, pa_channel_map *map);
|
||||
|
||||
/*** To be called exclusively by the sink driver, from IO context */
|
||||
|
||||
|
|
|
|||
|
|
@ -3077,6 +3077,29 @@ void pa_source_set_sample_rate(pa_source *s, uint32_t rate) {
|
|||
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
|
||||
}
|
||||
|
||||
/* Called from the main thread */
|
||||
void pa_source_set_channel_map(pa_source *s, pa_channel_map *map) {
|
||||
pa_channel_map old_map;
|
||||
char old_map_str[PA_CHANNEL_MAP_SNPRINT_MAX];
|
||||
char new_map_str[PA_CHANNEL_MAP_SNPRINT_MAX];
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(map);
|
||||
pa_assert(pa_channel_map_valid(map));
|
||||
|
||||
old_map = s->channel_map;
|
||||
if (pa_channel_map_equal(&old_map, map))
|
||||
return;
|
||||
|
||||
pa_log_info("%s: channel map: %s -> %s", s->name,
|
||||
pa_channel_map_snprint(old_map_str, sizeof(old_map_str), &old_map),
|
||||
pa_channel_map_snprint(new_map_str, sizeof(new_map_str), map));
|
||||
|
||||
s->channel_map = *map;
|
||||
|
||||
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
|
||||
}
|
||||
|
||||
/* Called from the main thread. */
|
||||
void pa_source_set_reference_volume_direct(pa_source *s, const pa_cvolume *volume) {
|
||||
pa_cvolume old_volume;
|
||||
|
|
|
|||
|
|
@ -450,6 +450,7 @@ pa_idxset* pa_source_check_formats(pa_source *s, pa_idxset *in_formats);
|
|||
|
||||
void pa_source_set_sample_format(pa_source *s, pa_sample_format_t format);
|
||||
void pa_source_set_sample_rate(pa_source *s, uint32_t rate);
|
||||
void pa_source_set_channel_map(pa_source *s, pa_channel_map *map);
|
||||
|
||||
/*** To be called exclusively by the source driver, from IO context */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue