common: Switch frame storage type from vector to deque

Deque seems more logical (and faster) since elements are
pushed back and taken from the front.
This commit is contained in:
Joni Räsänen 2022-09-12 16:14:22 +03:00
parent 3cd1a0fdaf
commit 5c666b1720
2 changed files with 3 additions and 2 deletions

View File

@ -178,7 +178,7 @@ uvgrtp::frame::rtp_frame *uvgrtp::reception_flow::pull_frame(ssize_t timeout_ms)
frames_mtx_.lock(); frames_mtx_.lock();
auto frame = frames_.front(); auto frame = frames_.front();
frames_.erase(frames_.begin()); frames_.pop_front();
frames_mtx_.unlock(); frames_mtx_.unlock();
return frame; return frame;

View File

@ -10,6 +10,7 @@
#include <thread> #include <thread>
#include <condition_variable> #include <condition_variable>
#include <atomic> #include <atomic>
#include <deque>
namespace uvgrtp { namespace uvgrtp {
@ -175,7 +176,7 @@ namespace uvgrtp {
/* If receive hook has not been installed, frames are pushed to "frames_" /* If receive hook has not been installed, frames are pushed to "frames_"
* and they can be retrieved using pull_frame() */ * and they can be retrieved using pull_frame() */
std::vector<uvgrtp::frame::rtp_frame *> frames_; std::deque<uvgrtp::frame::rtp_frame *> frames_;
std::mutex frames_mtx_; std::mutex frames_mtx_;
void *recv_hook_arg_; void *recv_hook_arg_;