diff options
-rwxr-xr-x | ztmonitor.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/ztmonitor.c b/ztmonitor.c index db20d58..da186ee 100755 --- a/ztmonitor.c +++ b/ztmonitor.c @@ -51,12 +51,12 @@ #define FRAG_SIZE 8 +static int stereo = 0; int audio_open(void) { int fd; int speed = 8000; int fmt = AFMT_S16_LE; - int stereo = 0; int fragsize = (BUFFERS << 16) | (FRAG_SIZE); struct audio_buf_info ispace, ospace; fd = open("/dev/dsp", O_WRONLY); @@ -76,6 +76,9 @@ int audio_open(void) close(fd); return -1; } + if (stereo != 0) { + fprintf(stderr, "Can't turn stereo off :(\n"); + } /* Step 3: Make 8000 Hz */ if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) < 0) { fprintf(stderr, "ioctl(SPEED) failed: %s\n", strerror(errno)); @@ -186,10 +189,11 @@ void visualize(short *tx, short *rx, int cnt) int main(int argc, char *argv[]) { int afd = -1, pfd, pfd2 = -1; - char buf[8192]; - char buf2[8192]; + short buf[8192]; + short buf2[16384]; int res, res2; int visual = 0; + int x; struct zt_confinfo zc; if ((argc < 2) || (atoi(argv[1]) < 1)) { @@ -249,8 +253,14 @@ int main(int argc, char *argv[]) visualize((short *)buf, (short *)buf2, res/2); else printf("Huh? res = %d, res2 = %d?\n", res, res2); - } else - write(afd, buf, res); + } else { + if (stereo) { + for (x=0;x<res;x++) + buf2[x<<1] = buf2[(x<<1) + 1] = buf[x]; + write(afd, buf2, res << 1); + } else + write(afd, buf, res); + } } exit(0); } |