mirror of
https://github.com/mpv-player/mpv
synced 2025-02-20 06:46:55 +00:00
ao_alsa: use sample format determination code
This commit is contained in:
parent
7eacfdcd25
commit
1557d2d470
@ -462,20 +462,18 @@ static int init_device(struct ao *ao, bool second_try)
|
|||||||
err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams);
|
err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams);
|
||||||
CHECK_ALSA_ERROR("Unable to get initial parameters");
|
CHECK_ALSA_ERROR("Unable to get initial parameters");
|
||||||
|
|
||||||
p->alsa_fmt = find_alsa_format(ao->format);
|
int try_formats[AF_FORMAT_COUNT];
|
||||||
if (p->alsa_fmt == SND_PCM_FORMAT_UNKNOWN) {
|
af_get_best_sample_formats(ao->format, try_formats);
|
||||||
p->alsa_fmt = SND_PCM_FORMAT_S16;
|
for (int n = 0; try_formats[n]; n++) {
|
||||||
ao->format = AF_FORMAT_S16;
|
ao->format = try_formats[n];
|
||||||
|
p->alsa_fmt = find_alsa_format(ao->format);
|
||||||
|
if (snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt) >= 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt);
|
if (!ao->format) {
|
||||||
if (err < 0) {
|
MP_ERR(ao, "Can't find appropriate sample format.\n");
|
||||||
if (af_fmt_is_spdif(ao->format))
|
goto alsa_error;
|
||||||
CHECK_ALSA_ERROR("Unable to set IEC61937 format");
|
|
||||||
MP_INFO(ao, "Format %s is not supported by hardware, trying default.\n",
|
|
||||||
af_fmt_to_str(ao->format));
|
|
||||||
p->alsa_fmt = SND_PCM_FORMAT_S16;
|
|
||||||
ao->format = AF_FORMAT_S16;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
|
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
|
||||||
|
Loading…
Reference in New Issue
Block a user