mirror of
https://github.com/mpv-player/mpv
synced 2025-03-04 05:07:51 +00:00
ao_oss: check whether setting samplerate succeeds
Independent from whether the samplerate was accepted or adjusted, errors returned by the ioctl are fatal errors. Found by Coverity.
This commit is contained in:
parent
c6c46f5aa7
commit
9d2aef048d
@ -322,7 +322,8 @@ static int reopen_device(struct ao *ao, bool allow_format_changes)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (AF_FORMAT_IS_IEC61937(format)) {
|
if (AF_FORMAT_IS_IEC61937(format)) {
|
||||||
ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate);
|
if (ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate) == -1)
|
||||||
|
goto fail;
|
||||||
// Probably could be fixed by setting number of channels; needs testing.
|
// Probably could be fixed by setting number of channels; needs testing.
|
||||||
if (channels.num != 2) {
|
if (channels.num != 2) {
|
||||||
MP_ERR(ao, "Format %s not implemented.\n", af_fmt_to_str(format));
|
MP_ERR(ao, "Format %s not implemented.\n", af_fmt_to_str(format));
|
||||||
@ -374,7 +375,8 @@ static int reopen_device(struct ao *ao, bool allow_format_changes)
|
|||||||
MP_VERBOSE(ao, "using %d channels (requested: %d)\n",
|
MP_VERBOSE(ao, "using %d channels (requested: %d)\n",
|
||||||
channels.num, reqchannels);
|
channels.num, reqchannels);
|
||||||
// set rate
|
// set rate
|
||||||
ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate);
|
if (ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate) == -1)
|
||||||
|
goto fail;
|
||||||
MP_VERBOSE(ao, "using %d Hz samplerate\n", samplerate);
|
MP_VERBOSE(ao, "using %d Hz samplerate\n", samplerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user