Don't bother with audio in the film viewer.
authorCarl Hetherington <cth@carlh.net>
Fri, 4 Sep 2015 22:14:46 +0000 (23:14 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 4 Sep 2015 23:25:14 +0000 (00:25 +0100)
src/lib/audio_decoder.cc
src/lib/audio_decoder.h
src/lib/player.cc
src/lib/player.h
src/wx/film_viewer.cc

index a65e5f7594eaf804bcd6b140293ac303e8dcead0..268a9d29629cfa7b108f3c6853e568fefd1e69ab 100644 (file)
@@ -32,6 +32,7 @@ using boost::shared_ptr;
 
 AudioDecoder::AudioDecoder (shared_ptr<const AudioContent> content)
        : _audio_content (content)
+       , _ignore_audio (false)
 {
        BOOST_FOREACH (AudioStreamPtr i, content->audio_streams ()) {
                _streams[i] = shared_ptr<AudioDecoderStream> (new AudioDecoderStream (_audio_content, i, this));
@@ -47,6 +48,10 @@ AudioDecoder::get_audio (AudioStreamPtr stream, Frame frame, Frame length, bool
 void
 AudioDecoder::audio (AudioStreamPtr stream, shared_ptr<const AudioBuffers> data, ContentTime time)
 {
+       if (_ignore_audio) {
+               return;
+       }
+
        if (_streams.find (stream) == _streams.end ()) {
 
                /* This method can be called with an unknown stream during the following sequence:
@@ -88,3 +93,10 @@ AudioDecoder::seek (ContentTime t, bool accurate)
                i->second->seek (t, accurate);
        }
 }
+
+/** Set this player never to produce any audio data */
+void
+AudioDecoder::set_ignore_audio ()
+{
+       _ignore_audio = true;
+}
index 6cdaeeecf69dcd317d8ce739196c087596c20444..d5e7c6f551584b7f6547e4318b84c79ea04dc54e 100644 (file)
@@ -53,6 +53,8 @@ public:
         */
        ContentAudio get_audio (AudioStreamPtr stream, Frame time, Frame length, bool accurate);
 
+       void set_ignore_audio ();
+
 protected:
        void audio (AudioStreamPtr stream, boost::shared_ptr<const AudioBuffers>, ContentTime);
        void flush ();
@@ -62,6 +64,7 @@ private:
        boost::shared_ptr<const AudioContent> _audio_content;
        /** An AudioDecoderStream object to manage each stream in _audio_content */
        std::map<AudioStreamPtr, boost::shared_ptr<AudioDecoderStream> > _streams;
+       bool _ignore_audio;
 };
 
 #endif
index caa2791b8d573c3c2ad32efae0e9cd4239b56eb9..5e1fbcc632f96c90b14324bd59dc7101175d3460 100644 (file)
@@ -74,6 +74,7 @@ Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist
        , _playlist (playlist)
        , _have_valid_pieces (false)
        , _ignore_video (false)
+       , _ignore_audio (false)
        , _always_burn_subtitles (false)
 {
        _film_changed_connection = _film->Changed.connect (bind (&Player::film_changed, this, _1));
@@ -180,6 +181,11 @@ Player::setup_pieces ()
                        vd->set_ignore_video ();
                }
 
+               shared_ptr<AudioDecoder> ad = dynamic_pointer_cast<AudioDecoder> (decoder);
+               if (ad && _ignore_audio) {
+                       ad->set_ignore_audio ();
+               }
+
                _pieces.push_back (shared_ptr<Piece> (new Piece (i, decoder, frc.get ())));
        }
 
@@ -652,6 +658,13 @@ Player::set_ignore_video ()
        _ignore_video = true;
 }
 
+/** Set this player never to produce any audio data */
+void
+Player::set_ignore_audio ()
+{
+       _ignore_audio = true;
+}
+
 /** Set whether or not this player should always burn text subtitles into the image,
  *  regardless of the content settings.
  *  @param burn true to always burn subtitles, false to obey content settings.
index 061388c4489b6354463edf3fb8e17c6878e2caa2..0a2117470a8570a5be67353bc583de9fbcd1c054 100644 (file)
@@ -49,6 +49,7 @@ public:
 
        void set_video_container_size (dcp::Size);
        void set_ignore_video ();
+       void set_ignore_audio ();
        void set_enable_subtitles (bool enable);
        void set_always_burn_subtitles (bool burn);
 
@@ -117,6 +118,8 @@ private:
 
        /** true if the player should ignore all video; i.e. never produce any */
        bool _ignore_video;
+       /** true if the player should ignore all audio; i.e. never produce any */
+       bool _ignore_audio;
        /** true if the player should always burn subtitles into the video regardless
            of content settings
        */
index 020d57ce3c4c5a6bc91369932c3f6598cf9e1749..3f4bc6514048143df7f464280b3926d6ec9d4b5c 100644 (file)
@@ -149,6 +149,7 @@ FilmViewer::set_film (shared_ptr<Film> film)
           in the preview.
        */
        _player->set_always_burn_subtitles (true);
+       _player->set_ignore_audio ();
 
        _film_connection = _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1));