Merge "While streaming media data, upon a socket-read error, try reconnecting to the server and attempt to re-read for at most 3 times."
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 4b364f2..5e6ce42 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -358,7 +358,7 @@
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
unsigned int result = 0;
if (af == 0) return result;
- if (ioHandle == NULL) return result;
+ if (ioHandle == 0) return result;
result = af->getInputFramesLost(ioHandle);
return result;
@@ -556,7 +556,18 @@
output_flags flags)
{
audio_io_handle_t output = 0;
- if ((flags & AudioSystem::OUTPUT_FLAG_DIRECT) == 0) {
+ // Do not use stream to output map cache if the direct output
+ // flag is set or if we are likely to use a direct output
+ // (e.g voice call stream @ 8kHz could use BT SCO device and be routed to
+ // a direct output on some platforms).
+ // TODO: the output cache and stream to output mapping implementation needs to
+ // be reworked for proper operation with direct outputs. This code is too specific
+ // to the first use case we want to cover (Voice Recognition and Voice Dialer over
+ // Bluetooth SCO
+ if ((flags & AudioSystem::OUTPUT_FLAG_DIRECT) == 0 &&
+ ((stream != AudioSystem::VOICE_CALL && stream != AudioSystem::BLUETOOTH_SCO) ||
+ channels != AudioSystem::CHANNEL_OUT_MONO ||
+ (samplingRate != 8000 && samplingRate != 16000))) {
Mutex::Autolock _l(gLock);
output = AudioSystem::gStreamOutputMap.valueFor(stream);
LOGV_IF((output != 0), "getOutput() read %d from cache for stream %d", output, stream);
diff --git a/media/libstagefright/codecs/aacdec/AACDecoder.cpp b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
index f0b66c9..fe84b38 100644
--- a/media/libstagefright/codecs/aacdec/AACDecoder.cpp
+++ b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
@@ -199,7 +199,16 @@
mConfig->pOutputBuffer_plus = NULL;
mConfig->repositionFlag = false;
- CHECK_EQ(PVMP4AudioDecodeFrame(mConfig, mDecoderBuf), MP4AUDEC_SUCCESS);
+ Int decoderErr = PVMP4AudioDecodeFrame(mConfig, mDecoderBuf);
+
+ if (decoderErr != MP4AUDEC_SUCCESS) {
+ LOGE("AAC decoder returned error %d", decoderErr);
+
+ buffer->release();
+ buffer = NULL;
+
+ return ERROR_MALFORMED;
+ }
buffer->set_range(
0, mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels);