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

Commit 17460976 authored by Leena Winterrowd's avatar Leena Winterrowd Committed by Lajos Molnar
Browse files

stagefright: httplive: Fix deadlock for low duration clips

PlaylistFetcher buffers up to 3 * target-duration bytes of data,
but if a stream is slow (ie due to bad network conditions), a
buffer threshold of 10s is used to resume playback. This results
in an indefinite freeze as PlaylistFetcher has stopped buffering
before this threshold. Reduce the 10s threshold to be more in-sync
with PlaylistFetcher's buffering size.

Bug: 18821145
Change-Id: Ife846e7c5b4f9645895873d08250c4bee0164972
parent 5cf91c50
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -145,10 +145,24 @@ status_t LiveSession::dequeueAccessUnit(
        }
    }

    int32_t targetDuration = 0;
    sp<AMessage> meta = packetSource->getLatestEnqueuedMeta();
    if (meta != NULL) {
        meta->findInt32("targetDuration", &targetDuration);
    }

    int64_t targetDurationUs = targetDuration * 1000000ll;
    if (targetDurationUs == 0 ||
            targetDurationUs > PlaylistFetcher::kMinBufferedDurationUs) {
        // Fetchers limit buffering to
        // min(3 * targetDuration, kMinBufferedDurationUs)
        targetDurationUs = PlaylistFetcher::kMinBufferedDurationUs;
    }

    if (mBuffering[idx]) {
        if (mSwitchInProgress
                || packetSource->isFinished(0)
                || packetSource->getEstimatedDurationUs() > 10000000ll) {
                || packetSource->getEstimatedDurationUs() > targetDurationUs) {
            mBuffering[idx] = false;
        }
    }
+2 −1
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ struct M3UParser;
struct String8;

struct PlaylistFetcher : public AHandler {
    static const int64_t kMinBufferedDurationUs;

    enum {
        kWhatStarted,
        kWhatPaused,
@@ -92,7 +94,6 @@ private:
        kWhatDownloadNext   = 'dlnx',
    };

    static const int64_t kMinBufferedDurationUs;
    static const int64_t kMaxMonitorDelayUs;
    static const int32_t kDownloadBlockSize;
    static const int32_t kNumSkipFrames;