diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-24 15:53:54 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-24 15:53:54 +0100 |
| commit | 0c01a21ffc4cf9eea71a662916cc3095f2634216 (patch) | |
| tree | 8dd9d52d022437a91243635eef69404b43d2c446 /src/lib/player.cc | |
| parent | 0ca58170da6cd1b7055c9c4b57a5d3e6a10cea7c (diff) | |
Try to clean up resampler output correctly.
Diffstat (limited to 'src/lib/player.cc')
| -rw-r--r-- | src/lib/player.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index f90cf32f5..37f172f1d 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -191,6 +191,18 @@ Player::pass () cout << "Pass " << *earliest << "\n"; #endif earliest->decoder->pass (); + + if (earliest->decoder->done()) { + shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (earliest->content); + assert (ac); + shared_ptr<Resampler> re = resampler (ac, false); + if (re) { + shared_ptr<const AudioBuffers> b = re->flush (); + if (b->frames ()) { + process_audio (earliest, b, ac->audio_length ()); + } + } + } } break; } @@ -267,7 +279,7 @@ Player::process_audio (weak_ptr<Piece> weak_piece, shared_ptr<const AudioBuffers /* Resample */ if (content->content_audio_frame_rate() != content->output_audio_frame_rate()) { - shared_ptr<Resampler> r = resampler (content); + shared_ptr<Resampler> r = resampler (content, true); audio = r->run (audio); } @@ -501,12 +513,16 @@ Player::set_video_container_size (libdcp::Size s) } shared_ptr<Resampler> -Player::resampler (shared_ptr<AudioContent> c) +Player::resampler (shared_ptr<AudioContent> c, bool create) { map<shared_ptr<AudioContent>, shared_ptr<Resampler> >::iterator i = _resamplers.find (c); if (i != _resamplers.end ()) { return i->second; } + + if (!create) { + return shared_ptr<Resampler> (); + } shared_ptr<Resampler> r (new Resampler (c->content_audio_frame_rate(), c->output_audio_frame_rate(), c->audio_channels())); _resamplers[c] = r; |
