Added Paparazzi support

This commit is contained in:
Martin Mueller
2005-05-25 22:17:20 +00:00
parent 8b09e74ee9
commit 9e6e2426f3
+13 -2
View File
@@ -177,6 +177,7 @@ static void input_sound(unsigned int sample_rate, unsigned int overlap,
short *sp; short *sp;
unsigned char *bp; unsigned char *bp;
int fmt = 0; int fmt = 0;
int stereo = 0;
if ((fd = open(ifname ? ifname : "/dev/dsp", O_RDONLY)) < 0) { if ((fd = open(ifname ? ifname : "/dev/dsp", O_RDONLY)) < 0) {
perror("open"); perror("open");
@@ -205,6 +206,11 @@ static void input_sound(unsigned int sample_rate, unsigned int overlap,
perror("ioctl: SNDCTL_DSP_STEREO"); perror("ioctl: SNDCTL_DSP_STEREO");
exit (10); exit (10);
} }
if (sndparam == 1) {
fprintf(stderr, "soundif: Warning, cannot set the channel "
"number to 1, will use stereo\n");
stereo=1;
} else
if (sndparam != 0) { if (sndparam != 0) {
fprintf(stderr, "soundif: Error, cannot set the channel " fprintf(stderr, "soundif: Error, cannot set the channel "
"number to 1\n"); "number to 1\n");
@@ -261,8 +267,13 @@ static void input_sound(unsigned int sample_rate, unsigned int overlap,
if (!i) if (!i)
break; break;
if (i > 0) { if (i > 0) {
for (; i >= sizeof(b.s[0]); i -= sizeof(b.s[0]), sp++) if (stereo) {
fbuf[fbuf_cnt++] = (*sp) * (1.0/32768.0); for (; i >= sizeof(b.s[0]); i -= (sizeof(b.s[0])*2), sp+=2)
fbuf[fbuf_cnt++] = (*sp) * (1.0/32768.0);
} else {
for (; i >= sizeof(b.s[0]); i -= sizeof(b.s[0]), sp++)
fbuf[fbuf_cnt++] = (*sp) * (1.0/32768.0);
}
if (i) if (i)
fprintf(stderr, "warning: noninteger number of samples read\n"); fprintf(stderr, "warning: noninteger number of samples read\n");
if (fbuf_cnt > overlap) { if (fbuf_cnt > overlap) {