summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/wav.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-01-10 21:47:42 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-01-10 21:47:42 +0000
commit37e6be3704bca205ce132f6b272639465cd841f4 (patch)
tree2a923a2c6b2319e21c555333db83e091842af53a /usr.bin/aucat/wav.c
parentb039c5e2f74be6a127e392ec2effc1aebc324126 (diff)
Add traces to help tracking subtle timing bugs often causing
underuns and overruns; such bugs are hard to debug with ktrace or a debugger. They are also handy to debug or monitor code using aucat. To enable traces, compile aucat with ``make DEBUG=-DDEBUG'' and use the -d option multiple times. ok jakemsr
Diffstat (limited to 'usr.bin/aucat/wav.c')
-rw-r--r--usr.bin/aucat/wav.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/usr.bin/aucat/wav.c b/usr.bin/aucat/wav.c
index 48563ed0ba1..aa6c7670341 100644
--- a/usr.bin/aucat/wav.c
+++ b/usr.bin/aucat/wav.c
@@ -24,6 +24,9 @@
#include "conf.h"
#include "dev.h"
#include "wav.h"
+#ifdef DEBUG
+#include "dbg.h"
+#endif
short wav_ulawmap[256] = {
-32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956,
@@ -447,6 +450,12 @@ wav_read(struct file *file, unsigned char *data, unsigned count)
if (f->rbytes >= 0 && count > f->rbytes) {
count = f->rbytes; /* file->rbytes fits in count */
if (count == 0) {
+#ifdef DEBUG
+ if (debug_level >= 3) {
+ file_dbg(&f->pipe.file);
+ dbg_puts(": read complete\n");
+ }
+#endif
file_eof(&f->pipe.file);
return 0;
}
@@ -472,6 +481,12 @@ wav_write(struct file *file, unsigned char *data, unsigned count)
if (f->wbytes >= 0 && count > f->wbytes) {
count = f->wbytes; /* wbytes fits in count */
if (count == 0) {
+#ifdef DEBUG
+ if (debug_level >= 3) {
+ file_dbg(&f->pipe.file);
+ dbg_puts(": write complete\n");
+ }
+#endif
file_hup(&f->pipe.file);
return 0;
}