Skip to content
Snippets Groups Projects
Commit f9c8fdd9 authored by Stan Seibert's avatar Stan Seibert
Browse files

OSS plugin correctly detects when audio rate cannot be set to correct value

on device.


git-svn-id: http://svn.xiph.org/trunk/ao@1862 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 0cf1f70d
No related branches found
No related tags found
No related merge requests found
......@@ -220,8 +220,13 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format)
format->channels);
goto ERR;
}
ioctl(internal->fd,SNDCTL_DSP_STEREO,&tmp);
if (ioctl(internal->fd,SNDCTL_DSP_STEREO,&tmp) < 0) {
fprintf(stderr, "libao - OSS cannot set channels to %d\n",
format->channels);
goto ERR;
}
/* To eliminate the need for a swap buffer, we set the device
to use whatever byte format the client selected. */
switch (format->bits)
......@@ -236,11 +241,24 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format)
format->bits);
goto ERR;
}
ioctl(internal->fd,SNDCTL_DSP_SAMPLESIZE,&tmp);
if (ioctl(internal->fd,SNDCTL_DSP_SAMPLESIZE,&tmp) < 0) {
fprintf(stderr, "libao - OSS cannot set sample size to %d\n",
format->bits);
goto ERR;
}
tmp = format->rate;
ioctl(internal->fd,SNDCTL_DSP_SPEED, &tmp);
/* Some cards aren't too accurate with their clocks and set to the
exact data rate, but something close. Fail only if completely out
of whack. */
if (ioctl(internal->fd,SNDCTL_DSP_SPEED, &tmp) < 0
|| tmp > 1.01 * format->rate || tmp < 0.99 * format->rate) {
fprintf(stderr, "libao - OSS cannot set rate to %d\n",
format->rate);
goto ERR;
}
return 1; /* Open successful */
ERR:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment