diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-25 13:33:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-25 13:33:08 +0100 |
| commit | 872557b0261c0daf2206a24e38f33b1c9871c8a3 (patch) | |
| tree | eb48213893311c0b5de4d05c8db8bd273e6ca993 /src/lib | |
| parent | d9362bdd24f01e4c833e89d63ac3816f36eae36e (diff) | |
Call Resampler::flush() again.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/audio_decoder.cc | 10 | ||||
| -rw-r--r-- | src/lib/audio_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/decoder.h | 3 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 46 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 2 |
5 files changed, 41 insertions, 22 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 0ed3505cf..e827a77b9 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -50,8 +50,6 @@ AudioDecoder::AudioDecoder (shared_ptr<const Film> film, shared_ptr<const AudioC void AudioDecoder::audio (shared_ptr<const AudioBuffers> data, AudioContent::Frame frame) { - /* XXX: no-one's calling _resampler->flush() again */ - if (_resampler) { data = _resampler->run (data); } @@ -59,3 +57,11 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, AudioContent::Frame fr Audio (data, _audio_position); _audio_position = frame + data->frames (); } + +void +AudioDecoder::flush () +{ + if (_resampler) { + _resampler->flush (); + } +} diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index b1ec54a7b..e2d28d707 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -44,6 +44,8 @@ public: protected: + void flush (); + void audio (boost::shared_ptr<const AudioBuffers>, AudioContent::Frame); /** Frame index of next emission (post resampling) */ AudioContent::Frame _audio_position; diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 9eb4850f9..d67592ed8 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -43,11 +43,12 @@ public: * cause the object to emit some data. */ virtual void pass () = 0; - virtual bool done () const = 0; protected: + virtual void flush () {}; + /** The Film that we are decoding in */ boost::weak_ptr<const Film> _film; }; diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index d8319723a..e2e5b9d64 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -120,7 +120,32 @@ FFmpegDecoder::~FFmpegDecoder () if (_subtitle_codec_context) { avcodec_close (_subtitle_codec_context); } -} +} + +void +FFmpegDecoder::flush () +{ + /* Get any remaining frames */ + + _packet.data = 0; + _packet.size = 0; + + /* XXX: should we reset _packet.data and size after each *_decode_* call? */ + + if (_decode_video) { + while (decode_video_packet ()) {} + } + + if (_ffmpeg_content->audio_stream() && _decode_audio) { + decode_audio_packet (); + } + + AudioDecoder::flush (); + + /* Stop us being asked for any more data */ + _video_position = _ffmpeg_content->video_length (); + _audio_position = _ffmpeg_content->audio_length (); +} void FFmpegDecoder::pass () @@ -137,24 +162,7 @@ FFmpegDecoder::pass () film->log()->log (String::compose (N_("error on av_read_frame (%1) (%2)"), buf, r)); } - /* Get any remaining frames */ - - _packet.data = 0; - _packet.size = 0; - - /* XXX: should we reset _packet.data and size after each *_decode_* call? */ - - if (_decode_video) { - while (decode_video_packet ()) {} - } - - if (_ffmpeg_content->audio_stream() && _decode_audio) { - decode_audio_packet (); - } - - /* Stop us being asked for any more data */ - _video_position = _ffmpeg_content->video_length (); - _audio_position = _ffmpeg_content->audio_length (); + flush (); return; } diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index e3aa484d1..11f83ed97 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -60,6 +60,8 @@ private: static double compute_pts_offset (double, double, float); + void flush (); + void setup_subtitle (); AVSampleFormat audio_sample_format () const; |
