return true;
}
- sf_count_t const block = 65536;
-
- cout << frames << " audio frames.\n";
+ /* Do things in half second blocks as I think there may be limits
+ to what FFmpeg (and in particular the resampler) can cope with.
+ */
+ sf_count_t const block = _audio_stream->sample_rate() / 2;
shared_ptr<AudioBuffers> audio (new AudioBuffers (_audio_stream->channels(), block));
while (frames > 0) {
}
}
+ audio->set_frames (this_time);
Audio (audio);
frames -= this_time;
}
#endif
if (_film->audio_stream()) {
- int const dcp_sr = dcp_audio_sample_rate (_film->audio_stream()->sample_rate ());
- int64_t const extra_audio_frames = dcp_sr - (_audio_frames_written % dcp_sr);
- shared_ptr<AudioBuffers> silence (new AudioBuffers (_film->audio_stream()->channels(), extra_audio_frames));
- silence->make_silent ();
- write_audio (silence);
-
close_sound_files ();
/* Rename .wav.tmp files to .wav */
#include "image.h"
#include "log.h"
+using std::min;
using boost::shared_ptr;
Matcher::Matcher (Log* log, int sample_rate, float frames_per_second)
if (audio_short_by_frames > 0) {
_log->log (String::compose ("Emitted %1 too few audio frames", audio_short_by_frames));
- shared_ptr<AudioBuffers> b (new AudioBuffers (_channels.get(), audio_short_by_frames));
+
+ /* Do things in half second blocks as I think there may be limits
+ to what FFmpeg (and in particular the resampler) can cope with.
+ */
+ int64_t const block = _sample_rate / 2;
+ shared_ptr<AudioBuffers> b (new AudioBuffers (_channels.get(), block));
b->make_silent ();
- Audio (b);
- _audio_frames += b->frames ();
+
+ int64_t to_do = audio_short_by_frames;
+ while (to_do > 0) {
+ int64_t const this_time = min (to_do, block);
+ b->set_frames (this_time);
+ Audio (b);
+ _audio_frames += b->frames ();
+ to_do -= this_time;
+ }
}
}
}
} catch (...) {
- /* process_end() is important as the decoder may have worker
- threads that need to be cleaned up.
- */
_encoder->process_end ();
throw;
}
-
+
+ if (_delay_line) {
+ _delay_line->process_end ();
+ }
+ if (_matcher) {
+ _matcher->process_end ();
+ }
+ if (_gain) {
+ _gain->process_end ();
+ }
_encoder->process_end ();
}