summaryrefslogtreecommitdiff
path: root/ztmonitor.c
diff options
context:
space:
mode:
authormartinp <martinp@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-08-29 20:33:43 +0000
committermartinp <martinp@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-08-29 20:33:43 +0000
commitf3ac57c43fe52f591326e2a65c97c42f28229dcb (patch)
tree460311b3f44f96ade149d59d167a7b49c710dd5b /ztmonitor.c
parent6a0ba1704a3cf9d030e863e17b8530361ff4da5d (diff)
Allow to save to a file even when there is no active sound card
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@237 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztmonitor.c')
-rwxr-xr-xztmonitor.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/ztmonitor.c b/ztmonitor.c
index c226c33..d915ece 100755
--- a/ztmonitor.c
+++ b/ztmonitor.c
@@ -227,8 +227,10 @@ int main(int argc, char *argv[])
}
if (!visual) {
/* Open audio */
- if ((afd = audio_open()) < 0)
- exit(1);
+ if ((afd = audio_open()) < 0) {
+ printf("Cannot open audio ...\n");
+ if (!ofh) exit(0);
+ }
}
/* Open Pseudo device */
if ((pfd = pseudo_open()) < 0)
@@ -278,13 +280,14 @@ int main(int argc, char *argv[])
} else {
if (ofh)
fwrite(buf, 1, res, ofh);
-
- 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);
+ if (afd) {
+ 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);
+ }
}
}
if (ofh) fclose(ofh); /*Never Reached */