summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-01-10 21:47:11 +0000
committerCarl Hetherington <cth@carlh.net>2019-01-10 21:47:11 +0000
commit70684e31a96bd7d4c7b09d525902959345b76526 (patch)
tree2d9f17c88d73df8c72747086e2f11b740f010395 /src
parentd9c2cf78e6c5e465e7f76020f78f7ed1e71c3bc0 (diff)
Fix a crash due the assertion in emit_audio failing when applying
trims which do not land precisely on a DCP audio sample boundary (at least, I think that's what triggers it).
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_ring_buffers.cc5
-rw-r--r--src/lib/player.cc6
2 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/audio_ring_buffers.cc b/src/lib/audio_ring_buffers.cc
index d26fb9eb7..21c4b6a5c 100644
--- a/src/lib/audio_ring_buffers.cc
+++ b/src/lib/audio_ring_buffers.cc
@@ -46,10 +46,11 @@ AudioRingBuffers::put (shared_ptr<const AudioBuffers> data, DCPTime time, int fr
if (!_buffers.empty()) {
DCPOMATIC_ASSERT (_buffers.front().first->channels() == data->channels());
- if ((_buffers.back().second + DCPTime::from_frames(_buffers.back().first->frames(), frame_rate)) != time) {
+ DCPTime const end = (_buffers.back().second + DCPTime::from_frames(_buffers.back().first->frames(), frame_rate));
+ if (labs(end.get() - time.get()) > 1) {
cout << "bad put " << to_string(_buffers.back().second) << " " << _buffers.back().first->frames() << " " << to_string(time) << "\n";
}
- DCPOMATIC_ASSERT ((_buffers.back().second + DCPTime::from_frames(_buffers.back().first->frames(), frame_rate)) == time);
+ DCPOMATIC_ASSERT (labs(end.get() - time.get()) < 2);
}
_buffers.push_back(make_pair(data, time));
diff --git a/src/lib/player.cc b/src/lib/player.cc
index fa6c1b055..f80adcbf4 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -1093,12 +1093,12 @@ void
Player::emit_audio (shared_ptr<AudioBuffers> data, DCPTime time)
{
/* Log if the assert below is about to fail */
- if (_last_audio_time && time != *_last_audio_time) {
+ if (_last_audio_time && labs(time.get() - _last_audio_time->get()) > 1) {
_film->log()->log(String::compose("Out-of-sequence emit %1 vs %2", to_string(time), to_string(*_last_audio_time)), LogEntry::TYPE_WARNING);
}
- /* This audio must follow on from the previous */
- DCPOMATIC_ASSERT (!_last_audio_time || time == *_last_audio_time);
+ /* This audio must follow on from the previous, allowing for half a sample (at 48kHz) leeway */
+ DCPOMATIC_ASSERT (!_last_audio_time || labs(time.get() - _last_audio_time->get()) < 2);
Audio (data, time, _film->audio_frame_rate());
_last_audio_time = time + DCPTime::from_frames (data->frames(), _film->audio_frame_rate());
}