summaryrefslogtreecommitdiff
path: root/src
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 /src
parent8b2d460f1b76d3d1122cfdb2a6a33e6eab7cece4 (diff)
Various fixes to audio play wrt trimming and push/pull merger API.
Diffstat (limited to 'src')
-rw-r--r--src/lib/player.cc37
-rw-r--r--src/lib/sndfile_content.cc2
2 files changed, 17 insertions, 22 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