Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9cb839a0 authored by Eric Laurent's avatar Eric Laurent
Browse files

Fix issue 5373048: AudioCache decode errors

When decoding a file for the SoundPool, do not
reject the entire file in case of error but
return what was decoded so far instead.

Change-Id: Iff199a1b6a4c8e064e42a0dfe0704e0ae36a27fd
parent ece731de
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -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();