Hopefully better errors on large video/audio disagreements.
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Apr 2019 00:34:03 +0000 (00:34 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Apr 2019 00:34:03 +0000 (00:34 +0000)
src/lib/audio_ring_buffers.cc
src/lib/audio_ring_buffers.h
src/lib/butler.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.
 
 
     This file is part of DCP-o-matic.
 
@@ -103,6 +103,16 @@ AudioRingBuffers::get (float* out, int channels, int frames)
        return time;
 }
 
        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 ()
 {
 void
 AudioRingBuffers::clear ()
 {
index ce0efd3e2c585569ccdc7f127618a69700083dde..8d830ecf78046f77e39012f1877f0bf0391968e6 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2016-2017 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -35,6 +35,7 @@ public:
 
        void put (boost::shared_ptr<const AudioBuffers> data, DCPTime time, int frame_rate);
        boost::optional<DCPTime> get (float* out, int channels, int frames);
 
        void put (boost::shared_ptr<const AudioBuffers> data, DCPTime time, int frame_rate);
        boost::optional<DCPTime> get (float* out, int channels, int frames);
+       boost::optional<DCPTime> peek () const;
 
        void clear ();
        Frame size () const;
 
        void clear ();
        Frame size () const;
index e15cb9d3f6266f80dffc5223edfa020617e8c721..11ee033e99ad9705c5e86ff04306abfcf04034bf 100644 (file)
@@ -124,14 +124,26 @@ Butler::should_run () const
 {
        if (_video.size() >= MAXIMUM_VIDEO_READAHEAD * 10) {
                /* This is way too big */
 {
        if (_video.size() >= MAXIMUM_VIDEO_READAHEAD * 10) {
                /* This is way too big */
-               throw ProgrammingError
-                       (__FILE__, __LINE__, String::compose ("Butler video buffers reached %1 frames (audio is %2)", _video.size(), _audio.size()));
+               optional<DCPTime> pos = _audio.peek();
+               if (pos) {
+                       throw ProgrammingError
+                               (__FILE__, __LINE__, String::compose ("Butler video buffers reached %1 frames (audio is %2 at %3)", _video.size(), _audio.size(), pos->get()));
+               } else {
+                       throw ProgrammingError
+                               (__FILE__, __LINE__, String::compose ("Butler video buffers reached %1 frames (audio is %2)", _video.size(), _audio.size()));
+               }
        }
 
        if (_audio.size() >= MAXIMUM_AUDIO_READAHEAD * 10) {
                /* This is way too big */
        }
 
        if (_audio.size() >= MAXIMUM_AUDIO_READAHEAD * 10) {
                /* This is way too big */
-               throw ProgrammingError
-                       (__FILE__, __LINE__, String::compose ("Butler audio buffers reached %1 frames (video is %2)", _audio.size(), _video.size()));
+               optional<DCPTime> pos = _audio.peek();
+               if (pos) {
+                       throw ProgrammingError
+                               (__FILE__, __LINE__, String::compose ("Butler audio buffers reached %1 frames at %2 (video is %3)", _audio.size(), pos->get(), _video.size()));
+               } else {
+                       throw ProgrammingError
+                               (__FILE__, __LINE__, String::compose ("Butler audio buffers reached %1 frames (video is %3)", _audio.size(), _video.size()));
+               }
        }
 
        if (_video.size() >= MAXIMUM_VIDEO_READAHEAD * 2) {
        }
 
        if (_video.size() >= MAXIMUM_VIDEO_READAHEAD * 2) {