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

Commit b23ef145 authored by Dave Sparks's avatar Dave Sparks Committed by Android Git Automerger
Browse files

am 65d39eeb: Merge "DO NOT MERGE: Prefill the cache before trying to...

am 65d39eeb: Merge "DO NOT MERGE: Prefill the cache before trying to instantiate the media extractor." into gingerbread

* commit '65d39eeb9b032e5507a01daa25afff62b29bffe4':
  DO NOT MERGE: Prefill the cache before trying to instantiate the media extractor.
parents ea59c3e2 6e3edc2d
Loading
Loading
Loading
Loading
+30 −3
Original line number Original line Diff line number Diff line
@@ -53,6 +53,8 @@ namespace android {


static int64_t kLowWaterMarkUs = 2000000ll;  // 2secs
static int64_t kLowWaterMarkUs = 2000000ll;  // 2secs
static int64_t kHighWaterMarkUs = 10000000ll;  // 10secs
static int64_t kHighWaterMarkUs = 10000000ll;  // 10secs
static const size_t kLowWaterMarkBytes = 40000;
static const size_t kHighWaterMarkBytes = 200000;


struct AwesomeEvent : public TimedEventQueue::Event {
struct AwesomeEvent : public TimedEventQueue::Event {
    AwesomeEvent(
    AwesomeEvent(
@@ -603,9 +605,6 @@ void AwesomePlayer::onBufferingUpdate() {
                // We don't know the bitrate of the stream, use absolute size
                // We don't know the bitrate of the stream, use absolute size
                // limits to maintain the cache.
                // limits to maintain the cache.


                const size_t kLowWaterMarkBytes = 40000;
                const size_t kHighWaterMarkBytes = 200000;

                if ((mFlags & PLAYING) && !eos
                if ((mFlags & PLAYING) && !eos
                        && (cachedDataRemaining < kLowWaterMarkBytes)) {
                        && (cachedDataRemaining < kLowWaterMarkBytes)) {
                    LOGI("cache is running low (< %d) , pausing.",
                    LOGI("cache is running low (< %d) , pausing.",
@@ -1523,6 +1522,34 @@ status_t AwesomePlayer::finishSetDataSource_l() {
        mConnectingDataSource.clear();
        mConnectingDataSource.clear();


        dataSource = mCachedSource;
        dataSource = mCachedSource;

        // We're going to prefill the cache before trying to instantiate
        // the extractor below, as the latter is an operation that otherwise
        // could block on the datasource for a significant amount of time.
        // During that time we'd be unable to abort the preparation phase
        // without this prefill.

        mLock.unlock();

        for (;;) {
            bool eos;
            size_t cachedDataRemaining =
                mCachedSource->approxDataRemaining(&eos);

            if (eos || cachedDataRemaining >= kHighWaterMarkBytes
                    || (mFlags & PREPARE_CANCELLED)) {
                break;
            }

            usleep(200000);
        }

        mLock.lock();

        if (mFlags & PREPARE_CANCELLED) {
            LOGI("Prepare cancelled while waiting for initial cache fill.");
            return UNKNOWN_ERROR;
        }
    } else if (!strncasecmp(mUri.string(), "httplive://", 11)) {
    } else if (!strncasecmp(mUri.string(), "httplive://", 11)) {
        String8 uri("http://");
        String8 uri("http://");
        uri.append(mUri.string() + 11);
        uri.append(mUri.string() + 11);
+1 −0
Original line number Original line Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


//#define LOG_NDEBUG 0
#define LOG_TAG "NuCachedSource2"
#define LOG_TAG "NuCachedSource2"
#include <utils/Log.h>
#include <utils/Log.h>