Various fixes to audio play wrt trimming and push/pull merger API.
authorCarl Hetherington <cth@carlh.net>
Wed, 31 Jul 2013 17:58:24 +0000 (18:58 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 31 Jul 2013 17:58:24 +0000 (18:58 +0100)
src/lib/player.cc
src/lib/sndfile_content.cc
test/ffmpeg_audio_test.cc
test/test.cc
test/wscript

index 63cf4ee7f8af3e9393d0215e7392d639c84c5988..8583a429bd00d534e879b8257bc9f2c13e4274b3 100644 (file)
@@ -177,7 +177,7 @@ Player::pass ()
                        emit_black ();
                } else {
 #ifdef DEBUG_PLAYER
-                       cout << "Pass " << *earliest << "\n";
+                       cout << "Pass video " << *earliest << "\n";
 #endif                 
                        earliest->decoder->pass ();
                }
@@ -186,12 +186,12 @@ Player::pass ()
        case AUDIO:
                if (earliest_t > _audio_position) {
 #ifdef DEBUG_PLAYER
-                       cout << "no audio here; emitting silence.\n";
+                       cout << "no audio here (none until " << earliest_t << "); emitting silence.\n";
 #endif
                        emit_silence (_film->time_to_audio_frames (earliest_t - _audio_position));
                } else {
 #ifdef DEBUG_PLAYER
-                       cout << "Pass " << *earliest << "\n";
+                       cout << "Pass audio " << *earliest << "\n";
 #endif
                        earliest->decoder->pass ();
 
@@ -206,27 +206,23 @@ Player::pass ()
                                        }
                                }
                        }
-
-                       
                }
-
-               Time done_up_to = TIME_MAX;
-               for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) {
-                       if (dynamic_pointer_cast<AudioContent> ((*i)->content)) {
-                               done_up_to = min (done_up_to, (*i)->audio_position);
-                       }
-               }
-
-               TimedAudioBuffers<Time> tb = _audio_merger.pull (done_up_to);
-               Audio (tb.audio, tb.time);
-               _audio_position += _film->audio_frames_to_time (tb.audio->frames ());
                break;
        }
-
        
+       Time audio_done_up_to = TIME_MAX;
+       for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) {
+               if (dynamic_pointer_cast<AudioDecoder> ((*i)->decoder)) {
+                       audio_done_up_to = min (audio_done_up_to, (*i)->audio_position);
+               }
+       }
+       
+       TimedAudioBuffers<Time> tb = _audio_merger.pull (audio_done_up_to);
+       Audio (tb.audio, tb.time);
+       _audio_position += _film->audio_frames_to_time (tb.audio->frames ());
 
 #ifdef DEBUG_PLAYER
-       cout << "\tpost pass " << _video_position << " " << _audio_position << "\n";
+       cout << "\tpost pass _video_position=" << _video_position << " _audio_position=" << _audio_position << "\n";
 #endif 
 
        return false;
@@ -302,14 +298,13 @@ Player::process_audio (weak_ptr<Piece> weak_piece, shared_ptr<const AudioBuffers
        shared_ptr<AudioContent> content = dynamic_pointer_cast<AudioContent> (piece->content);
        assert (content);
 
-       Time const relative_time = _film->audio_frames_to_time (frame)
-               + (content->audio_delay() * TIME_HZ / 1000);
+       Time const relative_time = _film->audio_frames_to_time (frame);
 
        if (content->trimmed (relative_time)) {
                return;
        }
 
-       Time time = content->position() + relative_time;
+       Time time = content->position() + (content->audio_delay() * TIME_HZ / 1000) + relative_time;
        
        /* Resample */
        if (content->content_audio_frame_rate() != content->output_audio_frame_rate()) {
index fc6f45d001005bf939c22539acb7b67df7dd239a..7d09f715c9746aed7572aa09746e972de93d8cb5 100644 (file)
@@ -64,7 +64,7 @@ SndfileContent::technical_summary () const
 {
        return Content::technical_summary() + " - "
                + AudioContent::technical_summary ()
-               + "sndfile";
+               + " - sndfile";
 }
 
 string
index 19f71e9644573897891d4170ac2bfb7408418325..7eafeef70d1d5ae532fbd520a796dc742ca0f877 100644 (file)
@@ -44,6 +44,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test)
        wait_for_jobs ();
 
        film->set_container (Ratio::from_id ("185"));
+       film->set_audio_channels (6);
        film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
        film->make_dcp ();
        film->write_metadata ();
index 1fd79872fa3337668144d4d0809939276a18f40c..2334523a1337696f74e271bec138503159343fb1 100644 (file)
@@ -144,8 +144,10 @@ wait_for_jobs ()
        while (jm->work_to_do ()) {}
        if (jm->errors ()) {
                for (list<shared_ptr<Job> >::iterator i = jm->_jobs.begin(); i != jm->_jobs.end(); ++i) {
-                       cerr << (*i)->error_summary () << "\n"
-                            << (*i)->error_details () << "\n";
+                       if ((*i)->finished_in_error ()) {
+                               cerr << (*i)->error_summary () << "\n"
+                                    << (*i)->error_details () << "\n";
+                       }
                }
        }
                
index 0fcb185f841a340eeeb4459ccacda813d681bea3..8cc50a683e33b2a76aa4ce702ea246aadc82dd27 100644 (file)
@@ -16,6 +16,7 @@ def build(bld):
     obj.use    = 'libdcpomatic'
     obj.source = """
                  test.cc
+                 audio_delay_test.cc
                  silence_padding_test.cc
                  audio_merger_test.cc
                  resampler_test.cc
@@ -23,7 +24,6 @@ def build(bld):
                  threed_test.cc
                  play_test.cc
                  frame_rate_test.cc
-                 audio_delay_test.cc
                  ffmpeg_pts_offset.cc
                  ffmpeg_examiner_test.cc
                  black_fill_test.cc