diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-07 22:15:01 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-07 22:15:01 +0200 |
| commit | 7bc2134d658778e04f1756c255e604b4ab5a5831 (patch) | |
| tree | b5ba51f2534604a6528fbbb130fd0cfca7d6fb70 /src/lib/video_ring_buffers.cc | |
| parent | a771a806291243760552988a1a7a5742bc007ee2 (diff) | |
Assorted C++11/formatting cleanups.
Diffstat (limited to 'src/lib/video_ring_buffers.cc')
| -rw-r--r-- | src/lib/video_ring_buffers.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/lib/video_ring_buffers.cc b/src/lib/video_ring_buffers.cc index 8c73aba25..63c52ee06 100644 --- a/src/lib/video_ring_buffers.cc +++ b/src/lib/video_ring_buffers.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,12 +18,14 @@ */ + #include "video_ring_buffers.h" #include "player_video.h" #include "compose.hpp" #include <list> #include <iostream> + using std::list; using std::make_pair; using std::cout; @@ -33,25 +35,28 @@ using std::shared_ptr; using boost::optional; using namespace dcpomatic; + void VideoRingBuffers::put (shared_ptr<PlayerVideo> frame, DCPTime time) { boost::mutex::scoped_lock lm (_mutex); - _data.push_back (make_pair (frame, time)); + _data.push_back (make_pair(frame, time)); } + pair<shared_ptr<PlayerVideo>, DCPTime> VideoRingBuffers::get () { boost::mutex::scoped_lock lm (_mutex); if (_data.empty ()) { - return make_pair(shared_ptr<PlayerVideo>(), DCPTime()); + return {}; } - pair<shared_ptr<PlayerVideo>, DCPTime> const r = _data.front (); + auto const r = _data.front(); _data.pop_front (); return r; } + Frame VideoRingBuffers::size () const { @@ -59,6 +64,7 @@ VideoRingBuffers::size () const return _data.size (); } + bool VideoRingBuffers::empty () const { @@ -66,6 +72,7 @@ VideoRingBuffers::empty () const return _data.empty (); } + void VideoRingBuffers::clear () { @@ -73,13 +80,14 @@ VideoRingBuffers::clear () _data.clear (); } + pair<size_t, string> VideoRingBuffers::memory_used () const { boost::mutex::scoped_lock lm (_mutex); size_t m = 0; - for (list<pair<shared_ptr<PlayerVideo>, DCPTime> >::const_iterator i = _data.begin(); i != _data.end(); ++i) { - m += i->first->memory_used(); + for (auto const& i: _data) { + m += i.first->memory_used(); } return make_pair(m, String::compose("%1 frames", _data.size())); } @@ -89,8 +97,8 @@ void VideoRingBuffers::reset_metadata (shared_ptr<const Film> film, dcp::Size player_video_container_size) { boost::mutex::scoped_lock lm (_mutex); - for (list<pair<shared_ptr<PlayerVideo>, DCPTime> >::const_iterator i = _data.begin(); i != _data.end(); ++i) { - i->first->reset_metadata (film, player_video_container_size); + for (auto const& i: _data) { + i.first->reset_metadata (film, player_video_container_size); } } |
