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

Commit aab5b08c authored by Eric Laurent's avatar Eric Laurent
Browse files

AwesomePlayer: do not send events when paused.

When streaming audio and paused, AwesomePlayer should
stop sending BufferingEvents as they will keep a wake lock
for no reason.

TimedEventQueue should always acquire the wakelock with mediaserver
identity so that it is released with the same identity by the
event handler thread.

Bug: 11104408.
Change-Id: Ied0e03acd6ad2f5a4c0ec82d5c2aa4e1c6da772c
parent fee4ce33
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -798,8 +798,10 @@ void AwesomePlayer::onBufferingUpdate() {
        }
    }

    if (mFlags & (PLAYING | PREPARING)) {
        postBufferingEvent_l();
    }
}

void AwesomePlayer::sendCacheStats() {
    sp<MediaPlayerBase> listener = mListener.promote();
@@ -1001,6 +1003,10 @@ status_t AwesomePlayer::play_l() {
    }
    addBatteryData(params);

    if (isStreamingHTTP()) {
        postBufferingEvent_l();
    }

    return OK;
}

+6 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@
#include <media/stagefright/foundation/ALooper.h>
#include <binder/IServiceManager.h>
#include <powermanager/PowerManager.h>
#include <binder/IPCThreadState.h>
#include <utils/CallStack.h>

namespace android {

@@ -327,10 +329,12 @@ void TimedEventQueue::acquireWakeLock_l()
    }
    if (mPowerManager != 0) {
        sp<IBinder> binder = new BBinder();
        int64_t token = IPCThreadState::self()->clearCallingIdentity();
        status_t status = mPowerManager->acquireWakeLock(POWERMANAGER_PARTIAL_WAKE_LOCK,
                                                         binder,
                                                         String16("TimedEventQueue"),
                                                         String16("media"));
        IPCThreadState::self()->restoreCallingIdentity(token);
        if (status == NO_ERROR) {
            mWakeLockToken = binder;
        }
@@ -343,7 +347,9 @@ void TimedEventQueue::releaseWakeLock_l()
        return;
    }
    if (mPowerManager != 0) {
        int64_t token = IPCThreadState::self()->clearCallingIdentity();
        mPowerManager->releaseWakeLock(mWakeLockToken, 0);
        IPCThreadState::self()->restoreCallingIdentity(token);
    }
    mWakeLockToken.clear();
}