1
0
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:
wm4 2014-11-21 10:05:46 +01:00
parent c6c46f5aa7
commit 9d2aef048d

View File

@ -322,7 +322,8 @@ static int reopen_device(struct ao *ao, bool allow_format_changes)
#endif
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.
if (channels.num != 2) {
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",
channels.num, reqchannels);
// 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);
}