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

Commit 61da4d35 authored by Pin-chih Lin's avatar Pin-chih Lin
Browse files

SimpleDecodingSource: add max retry times for while loop

Add a maximum retry times to break the loop to avoid infinite loop while output
buffer stack is stuck.

Bug: 112677333
Test: build and run stagefright cmdtool
Change-Id: Ie4f68075f5297acf67eda22f2f822a7878a18c66
parent d4d7f1ff
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ using namespace android;

const int64_t kTimeoutWaitForOutputUs = 500000; // 0.5 seconds
const int64_t kTimeoutWaitForInputUs = 5000; // 5 milliseconds
const int kTimeoutMaxRetries = 20;

//static
sp<SimpleDecodingSource> SimpleDecodingSource::Create(
@@ -242,7 +243,7 @@ status_t SimpleDecodingSource::doRead(
        return ERROR_END_OF_STREAM;
    }

    for (int retries = 0; ++retries; ) {
    for (int retries = 0; retries < kTimeoutMaxRetries; ++retries) {
        // If we fill all available input buffers, we should expect that
        // the codec produces at least one output buffer. Also, the codec
        // should produce an output buffer in at most 1 seconds. Retry a