mirror of
https://github.com/mpv-player/mpv
synced 2024-12-11 17:37:23 +00:00
mixer: add more debug output
For remote-debugging volume rstore problems.
This commit is contained in:
parent
e408dd20c7
commit
1d2b81b550
@ -89,6 +89,7 @@ static void checkvolume(struct mixer *mixer)
|
|||||||
vol.left = (gain / (mixer->opts->softvol_max / 100.0)) * 100.0;
|
vol.left = (gain / (mixer->opts->softvol_max / 100.0)) * 100.0;
|
||||||
vol.right = (gain / (mixer->opts->softvol_max / 100.0)) * 100.0;
|
vol.right = (gain / (mixer->opts->softvol_max / 100.0)) * 100.0;
|
||||||
} else {
|
} else {
|
||||||
|
MP_DBG(mixer, "Reading volume from AO.\n");
|
||||||
// Rely on the values not changing if the query is not supported
|
// Rely on the values not changing if the query is not supported
|
||||||
ao_control(mixer->ao, AOCONTROL_GET_VOLUME, &vol);
|
ao_control(mixer->ao, AOCONTROL_GET_VOLUME, &vol);
|
||||||
ao_control(mixer->ao, AOCONTROL_GET_MUTE, &mixer->muted);
|
ao_control(mixer->ao, AOCONTROL_GET_MUTE, &mixer->muted);
|
||||||
@ -124,6 +125,7 @@ static void setvolume_internal(struct mixer *mixer, float l, float r)
|
|||||||
{
|
{
|
||||||
struct ao_control_vol vol = {.left = l, .right = r};
|
struct ao_control_vol vol = {.left = l, .right = r};
|
||||||
if (!mixer->softvol) {
|
if (!mixer->softvol) {
|
||||||
|
MP_DBG(mixer, "Setting volume on AO.\n");
|
||||||
if (ao_control(mixer->ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK)
|
if (ao_control(mixer->ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK)
|
||||||
MP_ERR(mixer, "Failed to change audio output volume.\n");
|
MP_ERR(mixer, "Failed to change audio output volume.\n");
|
||||||
return;
|
return;
|
||||||
@ -252,7 +254,6 @@ static void probe_softvol(struct mixer *mixer)
|
|||||||
mixer->ao_softvol = mixer->ao_perapp ||
|
mixer->ao_softvol = mixer->ao_perapp ||
|
||||||
ao_control(mixer->ao, AOCONTROL_HAS_SOFT_VOLUME, 0) == 1;
|
ao_control(mixer->ao, AOCONTROL_HAS_SOFT_VOLUME, 0) == 1;
|
||||||
|
|
||||||
|
|
||||||
if (mixer->opts->softvol == SOFTVOL_AUTO) {
|
if (mixer->opts->softvol == SOFTVOL_AUTO) {
|
||||||
// No system-wide volume => fine with AO volume control.
|
// No system-wide volume => fine with AO volume control.
|
||||||
mixer->softvol = !mixer->ao_softvol;
|
mixer->softvol = !mixer->ao_softvol;
|
||||||
@ -260,6 +261,8 @@ static void probe_softvol(struct mixer *mixer)
|
|||||||
mixer->softvol = mixer->opts->softvol == SOFTVOL_YES;
|
mixer->softvol = mixer->opts->softvol == SOFTVOL_YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MP_DBG(mixer, "Will use af_volume: %s\n", mixer->softvol ? "yes" : "no");
|
||||||
|
|
||||||
// If we can't use real volume control => force softvol.
|
// If we can't use real volume control => force softvol.
|
||||||
if (!mixer->softvol) {
|
if (!mixer->softvol) {
|
||||||
ao_control_vol_t vol;
|
ao_control_vol_t vol;
|
||||||
@ -319,6 +322,7 @@ static void restore_volume(struct mixer *mixer)
|
|||||||
force_vol_l = v_l;
|
force_vol_l = v_l;
|
||||||
force_vol_r = v_r;
|
force_vol_r = v_r;
|
||||||
force_mute = !!m;
|
force_mute = !!m;
|
||||||
|
MP_DBG(mixer, "Restoring volume from resume config.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
talloc_free(mixer->opts->mixer_restore_volume_data);
|
talloc_free(mixer->opts->mixer_restore_volume_data);
|
||||||
@ -334,10 +338,14 @@ static void restore_volume(struct mixer *mixer)
|
|||||||
opts->mixer_init_mute = -1;
|
opts->mixer_init_mute = -1;
|
||||||
|
|
||||||
checkvolume(mixer);
|
checkvolume(mixer);
|
||||||
if (force_vol_l >= 0 && force_vol_r >= 0)
|
if (force_vol_l >= 0 && force_vol_r >= 0) {
|
||||||
|
MP_DBG(mixer, "Restoring previous volume.\n");
|
||||||
mixer_setvolume(mixer, force_vol_l, force_vol_r);
|
mixer_setvolume(mixer, force_vol_l, force_vol_r);
|
||||||
if (force_mute >= 0)
|
}
|
||||||
|
if (force_mute >= 0) {
|
||||||
|
MP_DBG(mixer, "Restoring previous mute toggle.\n");
|
||||||
mixer_setmute(mixer, force_mute);
|
mixer_setmute(mixer, force_mute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called after the audio filter chain is built or rebuilt.
|
// Called after the audio filter chain is built or rebuilt.
|
||||||
@ -349,6 +357,8 @@ void mixer_reinit_audio(struct mixer *mixer, struct ao *ao, struct af_stream *af
|
|||||||
mixer->ao = ao;
|
mixer->ao = ao;
|
||||||
mixer->af = af;
|
mixer->af = af;
|
||||||
|
|
||||||
|
MP_DBG(mixer, "Reinit...\n");
|
||||||
|
|
||||||
probe_softvol(mixer);
|
probe_softvol(mixer);
|
||||||
restore_volume(mixer);
|
restore_volume(mixer);
|
||||||
|
|
||||||
@ -365,8 +375,11 @@ void mixer_uninit_audio(struct mixer *mixer)
|
|||||||
if (!mixer->ao)
|
if (!mixer->ao)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
MP_DBG(mixer, "Uninit...\n");
|
||||||
|
|
||||||
checkvolume(mixer);
|
checkvolume(mixer);
|
||||||
if (mixer->muted_by_us && !mixer->softvol && !mixer->ao_softvol) {
|
if (mixer->muted_by_us && !mixer->softvol && !mixer->ao_softvol) {
|
||||||
|
MP_DBG(mixer, "Draining.\n");
|
||||||
/* Current audio output API combines playing the remaining buffered
|
/* Current audio output API combines playing the remaining buffered
|
||||||
* audio and uninitializing the AO into one operation, even though
|
* audio and uninitializing the AO into one operation, even though
|
||||||
* ideally unmute would happen between those two steps. We can't do
|
* ideally unmute would happen between those two steps. We can't do
|
||||||
|
Loading…
Reference in New Issue
Block a user