diff options
Diffstat (limited to 'src/modules/alsa')
-rw-r--r-- | src/modules/alsa/alsa-sink.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 53c14b80..f861904f 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1281,15 +1281,17 @@ static void sink_write_volume_cb(pa_sink *s) { (pa_cvolume_max(&tmp_vol) <= (PA_VOLUME_NORM + VOLUME_ACCURACY)); if (!accurate_enough) { - char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX]; - char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX]; + union { + char db[2][PA_SW_CVOLUME_SNPRINT_DB_MAX]; + char pcnt[2][PA_CVOLUME_SNPRINT_MAX]; + } vol; pa_log_debug("Written HW volume did not match with the request: %s (request) != %s", - pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &s->thread_info.current_hw_volume), - pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &hw_vol)); + pa_cvolume_snprint(vol.pcnt[0], sizeof(vol.pcnt[0]), &s->thread_info.current_hw_volume), + pa_cvolume_snprint(vol.pcnt[1], sizeof(vol.pcnt[1]), &hw_vol)); pa_log_debug(" in dB: %s (request) != %s", - pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &s->thread_info.current_hw_volume), - pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &hw_vol)); + pa_sw_cvolume_snprint_dB(vol.db[0], sizeof(vol.db[0]), &s->thread_info.current_hw_volume), + pa_sw_cvolume_snprint_dB(vol.db[1], sizeof(vol.db[1]), &hw_vol)); } } } @@ -1670,8 +1672,6 @@ fail: } static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_volume) { - int (*mixer_callback)(snd_mixer_elem_t *, unsigned int); - pa_assert(u); if (!u->mixer_handle) @@ -1760,29 +1760,31 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v pa_log_info("Using hardware mute control."); } - if (sync_volume) { - u->mixer_pd = pa_alsa_mixer_pdata_new(); - mixer_callback = io_mixer_callback; - - if (pa_alsa_set_mixer_rtpoll(u->mixer_pd, u->mixer_handle, u->rtpoll) < 0) { - pa_log("Failed to initialize file descriptor monitoring"); - return -1; - } + if (u->sink->flags & (PA_SINK_HW_VOLUME_CTRL|PA_SINK_HW_MUTE_CTRL)) { + int (*mixer_callback)(snd_mixer_elem_t *, unsigned int); + if (u->sink->flags & PA_SINK_SYNC_VOLUME) { + u->mixer_pd = pa_alsa_mixer_pdata_new(); + mixer_callback = io_mixer_callback; - } else { - u->mixer_fdl = pa_alsa_fdlist_new(); - mixer_callback = ctl_mixer_callback; + if (pa_alsa_set_mixer_rtpoll(u->mixer_pd, u->mixer_handle, u->rtpoll) < 0) { + pa_log("Failed to initialize file descriptor monitoring"); + return -1; + } + } else { + u->mixer_fdl = pa_alsa_fdlist_new(); + mixer_callback = ctl_mixer_callback; - if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, u->core->mainloop) < 0) { - pa_log("Failed to initialize file descriptor monitoring"); - return -1; + if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, u->core->mainloop) < 0) { + pa_log("Failed to initialize file descriptor monitoring"); + return -1; + } } - } - if (u->mixer_path_set) - pa_alsa_path_set_set_callback(u->mixer_path_set, u->mixer_handle, mixer_callback, u); - else - pa_alsa_path_set_callback(u->mixer_path, u->mixer_handle, mixer_callback, u); + if (u->mixer_path_set) + pa_alsa_path_set_set_callback(u->mixer_path_set, u->mixer_handle, mixer_callback, u); + else + pa_alsa_path_set_callback(u->mixer_path, u->mixer_handle, mixer_callback, u); + } return 0; } |