summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-31 18:58:24 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-31 18:58:24 +0100
commitd02f1b0f08b3095816767ab7a70254aef50eb355 (patch)
tree26811832c7b89e59a75710e434eae33557f96303
parent8b2d460f1b76d3d1122cfdb2a6a33e6eab7cece4 (diff)
Various fixes to audio play wrt trimming and push/pull merger API.
-rw-r--r--src/lib/player.cc37
-rw-r--r--src/lib/sndfile_content.cc2
-rw-r--r--test/ffmpeg_audio_test.cc1
-rw-r--r--test/test.cc6
-rw-r--r--test/wscript2
5 files changed, 23 insertions, 25 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 63cf4ee7f..8583a429b 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -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()) {
diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc
index fc6f45d00..7d09f715c 100644
--- a/src/lib/sndfile_content.cc
+++ b/src/lib/sndfile_content.cc
@@ -64,7 +64,7 @@ SndfileContent::technical_summary () const
{
return Content::technical_summary() + " - "
+ AudioContent::technical_summary ()
- + "sndfile";
+ + " - sndfile";
}
string
diff --git a/test/ffmpeg_audio_test.cc b/test/ffmpeg_audio_test.cc
index 19f71e964..7eafeef70 100644
--- a/test/ffmpeg_audio_test.cc
+++ b/test/ffmpeg_audio_test.cc
@@ -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 ();
diff --git a/test/test.cc b/test/test.cc
index 1fd79872f..2334523a1 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -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";
+ }
}
}
diff --git a/test/wscript b/test/wscript
index 0fcb185f8..8cc50a683 100644
--- a/test/wscript
+++ b/test/wscript
@@ -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