summaryrefslogtreecommitdiff
path: root/ztmonitor.c
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2002-07-25 21:07:47 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2002-07-25 21:07:47 +0000
commit6c7495ba44d73c05b5c2fc6d0c0a9577a8ff5278 (patch)
tree20f857ffae6370a60ef989eb737d0b25f9f9615b /ztmonitor.c
parentadcf20eb692b6e78838be24ae7c8798b182fd667 (diff)
Version 0.3.0 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@95 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztmonitor.c')
-rwxr-xr-xztmonitor.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ztmonitor.c b/ztmonitor.c
index d10f47e..2a6cca9 100755
--- a/ztmonitor.c
+++ b/ztmonitor.c
@@ -46,12 +46,18 @@
#endif
#include <linux/soundcard.h>
+#define BUFFERS 4
+
+#define FRAG_SIZE 8
+
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);
if (fd < 0) {
fprintf(stderr, "Unable to open /dev/dsp: %s\n", strerror(errno));
@@ -77,6 +83,25 @@ int audio_open(void)
}
if (speed != 8000)
fprintf(stderr, "Warning: Requested 8000 Hz, got %d\n", speed);
+ if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &fragsize)) {
+ fprintf(stderr, "Sound card won't let me set fragment size to 10 64-byte buffers (%x)\n"
+ "so sound may be choppy: %s.\n", fragsize, strerror(errno));
+ }
+ bzero(&ispace, sizeof(ispace));
+ bzero(&ospace, sizeof(ospace));
+
+ if (ioctl(fd, SNDCTL_DSP_GETISPACE, &ispace)) {
+ /* They don't support block size stuff, so just return but notify the user */
+ fprintf(stderr, "Sound card won't let me know the input buffering...\n");
+ }
+ if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &ospace)) {
+ /* They don't support block size stuff, so just return but notify the user */
+ fprintf(stderr, "Sound card won't let me know the output buffering...\n");
+ }
+ fprintf(stderr, "New input space: %d of %d %d byte fragments (%d bytes left)\n",
+ ispace.fragments, ispace.fragstotal, ispace.fragsize, ispace.bytes);
+ fprintf(stderr, "New output space: %d of %d %d byte fragments (%d bytes left)\n",
+ ospace.fragments, ospace.fragstotal, ospace.fragsize, ospace.bytes);
return fd;
}