projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Barely-functioning GL playback with new arrangement.
[dcpomatic.git]
/
src
/
lib
/
video_ring_buffers.cc
diff --git
a/src/lib/video_ring_buffers.cc
b/src/lib/video_ring_buffers.cc
index 254285456ebc4253d125111df1d5e9e45bdd4da9..bfec507ea4f84a5b22e82271e5966e33e9771e2a 100644
(file)
--- a/
src/lib/video_ring_buffers.cc
+++ b/
src/lib/video_ring_buffers.cc
@@
-20,6
+20,7
@@
#include "video_ring_buffers.h"
#include "player_video.h"
#include "video_ring_buffers.h"
#include "player_video.h"
+#include "compose.hpp"
#include <boost/foreach.hpp>
#include <list>
#include <iostream>
#include <boost/foreach.hpp>
#include <list>
#include <iostream>
@@
-28,13
+29,14
@@
using std::list;
using std::make_pair;
using std::cout;
using std::pair;
using std::make_pair;
using std::cout;
using std::pair;
+using std::string;
using boost::shared_ptr;
using boost::optional;
using boost::shared_ptr;
using boost::optional;
+using namespace dcpomatic;
void
VideoRingBuffers::put (shared_ptr<PlayerVideo> frame, DCPTime time)
{
void
VideoRingBuffers::put (shared_ptr<PlayerVideo> frame, DCPTime time)
{
- cout << "put " << to_string(time) << "\n";
boost::mutex::scoped_lock lm (_mutex);
_data.push_back (make_pair (frame, time));
}
boost::mutex::scoped_lock lm (_mutex);
_data.push_back (make_pair (frame, time));
}
@@
-44,11
+46,9
@@
VideoRingBuffers::get ()
{
boost::mutex::scoped_lock lm (_mutex);
if (_data.empty ()) {
{
boost::mutex::scoped_lock lm (_mutex);
if (_data.empty ()) {
- cout << "get: no data.\n";
return make_pair(shared_ptr<PlayerVideo>(), DCPTime());
}
pair<shared_ptr<PlayerVideo>, DCPTime> const r = _data.front ();
return make_pair(shared_ptr<PlayerVideo>(), DCPTime());
}
pair<shared_ptr<PlayerVideo>, DCPTime> const r = _data.front ();
- cout << "get: here we go! " << to_string(r.second) << "\n";
_data.pop_front ();
return r;
}
_data.pop_front ();
return r;
}
@@
-60,6
+60,13
@@
VideoRingBuffers::size () const
return _data.size ();
}
return _data.size ();
}
+bool
+VideoRingBuffers::empty () const
+{
+ boost::mutex::scoped_lock lm (_mutex);
+ return _data.empty ();
+}
+
void
VideoRingBuffers::clear ()
{
void
VideoRingBuffers::clear ()
{
@@
-67,13
+74,12
@@
VideoRingBuffers::clear ()
_data.clear ();
}
_data.clear ();
}
-
optional<DCPTime
>
-VideoRingBuffers::
latest
() const
+
pair<size_t, string
>
+VideoRingBuffers::
memory_used
() const
{
{
-
boost::mutex::scoped_lock lm (_mutex)
;
-
if (_data.empty ()
) {
-
return optional<DCPTime>
();
+
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
();
}
}
-
- return _data.back().second;
+ return make_pair(m, String::compose("%1 frames", _data.size()));
}
}