summaryrefslogtreecommitdiff
path: root/usrp/host/lib/legacy/circular_buffer.h
diff options
context:
space:
mode:
authormichaelld2007-08-17 03:23:02 +0000
committermichaelld2007-08-17 03:23:02 +0000
commitc6e9cb1d8f59873d0dd26458062fd0d01ec69b23 (patch)
tree94128b629470685d83a553fa95f42348279de845 /usrp/host/lib/legacy/circular_buffer.h
parentd5d0ca37f209d85298f46fa730abed5fa671174f (diff)
downloadgnuradio-c6e9cb1d8f59873d0dd26458062fd0d01ec69b23.tar.gz
gnuradio-c6e9cb1d8f59873d0dd26458062fd0d01ec69b23.tar.bz2
gnuradio-c6e9cb1d8f59873d0dd26458062fd0d01ec69b23.zip
Updated USRP's circular_buffer with the same corrections as for
gr-audio-osx. These corrections impact OSX/Darwin only. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6146 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'usrp/host/lib/legacy/circular_buffer.h')
-rw-r--r--usrp/host/lib/legacy/circular_buffer.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/usrp/host/lib/legacy/circular_buffer.h b/usrp/host/lib/legacy/circular_buffer.h
index 3025d7b50..4b5e7ba35 100644
--- a/usrp/host/lib/legacy/circular_buffer.h
+++ b/usrp/host/lib/legacy/circular_buffer.h
@@ -138,8 +138,9 @@ public:
int enqueue (T* buf, UInt32 bufLen_I) {
#if DO_DEBUG
- fprintf (stderr, "enqueue: buf = %X, bufLen = %ld.\n",
- (unsigned int)buf, bufLen_I);
+ 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);
#endif
if (bufLen_I > d_bufLen_I) {
fprintf (stderr, "cannot add buffer longer (%ld"
@@ -158,6 +159,8 @@ public:
d_internal->unlock ();
return (2);
}
+ // set the return value to 1: success; change if needed
+ int retval = 1;
if (bufLen_I > d_n_avail_write_I) {
if (d_doWriteBlock) {
while (bufLen_I > d_n_avail_write_I) {
@@ -184,7 +187,7 @@ public:
#if DO_DEBUG
fprintf (stderr, "circular_buffer::enqueue: overflow\n");
#endif
- return (-1);
+ retval = -1;
}
}
UInt32 n_now_I = d_bufLen_I - d_writeNdx_I, n_start_I = 0;
@@ -202,7 +205,7 @@ public:
d_n_avail_write_I -= bufLen_I;
d_readBlock->signal ();
d_internal->unlock ();
- return (1);
+ return (retval);
};
/*
@@ -226,11 +229,11 @@ public:
* buffer length is larger than the instantiated buffer length
*/
-
int dequeue (T* buf, UInt32* bufLen_I) {
#if DO_DEBUG
- fprintf (stderr, "dequeue: buf = %X, *bufLen = %ld.\n",
- (unsigned int)buf, *bufLen_I);
+ 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);
#endif
if (!bufLen_I)
throw std::runtime_error ("circular_buffer::dequeue(): "