Make terminate_threads() less likely to leave _threads containing invalid pointers.
[dcpomatic.git] / src / lib / video_ring_buffers.cc
index a8688a1cd7f6d246562f63e90780cdda72600563..0167f4aec4309c62ba47d1966ee04cba278ced5a 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "video_ring_buffers.h"
 #include "player_video.h"
+#include "compose.hpp"
 #include <boost/foreach.hpp>
 #include <list>
 #include <iostream>
@@ -28,6 +29,7 @@ using std::list;
 using std::make_pair;
 using std::cout;
 using std::pair;
+using std::string;
 using boost::shared_ptr;
 using boost::optional;
 
@@ -71,13 +73,12 @@ VideoRingBuffers::clear ()
        _data.clear ();
 }
 
-optional<DCPTime>
-VideoRingBuffers::earliest () 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.front().second;
+       return make_pair(m, String::compose("%1 frames", _data.size()));
 }