diff options
author | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-10-22 02:22:01 +0000 |
---|---|---|
committer | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-10-22 02:22:01 +0000 |
commit | fc33a5b3eca25fa80cab3e8522be177f680cfeb2 (patch) | |
tree | d2b56ee8bf2fbd992ee85cd50846a9ef25704078 /ztmonitor.c | |
parent | 74be0e96626f2d29d20cb4c8ae5a652d1bf013bb (diff) |
Version 0.3.2 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@119 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztmonitor.c')
-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); } |