summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-09-27 00:16:38 +0200
committerCarl Hetherington <cth@carlh.net>2023-09-29 00:57:58 +0200
commite67ce8ae4b9121bbcef2c1dcb61bdb5b9330ad78 (patch)
treeee3d90621a55e1f487f08151e4ae1ae6ba4042f3 /src
parent0c8349e3616735e21cc79bec8e705a77224f1921 (diff)
Fix errors with WAVs containing markers (#2617).
I'm not 100% sure about this but they seem to end up giving audio packets with no channels and no frames. Here we handle such packets better.
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_buffers.cc2
-rw-r--r--src/lib/audio_buffers.h2
-rw-r--r--src/lib/ffmpeg_decoder.cc4
3 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc
index 4f01146f9..0e31793ea 100644
--- a/src/lib/audio_buffers.cc
+++ b/src/lib/audio_buffers.cc
@@ -81,7 +81,7 @@ void
AudioBuffers::allocate (int channels, int frames)
{
DCPOMATIC_ASSERT (frames >= 0);
- DCPOMATIC_ASSERT (channels > 0);
+ DCPOMATIC_ASSERT(frames == 0 || channels > 0);
ScopeGuard sg = [this]() { update_data_pointers(); };
diff --git a/src/lib/audio_buffers.h b/src/lib/audio_buffers.h
index 645348aa0..b43179663 100644
--- a/src/lib/audio_buffers.h
+++ b/src/lib/audio_buffers.h
@@ -60,7 +60,7 @@ public:
}
int frames () const {
- return _data[0].size();
+ return _data.empty() ? 0 : _data[0].size();
}
void set_frames (int f);
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index efe151530..c3d32bc75 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -266,6 +266,10 @@ deinterleave_audio(AVFrame* frame)
auto audio = make_shared<AudioBuffers>(channels, frames);
auto data = audio->data();
+ if (frames == 0) {
+ return audio;
+ }
+
switch (format) {
case AV_SAMPLE_FMT_U8:
{