summaryrefslogtreecommitdiff
path: root/lib/gras_impl
diff options
context:
space:
mode:
authorJosh Blum2012-09-10 02:00:31 -0700
committerJosh Blum2012-09-10 02:00:31 -0700
commit4adb2a384bb06406ffaf3ca4f5a33e42f8a74491 (patch)
tree2e3839e3acc7792f3bb691e864245fdf31dbcac7 /lib/gras_impl
parent01a9ef2060e34b7cb6e8863e39854c5a0ae80b58 (diff)
downloadsandhi-4adb2a384bb06406ffaf3ca4f5a33e42f8a74491.tar.gz
sandhi-4adb2a384bb06406ffaf3ca4f5a33e42f8a74491.tar.bz2
sandhi-4adb2a384bb06406ffaf3ca4f5a33e42f8a74491.zip
switch to using sbuffer in gras impl
Diffstat (limited to 'lib/gras_impl')
-rw-r--r--lib/gras_impl/buffer_queue.hpp21
-rw-r--r--lib/gras_impl/input_buffer_queues.hpp20
-rw-r--r--lib/gras_impl/misc.hpp4
3 files changed, 26 insertions, 19 deletions
diff --git a/lib/gras_impl/buffer_queue.hpp b/lib/gras_impl/buffer_queue.hpp
index 5fd1661..306b369 100644
--- a/lib/gras_impl/buffer_queue.hpp
+++ b/lib/gras_impl/buffer_queue.hpp
@@ -17,19 +17,26 @@
#ifndef INCLUDED_LIBGRAS_IMPL_BUFFER_QUEUE_HPP
#define INCLUDED_LIBGRAS_IMPL_BUFFER_QUEUE_HPP
-#include <tsbe/buffer.hpp>
+#include <gnuradio/sbuffer.hpp>
#include <boost/bind.hpp>
#include <queue>
namespace gnuradio
{
-struct BufferQueue : std::queue<tsbe::Buffer>
+struct BufferQueue : std::queue<SBuffer>
{
+ void __push(SBuffer &buffer)
+ {
+ buffer.offset = 0;
+ buffer.length = buffer.get_actual_length();
+ this->push(buffer);
+ }
+
BufferQueue(void)
{
- tsbe::BufferDeleter deleter = boost::bind(&BufferQueue::push, this, _1);
- _token = tsbe::BufferToken(new tsbe::BufferDeleter(deleter));
+ SBufferDeleter deleter = boost::bind(&BufferQueue::__push, this, _1);
+ _token = SBufferToken(new SBufferDeleter(deleter));
}
~BufferQueue(void)
@@ -43,15 +50,15 @@ struct BufferQueue : std::queue<tsbe::Buffer>
void allocate_one(const size_t num_bytes)
{
- tsbe::BufferConfig config;
+ SBufferConfig config;
config.memory = NULL;
config.length = num_bytes;
config.token = _token;
- tsbe::Buffer buff(config);
+ SBuffer buff(config);
//buffer derefs here and the token messages it back to the queue
}
- tsbe::BufferToken _token;
+ SBufferToken _token;
};
} //namespace gnuradio
diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp
index 2066809..ccce8ad 100644
--- a/lib/gras_impl/input_buffer_queues.hpp
+++ b/lib/gras_impl/input_buffer_queues.hpp
@@ -19,7 +19,7 @@
#include <gras_impl/debug.hpp>
#include <gras_impl/buffer_queue.hpp>
-#include <tsbe/buffer.hpp>
+#include <gnuradio/sbuffer.hpp>
#include <boost/dynamic_bitset.hpp>
#include <vector>
#include <queue>
@@ -32,22 +32,22 @@ namespace gnuradio
struct BufferWOffset
{
BufferWOffset(void): offset(0), length(0){}
- BufferWOffset(const tsbe::Buffer &buffer):
- offset(0), length(buffer.get_length()), buffer(buffer){}
+ BufferWOffset(const SBuffer &buffer):
+ offset(0), length(buffer.length), buffer(buffer){}
inline char *mem_offset(void) const
{
- return ((char *)buffer.get_memory()) + offset;
+ return ((char *)buffer.get()) + offset;
}
inline size_t tail_free(void) const
{
- return buffer.get_length() - offset - length;
+ return buffer.length - offset - length;
}
size_t offset;
size_t length;
- tsbe::Buffer buffer;
+ SBuffer buffer;
};
struct BuffInfo
@@ -97,7 +97,7 @@ struct InputBufferQueues
void resize(const size_t size);
- inline void push(const size_t i, const tsbe::Buffer &buffer)
+ inline void push(const size_t i, const SBuffer &buffer)
{
_queues[i].push_back(buffer);
_enqueued_bytes[i] += _queues[i].back().length;
@@ -198,11 +198,11 @@ inline void InputBufferQueues::init(
//there is history, so enqueue some initial history
if (_history_bytes[i] != 0)
{
- tsbe::Buffer buff = _aux_queues[i]->front();
+ SBuffer buff = _aux_queues[i]->front();
_aux_queues[i]->pop();
const size_t hist_bytes = _history_bytes[i];
- std::memset(buff.get_memory(), 0, hist_bytes);
+ std::memset(buff.get(), 0, hist_bytes);
_queues[i].push_front(buff);
_queues[i].front().offset = hist_bytes;
_queues[i].front().length = 0;
@@ -242,7 +242,7 @@ inline void InputBufferQueues::__prepare(const size_t i)
//do we need a new buffer:
//- is the buffer unique (queue has only reference)?
//- can its remaining space meet reserve requirements?
- const bool enough_space = front.buffer.get_length() >= _reserve_bytes[i] + front.offset;
+ const bool enough_space = front.buffer.length >= _reserve_bytes[i] + front.offset;
if (enough_space and front.buffer.unique())
{
dst = _queues[i].front();
diff --git a/lib/gras_impl/misc.hpp b/lib/gras_impl/misc.hpp
index e988480..124ed51 100644
--- a/lib/gras_impl/misc.hpp
+++ b/lib/gras_impl/misc.hpp
@@ -17,7 +17,7 @@
#ifndef INCLUDED_LIBGRAS_IMPL_MISC_HPP
#define INCLUDED_LIBGRAS_IMPL_MISC_HPP
-#include <tsbe/buffer.hpp>
+#include <gnuradio/sbuffer.hpp>
#include <boost/shared_ptr.hpp>
static inline unsigned long myulround(const double x)
@@ -70,7 +70,7 @@ struct SelfKickMessage
struct BufferReturnMessage
{
size_t index;
- tsbe::Buffer buffer;
+ SBuffer buffer;
};