mirror of https://github.com/mpv-player/mpv
ao_alsa: fill unused ALSA channels with silence
This happens when ALSA gives us more channels than we asked for, for whatever reasons. It looks like this wasn't handled correctly. The mpv and ALSA channel counts could mismatch, which would lead to UB. I couldn't actually trigger this case, though. I'm fairly sure that drivers or plugins exist that do it anyway. (Inofficial ALSA motto: if it can be broken, then why not break it?)
This commit is contained in:
parent
1d51dc20ea
commit
33012b4141
|
@ -794,8 +794,13 @@ static int init_device(struct ao *ao, int mode)
|
|||
if (num_channels != ao->channels.num) {
|
||||
int req = ao->channels.num;
|
||||
mp_chmap_from_channels(&ao->channels, MPMIN(2, num_channels));
|
||||
mp_chmap_fill_na(&ao->channels, num_channels);
|
||||
MP_ERR(ao, "Asked for %d channels, got %d - fallback to %s.\n", req,
|
||||
num_channels, mp_chmap_to_str(&ao->channels));
|
||||
if (num_channels != ao->channels.num) {
|
||||
MP_FATAL(ao, "mismatching channel counts.\n");
|
||||
goto alsa_error;
|
||||
}
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &p->buffersize);
|
||||
|
|
Loading…
Reference in New Issue