std::shared_ptr
[dcpomatic.git] / src / lib / audio_ring_buffers.cc
index 21c4b6a5c1084123c71d82706653615e96aab709..c0559f61c5b11283ef3e67f22ffcaea33c7f0a97 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -29,8 +29,9 @@ using std::cout;
 using std::make_pair;
 using std::pair;
 using std::list;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
+using namespace dcpomatic;
 
 AudioRingBuffers::AudioRingBuffers ()
        : _used_in_head (0)
@@ -103,6 +104,16 @@ AudioRingBuffers::get (float* out, int channels, int frames)
        return time;
 }
 
+optional<DCPTime>
+AudioRingBuffers::peek () const
+{
+       boost::mutex::scoped_lock lm (_mutex);
+       if (_buffers.empty()) {
+               return optional<DCPTime>();
+       }
+       return _buffers.front().second;
+}
+
 void
 AudioRingBuffers::clear ()
 {