]>
code.delx.au - pulseaudio/blob - src/oss-util.c
2 #include <sys/soundcard.h>
10 int oss_auto_format(int fd
, struct pa_sample_spec
*ss
) {
11 int format
, channels
, speed
;
13 assert(fd
>= 0 && ss
);
16 if (ioctl(fd
, SNDCTL_DSP_SETFMT
, &format
) < 0 || format
!= AFMT_S16_NE
) {
17 int f
= AFMT_S16_NE
== AFMT_S16_LE
? AFMT_S16_BE
: AFMT_S16_LE
;
19 if (ioctl(fd
, SNDCTL_DSP_SETFMT
, &format
) < 0 || format
!= f
) {
21 if (ioctl(fd
, SNDCTL_DSP_SETFMT
, &format
) < 0 || format
!= AFMT_U8
) {
22 fprintf(stderr
, "SNDCTL_DSP_SETFMT: %s\n", format
!= AFMT_U8
? "No supported sample format" : strerror(errno
));
25 ss
->format
= PA_SAMPLE_U8
;
27 ss
->format
= f
== AFMT_S16_LE
? PA_SAMPLE_S16LE
: PA_SAMPLE_S16BE
;
29 ss
->format
= PA_SAMPLE_S16NE
;
32 if (ioctl(fd
, SNDCTL_DSP_CHANNELS
, &channels
) < 0) {
33 fprintf(stderr
, "SNDCTL_DSP_CHANNELS: %s\n", strerror(errno
));
37 ss
->channels
= channels
;
40 if (ioctl(fd
, SNDCTL_DSP_SPEED
, &speed
) < 0) {
41 fprintf(stderr
, "SNDCTL_DSP_SPEED: %s\n", strerror(errno
));