summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-09-12 12:06:43 +0100
committerCarl Hetherington <cth@carlh.net>2012-09-12 12:06:43 +0100
commitedd4f83959b196bef442387f99ecece034171464 (patch)
tree2b3547488ebfae2f599a6c2b23978001f50451ae
parent3e3fa3f58b9ce62768ca8a977334ae1b5fe7da69 (diff)
Fix crash when FFMpeg doesn't set up the audio channel layout for some reason.
-rw-r--r--ChangeLog5
-rw-r--r--src/lib/ffmpeg_decoder.cc12
2 files changed, 15 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index fcb18baa1..47f701c29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-12 Carl Hetherington <cth@carlh.net>
+
+ * Fix crash when FFmpeg doesn't set up the audio channel
+ layout for some reason.
+
2012-09-01 Carl Hetherington <cth@carlh.net>
* Add 1.66-within-flat format.
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index c12e6728d..3471ffaab 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -142,10 +142,18 @@ FFmpegDecoder::setup_audio ()
if (_audio_codec == 0) {
throw DecodeError ("could not find audio decoder");
}
-
+
if (avcodec_open2 (_audio_codec_context, _audio_codec, 0) < 0) {
throw DecodeError ("could not open audio decoder");
}
+
+ /* This is a hack; sometimes it seems that _audio_codec_context->channel_layout isn't set up,
+ so bodge it here. No idea why we should have to do this.
+ */
+
+ if (_audio_codec_context->channel_layout == 0) {
+ _audio_codec_context->channel_layout = av_get_default_channel_layout (audio_channels ());
+ }
}
bool
@@ -200,7 +208,7 @@ FFmpegDecoder::audio_channels () const
if (_audio_codec_context == 0) {
return 0;
}
-
+
return _audio_codec_context->channels;
}