mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
alsa-mixer: select nearest alsa volume step in sync-volume mode
This commit is contained in:
parent
1e7c4dd3e6
commit
4eb513cbf4
4 changed files with 76 additions and 14 deletions
|
|
@ -1129,7 +1129,7 @@ static void source_set_volume_cb(pa_source *s) {
|
|||
struct userdata *u = s->userdata;
|
||||
pa_cvolume r;
|
||||
char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX];
|
||||
pa_bool_t write_to_hw = (s->flags & PA_SOURCE_SYNC_VOLUME) ? FALSE : TRUE;
|
||||
pa_bool_t sync_volume = !!(s->flags & PA_SOURCE_SYNC_VOLUME);
|
||||
|
||||
pa_assert(u);
|
||||
pa_assert(u->mixer_path);
|
||||
|
|
@ -1138,7 +1138,7 @@ static void source_set_volume_cb(pa_source *s) {
|
|||
/* Shift up by the base volume */
|
||||
pa_sw_cvolume_divide_scalar(&r, &s->real_volume, s->base_volume);
|
||||
|
||||
if (pa_alsa_path_set_volume(u->mixer_path, u->mixer_handle, &s->channel_map, &r, write_to_hw) < 0)
|
||||
if (pa_alsa_path_set_volume(u->mixer_path, u->mixer_handle, &s->channel_map, &r, sync_volume, !sync_volume) < 0)
|
||||
return;
|
||||
|
||||
/* Shift down by the base volume, so that 0dB becomes maximum volume */
|
||||
|
|
@ -1195,7 +1195,7 @@ static void source_write_volume_cb(pa_source *s) {
|
|||
/* Shift up by the base volume */
|
||||
pa_sw_cvolume_divide_scalar(&hw_vol, &hw_vol, s->base_volume);
|
||||
|
||||
if (pa_alsa_path_set_volume(u->mixer_path, u->mixer_handle, &s->channel_map, &hw_vol, TRUE) < 0)
|
||||
if (pa_alsa_path_set_volume(u->mixer_path, u->mixer_handle, &s->channel_map, &hw_vol, TRUE, TRUE) < 0)
|
||||
pa_log_error("Writing HW volume failed");
|
||||
else {
|
||||
pa_cvolume tmp_vol;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue