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

Commit 52c03ae2 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8822666 from 8e49253e to tm-d1-release

Change-Id: I30df07a8a9b694f83b0c3626f63c76927189f78f
parents 5261067a 8e49253e
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -59,10 +59,11 @@ bool AWakeLock::acquire() {
        if (mPowerManager != NULL) {
        if (mPowerManager != NULL) {
            sp<IBinder> binder = new BBinder();
            sp<IBinder> binder = new BBinder();
            int64_t token = IPCThreadState::self()->clearCallingIdentity();
            int64_t token = IPCThreadState::self()->clearCallingIdentity();
            binder::Status status = mPowerManager->acquireWakeLockAsync(
            binder::Status status = mPowerManager->acquireWakeLock(
                    binder, POWERMANAGER_PARTIAL_WAKE_LOCK,
                    binder, POWERMANAGER_PARTIAL_WAKE_LOCK,
                    String16("AWakeLock"), String16("media"),
                    String16("AWakeLock"), String16("media"),
                    {} /* workSource */, {} /* historyTag */);
                    {} /* workSource */, {} /* historyTag */, -1 /* displayId */,
                    nullptr /* callback */);
            IPCThreadState::self()->restoreCallingIdentity(token);
            IPCThreadState::self()->restoreCallingIdentity(token);
            if (status.isOk()) {
            if (status.isOk()) {
                mWakeLockToken = binder;
                mWakeLockToken = binder;
+20 −1
Original line number Original line Diff line number Diff line
@@ -73,6 +73,10 @@ static inline int32_t getAudioSinkPcmMsSetting() {
// is closed to allow the audio DSP to power down.
// is closed to allow the audio DSP to power down.
static const int64_t kOffloadPauseMaxUs = 10000000LL;
static const int64_t kOffloadPauseMaxUs = 10000000LL;


// Additional delay after teardown before releasing the wake lock to allow time for the audio path
// to be completely released
static const int64_t kWakelockReleaseDelayUs = 2000000LL;

// Maximum allowed delay from AudioSink, 1.5 seconds.
// Maximum allowed delay from AudioSink, 1.5 seconds.
static const int64_t kMaxAllowedAudioSinkDelayUs = 1500000LL;
static const int64_t kMaxAllowedAudioSinkDelayUs = 1500000LL;


@@ -793,6 +797,20 @@ void NuPlayer::Renderer::onMessageReceived(const sp<AMessage> &msg) {
            }
            }
            ALOGV("Audio Offload tear down due to pause timeout.");
            ALOGV("Audio Offload tear down due to pause timeout.");
            onAudioTearDown(kDueToTimeout);
            onAudioTearDown(kDueToTimeout);
            sp<AMessage> newMsg = new AMessage(kWhatReleaseWakeLock, this);
            newMsg->setInt32("drainGeneration", generation);
            newMsg->post(kWakelockReleaseDelayUs);
            break;
        }

        case kWhatReleaseWakeLock:
        {
            int32_t generation;
            CHECK(msg->findInt32("drainGeneration", &generation));
            if (generation != mAudioOffloadPauseTimeoutGeneration) {
                break;
            }
            ALOGV("releasing audio offload pause wakelock.");
            mWakeLock->release();
            mWakeLock->release();
            break;
            break;
        }
        }
@@ -1785,6 +1803,8 @@ void NuPlayer::Renderer::onPause() {
        return;
        return;
    }
    }


    startAudioOffloadPauseTimeout();

    {
    {
        Mutex::Autolock autoLock(mLock);
        Mutex::Autolock autoLock(mLock);
        // we do not increment audio drain generation so that we fill audio buffer during pause.
        // we do not increment audio drain generation so that we fill audio buffer during pause.
@@ -1799,7 +1819,6 @@ void NuPlayer::Renderer::onPause() {


    // Note: audio data may not have been decoded, and the AudioSink may not be opened.
    // Note: audio data may not have been decoded, and the AudioSink may not be opened.
    mAudioSink->pause();
    mAudioSink->pause();
    startAudioOffloadPauseTimeout();


    ALOGV("now paused audio queue has %zu entries, video has %zu entries",
    ALOGV("now paused audio queue has %zu entries, video has %zu entries",
          mAudioQueue.size(), mVideoQueue.size());
          mAudioQueue.size(), mVideoQueue.size());
+1 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,7 @@ struct NuPlayer::Renderer : public AHandler {
        kWhatMediaRenderingStart      = 'mdrd',
        kWhatMediaRenderingStart      = 'mdrd',
        kWhatAudioTearDown            = 'adTD',
        kWhatAudioTearDown            = 'adTD',
        kWhatAudioOffloadPauseTimeout = 'aOPT',
        kWhatAudioOffloadPauseTimeout = 'aOPT',
        kWhatReleaseWakeLock          = 'adRL',
    };
    };


    enum AudioTearDownReason {
    enum AudioTearDownReason {