summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/block_allocator.cpp14
-rw-r--r--lib/block_task.cpp14
-rw-r--r--lib/element_impl.hpp6
-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
-rw-r--r--lib/port_handlers.cpp4
7 files changed, 47 insertions, 36 deletions
diff --git a/lib/block_allocator.cpp b/lib/block_allocator.cpp
index f5e632f..f69cd54 100644
--- a/lib/block_allocator.cpp
+++ b/lib/block_allocator.cpp
@@ -22,8 +22,12 @@ using namespace gnuradio;
//TODO will need more complicated later
-void ElementImpl::buffer_returner(const size_t index, tsbe::Buffer &buffer)
+void ElementImpl::buffer_returner(const size_t index, SBuffer &buffer)
{
+ //reset offset and length
+ buffer.offset = 0;
+ buffer.length = buffer.get_actual_length();
+
BufferReturnMessage message;
message.index = index;
message.buffer = buffer;
@@ -43,16 +47,16 @@ void ElementImpl::handle_allocation(const tsbe::TaskInterface &task_iface)
const size_t bytes = items * this->output_items_sizes[i];
- tsbe::BufferDeleter deleter = boost::bind(&ElementImpl::buffer_returner, this, i, _1);
- this->output_buffer_tokens[i] = tsbe::BufferToken(new tsbe::BufferDeleter(deleter));
+ SBufferDeleter deleter = boost::bind(&ElementImpl::buffer_returner, this, i, _1);
+ this->output_buffer_tokens[i] = SBufferToken(new SBufferDeleter(deleter));
for (size_t j = 0; j < 8; j++)
{
- tsbe::BufferConfig config;
+ SBufferConfig config;
config.memory = NULL;
config.length = bytes;
config.token = this->output_buffer_tokens[i];
- tsbe::Buffer buff(config);
+ SBuffer buff(config);
//buffer derefs here and the token messages it back to the block
}
}
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index c68ebee..7855619 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -31,8 +31,8 @@ void ElementImpl::mark_done(const tsbe::TaskInterface &task_iface)
{
if (this->output_bytes_offset[i] == 0) continue;
ASSERT(this->output_queues.ready(i));
- tsbe::Buffer &buff = this->output_queues.front(i);
- buff.get_length() = this->output_bytes_offset[i];
+ SBuffer &buff = this->output_queues.front(i);
+ buff.length = this->output_bytes_offset[i];
task_iface.post_downstream(i, buff);
this->output_queues.pop(i);
this->output_bytes_offset[i] = 0;
@@ -133,9 +133,9 @@ void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface)
output_tokens_count += this->output_tokens[i].use_count();
ASSERT(this->output_queues.ready(i));
- const tsbe::Buffer &buff = this->output_queues.front(i);
- char *mem = ((char *)buff.get_memory()) + this->output_bytes_offset[i];
- const size_t bytes = buff.get_length() - this->output_bytes_offset[i];
+ const SBuffer &buff = this->output_queues.front(i);
+ char *mem = ((char *)buff.get()) + this->output_bytes_offset[i];
+ const size_t bytes = buff.length - this->output_bytes_offset[i];
const size_t items = bytes/this->output_items_sizes[i];
this->work_io_ptr_mask |= ptrdiff_t(mem);
@@ -223,8 +223,8 @@ void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface)
//and then call work again on the real input buffer, but still yield one output buffer per input buffer.
if (input_allows_flush)
{
- tsbe::Buffer &buff = this->output_queues.front(i);
- buff.get_length() = this->output_bytes_offset[i];
+ SBuffer &buff = this->output_queues.front(i);
+ buff.length = this->output_bytes_offset[i];
task_iface.post_downstream(i, buff);
this->output_queues.pop(i);
this->output_bytes_offset[i] = 0;
diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp
index 6a9c088..250e640 100644
--- a/lib/element_impl.hpp
+++ b/lib/element_impl.hpp
@@ -80,11 +80,11 @@ struct ElementImpl
std::vector<Token> output_tokens;
std::set<Token> token_pool;
- std::vector<tsbe::BufferToken> output_buffer_tokens;
+ std::vector<SBufferToken> output_buffer_tokens;
//buffer queues and ready conditions
InputBufferQueues input_queues;
- VectorOfQueues<tsbe::Buffer> output_queues;
+ VectorOfQueues<SBuffer> output_queues;
std::vector<size_t> output_bytes_offset;
//tag tracking
@@ -115,7 +115,7 @@ struct ElementImpl
void handle_task(const tsbe::TaskInterface &);
void mark_done(const tsbe::TaskInterface &);
void conclusion(const tsbe::TaskInterface &task_iface, const bool);
- void buffer_returner(const size_t index, tsbe::Buffer &buffer);
+ void buffer_returner(const size_t index, SBuffer &buffer);
//is the fg running?
enum
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;
};
diff --git a/lib/port_handlers.cpp b/lib/port_handlers.cpp
index 9ec805d..5777cf9 100644
--- a/lib/port_handlers.cpp
+++ b/lib/port_handlers.cpp
@@ -26,10 +26,10 @@ void ElementImpl::handle_input_msg(
if (MESSAGE) std::cout << "handle_input_msg (" << msg.type().name() << ") " << name << std::endl;
//handle incoming stream buffer, push into the queue
- if (msg.type() == typeid(tsbe::Buffer))
+ if (msg.type() == typeid(SBuffer))
{
if (this->block_state == BLOCK_STATE_DONE) return;
- this->input_queues.push(index, msg.cast<tsbe::Buffer>());
+ this->input_queues.push(index, msg.cast<SBuffer>());
this->handle_task(handle);
return;
}