diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-20 21:03:25 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-20 21:03:25 +0100 |
| commit | b6e73791a09cf0598024484f820385f4fec6190c (patch) | |
| tree | e2cd3ca8a732b47c06027690906fee685884c9cb /src/lib/decoder.cc | |
| parent | 453aa554e67d6a0c0ad74a16f5f877dec5a5c219 (diff) | |
Don't add silence at the end if not decoding audio; use an appropriately sized buffer for silence and check that emit_audio is passed an integer number of frames.
Diffstat (limited to 'src/lib/decoder.cc')
| -rw-r--r-- | src/lib/decoder.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index ee725c39d..14401994f 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -116,15 +116,14 @@ Decoder::process_end () ((int64_t) _fs->dcp_length() * _fs->target_sample_rate() / _fs->frames_per_second()) - _audio_frames_processed; - if (audio_short_by_frames >= 0) { + if (audio_short_by_frames >= 0 && _opt->decode_audio) { - stringstream s; - s << "Adding " << audio_short_by_frames << " frames of silence to the end."; - _log->log (s.str ()); + _log->log (String::compose ("DCP length is %1; %2 frames of audio processed.", _fs->dcp_length(), _audio_frames_processed)); + _log->log (String::compose ("Adding %1 frames of silence to the end.", audio_short_by_frames)); int64_t bytes = audio_short_by_frames * _fs->audio_channels() * bytes_per_audio_sample(); - int64_t const silence_size = 64 * 1024; + int64_t const silence_size = 16 * 1024 * _fs->audio_channels() * bytes_per_audio_sample(); uint8_t silence[silence_size]; memset (silence, 0, silence_size); @@ -192,6 +191,8 @@ Decoder::emit_audio (uint8_t* data, int size) { /* Deinterleave and convert to float */ + assert ((size % (bytes_per_audio_sample() * _fs->audio_channels())) == 0); + int const total_samples = size / bytes_per_audio_sample(); int const frames = total_samples / _fs->audio_channels(); shared_ptr<AudioBuffers> audio (new AudioBuffers (_fs->audio_channels(), frames)); |
