Add Piece::reference_dcp_audio().
authorCarl Hetherington <cth@carlh.net>
Fri, 23 Apr 2021 23:16:51 +0000 (01:16 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 May 2021 07:29:59 +0000 (09:29 +0200)
src/lib/piece.cc
src/lib/piece.h
src/lib/player.cc

index 0dad2517830209863d65c553d53d5331036870c1..0e5fd0259d8549ad3a9a6b1c97775f35df9d1052 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "audio_content.h"
 #include "content.h"
+#include "dcp_content.h"
 #include "dcpomatic_log.h"
 #include "decoder.h"
 #include "film.h"
@@ -29,8 +30,9 @@
 #include "video_content.h"
 
 
-using std::shared_ptr;
+using std::dynamic_pointer_cast;
 using std::make_shared;
+using std::shared_ptr;
 using namespace dcpomatic;
 
 
@@ -200,3 +202,10 @@ Piece::pass ()
        done = decoder->pass();
 }
 
+
+bool
+Piece::reference_dcp_audio () const
+{
+       auto dcp = dynamic_pointer_cast<DCPContent>(content);
+       return dcp && dcp->reference_audio();
+}
index 7379a5c3f76091fb24cdb7a02e7145323b49ebfa..5b80a7fff2060cd1f6bb1de480464231da4e0948 100644 (file)
@@ -65,6 +65,7 @@ public:
 
        int resampled_audio_frame_rate (std::shared_ptr<const Film> film) const;
        double audio_gain () const;
+       bool reference_dcp_audio () const;
 
        std::shared_ptr<Decoder> decoder_for (std::shared_ptr<Content> content) const;
 
index c9526411cf26c3c08c892afb355eb5c0c4d13639..086cfbbbd7b259d447a5e68d01abe364b5b8d8c6 100644 (file)
@@ -627,13 +627,12 @@ Player::pass ()
        case CONTENT:
        {
                earliest_content->pass();
-               auto dcp = dynamic_pointer_cast<DCPContent>(earliest_content->content);
-               if (dcp && !_play_referenced && dcp->reference_audio()) {
+               if (!_play_referenced && earliest_content->reference_dcp_audio()) {
                        /* We are skipping some referenced DCP audio content, so we need to update _last_audio_time
                           to `hide' the fact that no audio was emitted during the referenced DCP (though
                           we need to behave as though it was).
                        */
-                       _last_audio_time = dcp->end (_film);
+                       _last_audio_time = earliest_content->end (_film);
                }
                break;
        }