From 26eca01c490f643fc2558be4c5477a1d433a8a07 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Tue, 28 Apr 2015 18:43:03 -0700 Subject: Check for null codec from AMediaCodec_createDecoderByType NULL codec can now occur if codec cannot be created. Bug: 20566134 Change-Id: I08d54e733a01d0614313673dc49a6f5e702633ac --- media/jni/soundpool/SoundPool.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'media') diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp index 25c6154..84ae3b4 100644 --- a/media/jni/soundpool/SoundPool.cpp +++ b/media/jni/soundpool/SoundPool.cpp @@ -514,10 +514,11 @@ static status_t decode(int fd, int64_t offset, int64_t length, if (strncmp(mime, "audio/", 6) == 0) { AMediaCodec *codec = AMediaCodec_createDecoderByType(mime); - if (AMediaCodec_configure(codec, format, - NULL /* window */, NULL /* drm */, 0 /* flags */) != AMEDIA_OK - || AMediaCodec_start(codec) != AMEDIA_OK - || AMediaExtractor_selectTrack(ex, i) != AMEDIA_OK) { + if (codec == NULL + || AMediaCodec_configure(codec, format, + NULL /* window */, NULL /* drm */, 0 /* flags */) != AMEDIA_OK + || AMediaCodec_start(codec) != AMEDIA_OK + || AMediaExtractor_selectTrack(ex, i) != AMEDIA_OK) { AMediaExtractor_delete(ex); AMediaCodec_delete(codec); AMediaFormat_delete(format); -- cgit v1.1