[pulseaudio-commits] r1219 - /trunk/src/modules/oss-util.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat Aug 12 08:09:49 PDT 2006
Author: lennart
Date: Sat Aug 12 17:09:49 2006
New Revision: 1219
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1219&root=pulseaudio&view=rev
Log:
when the requested sample format is not available for OSS devices, print a nice warning and take what we can get instead
Modified:
trunk/src/modules/oss-util.c
Modified: trunk/src/modules/oss-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/oss-util.c?rev=1219&root=pulseaudio&r1=1218&r2=1219&view=diff
==============================================================================
--- trunk/src/modules/oss-util.c (original)
+++ trunk/src/modules/oss-util.c Sat Aug 12 17:09:49 2006
@@ -98,6 +98,8 @@
int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
int format, channels, speed, reqformat;
+ pa_sample_format_t orig_format;
+
static const int format_trans[PA_SAMPLE_MAX] = {
[PA_SAMPLE_U8] = AFMT_U8,
[PA_SAMPLE_ALAW] = AFMT_A_LAW,
@@ -110,6 +112,8 @@
assert(fd >= 0 && ss);
+ orig_format = ss->format;
+
reqformat = format = format_trans[ss->format];
if (reqformat == AFMT_QUERY || ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != reqformat) {
format = AFMT_S16_NE;
@@ -128,22 +132,38 @@
} else
ss->format = PA_SAMPLE_S16NE;
}
-
+
+ if (orig_format != ss->format)
+ pa_log_warn(__FILE__": device doesn't support sample format %s, changed to %s.",
+ pa_sample_format_to_string(orig_format),
+ pa_sample_format_to_string(ss->format));
+
channels = ss->channels;
if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) < 0) {
pa_log(__FILE__": SNDCTL_DSP_CHANNELS: %s", pa_cstrerror(errno));
return -1;
}
- assert(channels);
- ss->channels = channels;
+ assert(channels > 0);
+
+ if (ss->channels != channels) {
+ pa_log_warn(__FILE__": device doesn't support %i channels, using %i channels.", ss->channels, channels);
+ ss->channels = channels;
+ }
speed = ss->rate;
if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) < 0) {
pa_log(__FILE__": SNDCTL_DSP_SPEED: %s", pa_cstrerror(errno));
return -1;
}
- assert(speed);
- ss->rate = speed;
+ assert(speed > 0);
+
+ if (ss->rate != (unsigned) speed) {
+ pa_log_warn(__FILE__": device doesn't support %i Hz, changed to %i Hz.", ss->rate, speed);
+
+ /* If the sample rate deviates too much, we need to resample */
+ if (speed < ss->rate*.95 || speed > ss->rate*1.05)
+ ss->rate = speed;
+ }
return 0;
}
More information about the pulseaudio-commits
mailing list