Remove template from TimedAudioBuffers; a couple of small fixes.
authorCarl Hetherington <cth@carlh.net>
Fri, 7 Mar 2014 19:07:35 +0000 (19:07 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 Mar 2014 19:07:35 +0000 (19:07 +0000)
src/lib/audio_merger.cc
src/lib/audio_merger.h
src/lib/decoded.h
src/lib/ffmpeg_examiner.cc
src/lib/player.cc
src/lib/subrip_content.cc
src/lib/types.h
src/lib/video_content.cc
test/audio_merger_test.cc

index d50420c31d5343dcabe0b25eb13b8b704599d37f..ad110a44f3af8b32490f6cdaa9f59947661f5964 100644 (file)
@@ -33,12 +33,12 @@ AudioMerger::AudioMerger (int channels, int frame_rate)
 }
 
 
-TimedAudioBuffers<DCPTime>
+TimedAudioBuffers
 AudioMerger::pull (DCPTime time)
 {
        assert (time >= _last_pull);
        
-       TimedAudioBuffers<DCPTime> out;
+       TimedAudioBuffers out;
        
        int64_t const to_return = DCPTime (time - _last_pull).frames (_frame_rate);
        out.audio.reset (new AudioBuffers (_buffers->channels(), to_return));
@@ -74,14 +74,14 @@ AudioMerger::push (shared_ptr<const AudioBuffers> audio, DCPTime time)
        _buffers->set_frames (after);
 }
 
-TimedAudioBuffers<DCPTime>
+TimedAudioBuffers
 AudioMerger::flush ()
 {
        if (_buffers->frames() == 0) {
-               return TimedAudioBuffers<DCPTime> ();
+               return TimedAudioBuffers ();
        }
        
-       return TimedAudioBuffers<DCPTime> (_buffers, _last_pull);
+       return TimedAudioBuffers (_buffers, _last_pull);
 }
 
 void
index 121b21095a6c6b43ad4e24fc8591bea00bcc6be4..756e5ab3120719fc8fd4e892891b947bbdf31ddb 100644 (file)
@@ -29,9 +29,9 @@ public:
        /** Pull audio up to a given time; after this call, no more data can be pushed
         *  before the specified time.
         */
-       TimedAudioBuffers<DCPTime> pull (DCPTime time);
+       TimedAudioBuffers pull (DCPTime time);
        void push (boost::shared_ptr<const AudioBuffers> audio, DCPTime time);
-       TimedAudioBuffers<DCPTime> flush ();
+       TimedAudioBuffers flush ();
        void clear (DCPTime t);
        
 private:
index 30fe899885e59e126abcf8d6c268d7bb7b496947..ebf4e57c1a724f6aa6ab69679c5b1f4528110134 100644 (file)
@@ -121,8 +121,8 @@ public:
 
        /* Assuming that all subs are at the same time */
        DecodedTextSubtitle (std::list<dcp::SubtitleString> s)
-               : Decoded (ContentTime::from_seconds (subs.front().in().to_ticks() * 4 / 1000.0))
-               , content_time_to (ContentTime::from_seconds (subs.front().out().to_ticks() * 4 / 1000.0))
+               : Decoded (ContentTime::from_seconds (s.front().in().to_ticks() * 4 / 1000.0))
+               , content_time_to (ContentTime::from_seconds (s.front().out().to_ticks() * 4 / 1000.0))
                , subs (s)
        {
                
index 093df09892082e587f236d91665bd9661d09cb65..6daba4b4002fee010a90943d182d2089168e7f69 100644 (file)
@@ -121,7 +121,6 @@ FFmpegExaminer::video_frame_rate () const
        AVStream* s = _format_context->streams[_video_stream];
 
        if (s->avg_frame_rate.num && s->avg_frame_rate.den) {
-               cout << "here we bitchen well are " << av_q2d (s->avg_frame_rate) << "\n";
                return av_q2d (s->avg_frame_rate);
        }
 
index d340ea9b46d8ff76e0ce0b88c97f90dbc74891da..e6e1f375373dd79cfdbe2790f40d126d4d1ef845 100644 (file)
@@ -162,7 +162,7 @@ Player::pass ()
                if (earliest_audio.get() < 0) {
                        earliest_audio = DCPTime ();
                }
-               TimedAudioBuffers<DCPTime> tb = _audio_merger.pull (earliest_audio);
+               TimedAudioBuffers tb = _audio_merger.pull (earliest_audio);
                Audio (tb.audio, tb.time);
                /* This assumes that the audio-frames-to-time conversion is exact
                   so that there are no accumulated errors caused by rounding.
@@ -383,7 +383,7 @@ Player::emit_audio (weak_ptr<Piece> weak_piece, shared_ptr<DecodedAudio> audio)
 void
 Player::flush ()
 {
-       TimedAudioBuffers<DCPTime> tb = _audio_merger.flush ();
+       TimedAudioBuffers tb = _audio_merger.flush ();
        if (_audio && tb.audio) {
                Audio (tb.audio, tb.time);
                _audio_position += DCPTime::from_frames (tb.audio->frames (), _film->audio_frame_rate ());
index bf034200d366cd532b09bfc5150e948fbc98a560..9524cf96baa8fa4b55f6650681e3d69bdfa939c2 100644 (file)
@@ -50,9 +50,11 @@ SubRipContent::examine (boost::shared_ptr<Job> job)
 {
        Content::examine (job);
        SubRip s (shared_from_this ());
-       boost::mutex::scoped_lock lm (_mutex);
        shared_ptr<const Film> film = _film.lock ();
-       _length = DCPTime (s.length (), film->active_frame_rate_change (position ()));
+       DCPTime len (s.length (), film->active_frame_rate_change (position ()));
+
+       boost::mutex::scoped_lock lm (_mutex);
+       _length = len;
 }
 
 string
index 42344cae543b8d380a5ccdc275b53816c4e79a69..dafea92f83948faba000c4391be42b169aaecf7a 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <boost/shared_ptr.hpp>
 #include <dcp/util.h>
+#include "dcpomatic_time.h"
 
 class Content;
 class VideoContent;
@@ -44,20 +45,19 @@ typedef std::vector<boost::shared_ptr<AudioContent> > AudioContentList;
 typedef std::vector<boost::shared_ptr<SubtitleContent> > SubtitleContentList;
 typedef std::vector<boost::shared_ptr<FFmpegContent> > FFmpegContentList;
 
-template<class T>
 struct TimedAudioBuffers
 {
        TimedAudioBuffers ()
                : time (0)
        {}
        
-       TimedAudioBuffers (boost::shared_ptr<AudioBuffers> a, T t)
+       TimedAudioBuffers (boost::shared_ptr<AudioBuffers> a, DCPTime t)
                : audio (a)
                , time (t)
        {}
        
        boost::shared_ptr<AudioBuffers> audio;
-       T time;
+       DCPTime time;
 };
 
 enum VideoFrameType
index d6122eb51087fe15cc666a8566aa980c1c9c6326..11310c5dad2954d0d7e5cd4412a605eb2a061286 100644 (file)
@@ -180,13 +180,11 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d)
        /* These examiner calls could call other content methods which take a lock on the mutex */
        dcp::Size const vs = d->video_size ();
        float const vfr = d->video_frame_rate ();
-       cout << "taking " << vfr << "\n";
        
        {
                boost::mutex::scoped_lock lm (_mutex);
                _video_size = vs;
                _video_frame_rate = vfr;
-               cout << "and then " << _video_frame_rate << "\n";
        }
        
        signal_changed (VideoContentProperty::VIDEO_SIZE);
index c65c0defdb7665a4e0b335cb984e92eba77390c4..2fa0ccea5945a61a4b72624bac24dc3312495005 100644 (file)
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE (audio_merger_test1)
        /* Push 64 samples, 0 -> 63 at time 22 */
        merger.push (buffers, DCPTime::from_frames (22, frame_rate));
 
-       TimedAudioBuffers<DCPTime> tb = merger.pull (DCPTime::from_frames (22, frame_rate));
+       TimedAudioBuffers tb = merger.pull (DCPTime::from_frames (22, frame_rate));
        BOOST_CHECK (tb.audio != shared_ptr<const AudioBuffers> ());
        BOOST_CHECK_EQUAL (tb.audio->frames(), 22);
        BOOST_CHECK_EQUAL (tb.time, DCPTime ());
@@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE (audio_merger_test2)
        }
        merger.push (buffers, DCPTime::from_frames (9, frame_rate));
 
-       TimedAudioBuffers<DCPTime> tb = merger.pull (DCPTime::from_frames (9, frame_rate));
+       TimedAudioBuffers tb = merger.pull (DCPTime::from_frames (9, frame_rate));
        BOOST_CHECK_EQUAL (tb.audio->frames(), 9);
        BOOST_CHECK_EQUAL (tb.time, DCPTime ());