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

Commit 6b23df9d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "httplive: Resolve buffering standoff in HLS"

parents 0c52765e 0610341f
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -627,7 +627,7 @@ void PlaylistFetcher::onMonitorQueue() {
        durationToBufferUs = kMinBufferedDurationUs;
    }

    int64_t bufferedDurationUs = 0ll;
    int64_t bufferedDurationUs = -1ll;
    status_t finalResult = NOT_ENOUGH_DATA;
    if (mStreamTypeMask == LiveSession::STREAMTYPE_SUBTITLES) {
        sp<AnotherPacketSource> packetSource =
@@ -637,7 +637,10 @@ void PlaylistFetcher::onMonitorQueue() {
                packetSource->getBufferedDurationUs(&finalResult);
        finalResult = OK;
    } else {
        // Use max stream duration to prevent us from waiting on a non-existent stream;
        // In steady-state playback, the TS parser will ensure that mStreamTypeMask
        // correctly reflects the streams that are present. In this case, use min stream
        // duration to ensure that all streams are buffered. Otherwise (when mStartup is set)
        // use max stream duration to prevent us from waiting on a non-existent stream;
        // when we cannot make out from the manifest what streams are included in a playlist
        // we might assume extra streams.
        for (size_t i = 0; i < mPacketSources.size(); ++i) {
@@ -647,11 +650,19 @@ void PlaylistFetcher::onMonitorQueue() {

            int64_t bufferedStreamDurationUs =
                mPacketSources.valueAt(i)->getBufferedDurationUs(&finalResult);
            ALOGV("buffered %" PRId64 " for stream %d",
                    bufferedStreamDurationUs, mPacketSources.keyAt(i));
            ALOGV("buffered %" PRId64 " for stream %d (startup = %s)",
                    bufferedStreamDurationUs, mPacketSources.keyAt(i),
                    mStartup ? "true" : "false");
            if (mStartup) {
                if (bufferedStreamDurationUs > bufferedDurationUs) {
                    bufferedDurationUs = bufferedStreamDurationUs;
                }
            } else {
                if (bufferedDurationUs < 0 ||
                        bufferedStreamDurationUs < bufferedDurationUs) {
                    bufferedDurationUs = bufferedStreamDurationUs;
                }
            }
        }
    }
    downloadMore = (bufferedDurationUs < durationToBufferUs);