Merge "Fix issue 5373048: AudioCache decode errors"

This commit is contained in:
Eric Laurent
2011-09-27 10:32:17 -07:00
committed by Android (Google) Code Review

View File

@@ -52,6 +52,7 @@
#include <media/Metadata.h>
#include <media/AudioTrack.h>
#include <media/MemoryLeakTrackUtil.h>
#include <media/stagefright/MediaErrors.h>
#include <system/audio.h>
@@ -1132,7 +1133,11 @@ sp<IMemory> MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, i
player->start();
LOGV("wait for playback complete");
if (cache->wait() != NO_ERROR) goto Exit;
cache->wait();
// in case of error, return what was successfully decoded.
if (cache->size() == 0) {
goto Exit;
}
mem = new MemoryBase(cache->getHeap(), 0, cache->size());
*pSampleRate = cache->sampleRate();
@@ -1175,7 +1180,11 @@ sp<IMemory> MediaPlayerService::decode(int fd, int64_t offset, int64_t length, u
player->start();
LOGV("wait for playback complete");
if (cache->wait() != NO_ERROR) goto Exit;
cache->wait();
// in case of error, return what was successfully decoded.
if (cache->size() == 0) {
goto Exit;
}
mem = new MemoryBase(cache->getHeap(), 0, cache->size());
*pSampleRate = cache->sampleRate();