diff options
author | Josh Blum <josh@joshknows.com> | 2010-06-01 17:51:26 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-06-01 17:51:26 -0700 |
commit | 212159ca3bc00d233464cd6f9f454e5ac6e08f88 (patch) | |
tree | 26ba4df4c4e692face9145c6cc1e77fff8056076 /host/lib/transport/vrt_packet_handler.hpp | |
parent | f78cae4911148470f1b5fbf2ff8ea795250419a1 (diff) | |
download | uhd-212159ca3bc00d233464cd6f9f454e5ac6e08f88.tar.gz uhd-212159ca3bc00d233464cd6f9f454e5ac6e08f88.tar.bz2 uhd-212159ca3bc00d233464cd6f9f454e5ac6e08f88.zip |
Implemented pirate thread, moved io impl details into io impl cpp file. Fixed bug in bounded buffer push with pop on full.
Diffstat (limited to 'host/lib/transport/vrt_packet_handler.hpp')
-rw-r--r-- | host/lib/transport/vrt_packet_handler.hpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp index a179731ca..d6b863040 100644 --- a/host/lib/transport/vrt_packet_handler.hpp +++ b/host/lib/transport/vrt_packet_handler.hpp @@ -18,7 +18,6 @@ #ifndef INCLUDED_LIBUHD_TRANSPORT_VRT_PACKET_HANDLER_HPP #define INCLUDED_LIBUHD_TRANSPORT_VRT_PACKET_HANDLER_HPP -#include "vrt_packet_handler_state.hpp" #include <uhd/config.hpp> #include <uhd/device.hpp> #include <uhd/types/io_type.hpp> @@ -37,6 +36,24 @@ namespace vrt_packet_handler{ /*********************************************************************** * vrt packet handler for recv **********************************************************************/ + struct recv_state{ + //init the expected seq number + size_t next_packet_seq; + + //state variables to handle fragments + uhd::transport::managed_recv_buffer::sptr managed_buff; + boost::asio::const_buffer copy_buff; + size_t fragment_offset_in_samps; + + recv_state(void){ + //first expected seq is zero + next_packet_seq = 0; + + //initially empty copy buffer + copy_buff = boost::asio::buffer("", 0); + } + }; + typedef boost::function<uhd::transport::managed_recv_buffer::sptr(void)> get_recv_buff_t; typedef boost::function<void(uhd::transport::managed_recv_buffer::sptr)> recv_cb_t; @@ -106,6 +123,7 @@ namespace vrt_packet_handler{ if (boost::asio::buffer_size(state.copy_buff) == 0){ state.fragment_offset_in_samps = 0; state.managed_buff = get_recv_buff(); + if (state.managed_buff.get() == NULL) return 0; recv_cb(state.managed_buff); //callback before vrt unpack try{ _recv1_helper( @@ -210,6 +228,15 @@ namespace vrt_packet_handler{ /*********************************************************************** * vrt packet handler for send **********************************************************************/ + struct send_state{ + //init the expected seq number + size_t next_packet_seq; + + send_state(void){ + next_packet_seq = 0; + } + }; + typedef boost::function<uhd::transport::managed_send_buffer::sptr(void)> get_send_buff_t; typedef boost::function<void(uhd::transport::managed_send_buffer::sptr)> send_cb_t; |