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

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

stagefright: httplive: Reduce memcpy calls for chunked content

Streams using http chunking will not report the segment's total
content-length. In this case, a 64k buffer is allocated and is
increased by 32k each time the buffer is filled again. For high
bitrate content, this can lead to a large number of copies that
affect the HLS framework delay. Increase fetchFile buffer size
exponentially by 50% or at least 32k instead of by 32k each time
to reduce the number of memcpy calls.

Example for a chunked 6 MB 1080p segment (ie ~3s):
Adding 32k:
190 copies with 572.97 MB copied

Increasing by 50%:
12 copies with 16.09 MB copied

Bug: 18821145
Change-Id: Iedf0e4437e96026a58d50bce2660f85ac90d0ada
parent 79971c74
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -873,7 +873,11 @@ ssize_t LiveSession::fetchFile(
        // Only resize when we don't know the size.
        size_t bufferRemaining = buffer->capacity() - buffer->size();
        if (bufferRemaining == 0 && getSizeErr != OK) {
            bufferRemaining = 32768;
            size_t bufferIncrement = buffer->size() / 2;
            if (bufferIncrement < 32768) {
                bufferIncrement = 32768;
            }
            bufferRemaining = bufferIncrement;

            ALOGV("increasing download buffer to %zu bytes",
                 buffer->size() + bufferRemaining);