diff options
-rw-r--r-- | usrp/host/lib/legacy/circular_buffer.h | 17 |
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(): " |