From 45ad57aab33428575d7cde917e9477aac26beb71 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 30 Mar 2011 14:45:22 -0700 Subject: [PATCH] When http streaming and Content-Length is unknown, make sure to return all data that we successfully received before signalling the error. Change-Id: I7e60602d41b4df85aa85e413c590687305e9bbce related-to-bug: 4190765 --- media/libstagefright/NuHTTPDataSource.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/media/libstagefright/NuHTTPDataSource.cpp b/media/libstagefright/NuHTTPDataSource.cpp index b24343f4d1920..bee0d5e030925 100644 --- a/media/libstagefright/NuHTTPDataSource.cpp +++ b/media/libstagefright/NuHTTPDataSource.cpp @@ -410,7 +410,14 @@ ssize_t NuHTTPDataSource::readAt(off64_t offset, void *data, size_t size) { internalRead((uint8_t *)data + numBytesRead, size - numBytesRead); if (n < 0) { - return n; + if (numBytesRead == 0 || mContentLengthValid) { + return n; + } + + // If there was an error we want to at least return the data + // we've already successfully read. The next call to read will + // then return the error. + n = 0; } int64_t delayUs = ALooper::GetNowUs() - startTimeUs;