Make terminate_threads() less likely to leave _threads containing invalid pointers.
[dcpomatic.git] / src / lib / audio_ring_buffers.cc
index 21c4b6a5c1084123c71d82706653615e96aab709..d1375cb27e2eeeb80d3a2935a06a10cb3aee9b87 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.
 
@@ -103,6 +103,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 ()
 {