diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-05-13 13:30:44 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-05-13 13:30:44 +0100 |
| commit | 9979f8f81258cecae06c8254868eceac43c56f8e (patch) | |
| tree | a43d8f43d1df9dad1f44c88603de27fd9ba74344 | |
| parent | 3ed8ab280b3ea0b52d5061a4a36976da232c38ef (diff) | |
Fix crash on rounding in AudioMerger.
| -rw-r--r-- | src/lib/audio_merger.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/audio_merger.cc b/src/lib/audio_merger.cc index 275a47691..8a69dee52 100644 --- a/src/lib/audio_merger.cc +++ b/src/lib/audio_merger.cc @@ -69,13 +69,15 @@ AudioMerger::pull (DCPTime time) } else if (i.time < time) { /* Overlaps the end of the pull period */ shared_ptr<AudioBuffers> audio (new AudioBuffers (i.audio->channels(), frames(DCPTime(time - i.time)))); - audio->copy_from (i.audio.get(), audio->frames(), 0, 0); - DCPOMATIC_ASSERT (audio->frames() > 0); - out.push_back (make_pair (audio, i.time)); - i.audio->trim_start (audio->frames ()); - i.time += DCPTime::from_frames(audio->frames(), _frame_rate); - DCPOMATIC_ASSERT (i.audio->frames() > 0); - new_buffers.push_back (i); + /* Though time > i.time, audio->frames() could be 0 if the difference in time is less than one frame */ + if (audio->frames() > 0) { + audio->copy_from (i.audio.get(), audio->frames(), 0, 0); + out.push_back (make_pair (audio, i.time)); + i.audio->trim_start (audio->frames ()); + i.time += DCPTime::from_frames(audio->frames(), _frame_rate); + DCPOMATIC_ASSERT (i.audio->frames() > 0); + new_buffers.push_back (i); + } } else { /* Not involved */ DCPOMATIC_ASSERT (i.audio->frames() > 0); |
