Revision 0fc64104 host/lib/transport/libusb1_zero_copy.cpp
| b/host/lib/transport/libusb1_zero_copy.cpp | ||
|---|---|---|
| 18 | 18 |
#include "libusb1_base.hpp" |
| 19 | 19 |
#include <uhd/transport/usb_zero_copy.hpp> |
| 20 | 20 |
#include <uhd/transport/bounded_buffer.hpp> |
| 21 |
#include <uhd/utils/thread_priority.hpp> |
|
| 21 | 22 |
#include <uhd/utils/assert.hpp> |
| 22 | 23 |
#include <boost/shared_array.hpp> |
| 23 | 24 |
#include <boost/foreach.hpp> |
| ... | ... | |
| 290 | 291 |
const device_addr_t &hints |
| 291 | 292 |
); |
| 292 | 293 |
|
| 294 |
~libusb_zero_copy_impl(void){
|
|
| 295 |
_threads_running = false; |
|
| 296 |
_thread_group.join_all(); |
|
| 297 |
} |
|
| 298 |
|
|
| 293 | 299 |
managed_recv_buffer::sptr get_recv_buff(double); |
| 294 | 300 |
managed_send_buffer::sptr get_send_buff(double); |
| 295 | 301 |
|
| ... | ... | |
| 318 | 324 |
const size_t _recv_frame_size, _num_recv_frames; |
| 319 | 325 |
const size_t _send_frame_size, _num_send_frames; |
| 320 | 326 |
usb_endpoint::sptr _recv_ep, _send_ep; |
| 327 |
|
|
| 328 |
//event handler threads |
|
| 329 |
boost::thread_group _thread_group; |
|
| 330 |
bool _threads_running; |
|
| 331 |
|
|
| 332 |
void run_event_loop(void){
|
|
| 333 |
set_thread_priority_safe(); |
|
| 334 |
libusb::session::sptr session = libusb::session::get_global_session(); |
|
| 335 |
_threads_running = true; |
|
| 336 |
while(_threads_running){
|
|
| 337 |
timeval tv; |
|
| 338 |
tv.tv_sec = 0; |
|
| 339 |
tv.tv_usec = 100000; //100ms |
|
| 340 |
libusb_handle_events_timeout(session->get_context(), &tv); |
|
| 341 |
} |
|
| 342 |
} |
|
| 321 | 343 |
}; |
| 322 | 344 |
|
| 323 | 345 |
/* |
| ... | ... | |
| 355 | 377 |
this->get_send_frame_size(), // buffer size per transfer |
| 356 | 378 |
this->get_num_send_frames() // number of libusb transfers |
| 357 | 379 |
)); |
| 380 |
|
|
| 381 |
//spawn the event handler threads |
|
| 382 |
size_t concurrency = hints.cast<size_t>("concurrency_hint", 1);
|
|
| 383 |
for (size_t i = 0; i < concurrency; i++) _thread_group.create_thread( |
|
| 384 |
boost::bind(&libusb_zero_copy_impl::run_event_loop, this) |
|
| 385 |
); |
|
| 358 | 386 |
} |
| 359 | 387 |
|
| 360 | 388 |
/* |
Also available in: Unified diff