summaryrefslogtreecommitdiff
path: root/usrp/host/lib/legacy/circular_buffer.h
diff options
context:
space:
mode:
authormichaelld <michaelld@221aa14e-8319-0410-a670-987f0aec2ac5>2008-01-13 20:41:11 +0000
committermichaelld <michaelld@221aa14e-8319-0410-a670-987f0aec2ac5>2008-01-13 20:41:11 +0000
commit4022e568aa33f223df17b869af80f5c6565df286 (patch)
tree901c6938f22f7dde651a7eefba8d45bbf0ebe85f /usrp/host/lib/legacy/circular_buffer.h
parent88632145c80262215e8a1ea8c18fea4ae98772c9 (diff)
Merged OSX fixes for 10.5 (backwards compatible with 10.4 if not
earlier) for USRP legacy fast-usb code from r7358 branch into trunk: Fixed DEBUG commands in all files. Fixed flow control between originating and spawned threads. Fixed WritePipeAsync buffer write size. Added in debugging comments to fusb code, to better track async flow. NOT YET updated for MacOS X 10.5-specific IOKit code, but everything seems to work just fine as is. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@7417 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'usrp/host/lib/legacy/circular_buffer.h')
-rw-r--r--usrp/host/lib/legacy/circular_buffer.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/usrp/host/lib/legacy/circular_buffer.h b/usrp/host/lib/legacy/circular_buffer.h
index fa451d607b..8898e41948 100644
--- a/usrp/host/lib/legacy/circular_buffer.h
+++ b/usrp/host/lib/legacy/circular_buffer.h
@@ -26,7 +26,9 @@
#include "mld_threads.h"
#include <stdexcept>
+#ifndef DO_DEBUG
#define DO_DEBUG 0
+#endif
#if DO_DEBUG
#define DEBUG(X) do{X} while(0);
@@ -82,7 +84,7 @@ public:
DEBUG (fprintf (stderr, "c_b(): buf len (items) = %ld, "
"doWriteBlock = %s, doFullRead = %s\n", d_bufLen_I,
(d_doWriteBlock ? "true" : "false"),
- (d_doFullRead ? "true" : "false")));
+ (d_doFullRead ? "true" : "false")););
};
~circular_buffer () {
@@ -150,7 +152,7 @@ public:
int enqueue (T* buf, UInt32 bufLen_I) {
DEBUG (fprintf (stderr, "enqueue: buf = %X, bufLen = %ld, #av_wr = %ld, "
"#av_rd = %ld.\n", (unsigned int)buf, bufLen_I,
- d_n_avail_write_I, d_n_avail_read_I));
+ d_n_avail_write_I, d_n_avail_read_I););
if (bufLen_I > d_bufLen_I) {
fprintf (stderr, "cannot add buffer longer (%ld"
") than instantiated length (%ld"
@@ -173,21 +175,21 @@ public:
if (bufLen_I > d_n_avail_write_I) {
if (d_doWriteBlock) {
while (bufLen_I > d_n_avail_write_I) {
- DEBUG (fprintf (stderr, "enqueue: #len > #a, waiting.\n"));
+ DEBUG (fprintf (stderr, "enqueue: #len > #a, waiting.\n"););
// wait will automatically unlock() the internal mutex
d_writeBlock->wait ();
// and lock() it here.
if (d_doAbort) {
d_internal->unlock ();
- DEBUG (fprintf (stderr, "enqueue: #len > #a, aborting.\n"));
+ DEBUG (fprintf (stderr, "enqueue: #len > #a, aborting.\n"););
return (2);
}
- DEBUG (fprintf (stderr, "enqueue: #len > #a, done waiting.\n"));
+ DEBUG (fprintf (stderr, "enqueue: #len > #a, done waiting.\n"););
}
} else {
d_n_avail_read_I = d_bufLen_I - bufLen_I;
d_n_avail_write_I = bufLen_I;
- DEBUG (fprintf (stderr, "circular_buffer::enqueue: overflow\n"));
+ DEBUG (fprintf (stderr, "circular_buffer::enqueue: overflow\n"););
retval = -1;
}
}
@@ -233,7 +235,7 @@ public:
int dequeue (T* buf, UInt32* bufLen_I) {
DEBUG (fprintf (stderr, "dequeue: buf = %X, *bufLen = %ld, #av_wr = %ld, "
"#av_rd = %ld.\n", (unsigned int)buf, *bufLen_I,
- d_n_avail_write_I, d_n_avail_read_I));
+ d_n_avail_write_I, d_n_avail_read_I););
if (!bufLen_I)
throw std::runtime_error ("circular_buffer::dequeue(): "
"input bufLen pointer is NULL.\n");
@@ -257,29 +259,29 @@ public:
}
if (d_doFullRead) {
while (d_n_avail_read_I < l_bufLen_I) {
- DEBUG (fprintf (stderr, "dequeue: #a < #len, waiting.\n"));
+ DEBUG (fprintf (stderr, "dequeue: #a < #len, waiting.\n"););
// wait will automatically unlock() the internal mutex
d_readBlock->wait ();
// and lock() it here.
if (d_doAbort) {
d_internal->unlock ();
- DEBUG (fprintf (stderr, "dequeue: #a < #len, aborting.\n"));
+ DEBUG (fprintf (stderr, "dequeue: #a < #len, aborting.\n"););
return (2);
}
- DEBUG (fprintf (stderr, "dequeue: #a < #len, done waiting.\n"));
+ DEBUG (fprintf (stderr, "dequeue: #a < #len, done waiting.\n"););
}
} else {
while (d_n_avail_read_I == 0) {
- DEBUG (fprintf (stderr, "dequeue: #a == 0, waiting.\n"));
+ DEBUG (fprintf (stderr, "dequeue: #a == 0, waiting.\n"););
// wait will automatically unlock() the internal mutex
d_readBlock->wait ();
// and lock() it here.
if (d_doAbort) {
d_internal->unlock ();
- DEBUG (fprintf (stderr, "dequeue: #a == 0, aborting.\n"));
+ DEBUG (fprintf (stderr, "dequeue: #a == 0, aborting.\n"););
return (2);
}
- DEBUG (fprintf (stderr, "dequeue: #a == 0, done waiting.\n"));
+ DEBUG (fprintf (stderr, "dequeue: #a == 0, done waiting.\n"););
}
}
if (l_bufLen_I > d_n_avail_read_I)