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

Commit 76f80b26 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8822995 from e1cca4de to tm-qpr1-release

Change-Id: I7cb97f326348a9d38ca260bce2a2c41e52e92b92
parents 838714d3 e1cca4de
Loading
Loading
Loading
Loading
+41 −7
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@ static inline int32_t getAudioSinkPcmMsSetting() {
// is closed to allow the audio DSP to power down.
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.
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.");
            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();
            break;
        }
@@ -1785,6 +1803,8 @@ void NuPlayer::Renderer::onPause() {
        return;
    }

    startAudioOffloadPauseTimeout();

    {
        Mutex::Autolock autoLock(mLock);
        // 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.
    mAudioSink->pause();
    startAudioOffloadPauseTimeout();

    ALOGV("now paused audio queue has %zu entries, video has %zu entries",
          mAudioQueue.size(), mVideoQueue.size());
@@ -1927,12 +1946,27 @@ status_t NuPlayer::Renderer::onOpenAudioSink(
    int32_t numChannels;
    CHECK(format->findInt32("channel-count", &numChannels));

    int32_t rawChannelMask;
    audio_channel_mask_t channelMask =
            format->findInt32("channel-mask", &rawChannelMask) ?
                    static_cast<audio_channel_mask_t>(rawChannelMask)
                    // signal to the AudioSink to derive the mask from count.
                    : CHANNEL_MASK_USE_CHANNEL_ORDER;
    // channel mask info as read from the audio format
    int32_t channelMaskFromFormat;
    // channel mask to use for native playback
    audio_channel_mask_t channelMask;
    if (format->findInt32("channel-mask", &channelMaskFromFormat)) {
        // KEY_CHANNEL_MASK follows the android.media.AudioFormat java mask
        // which is left-bitshifted by 2 relative to the native mask
        if ((channelMaskFromFormat & 0b11) != 0) {
            // received an unexpected mask (supposed to follow AudioFormat constants
            // for output masks with the 2 least-significant bits at 0), but
            // it may come from an extractor that uses native masks: keeping
            // the mask as given is ok as it contains at least mono or stereo
            // and potentially the haptic channels
            channelMask = static_cast<audio_channel_mask_t>(channelMaskFromFormat);
        } else {
            channelMask = static_cast<audio_channel_mask_t>(channelMaskFromFormat >> 2);
        }
    } else {
        // no mask found: the mask will be derived from the channel count
        channelMask = CHANNEL_MASK_USE_CHANNEL_ORDER;
    }

    int32_t sampleRate;
    CHECK(format->findInt32("sample-rate", &sampleRate));
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ struct NuPlayer::Renderer : public AHandler {
        kWhatMediaRenderingStart      = 'mdrd',
        kWhatAudioTearDown            = 'adTD',
        kWhatAudioOffloadPauseTimeout = 'aOPT',
        kWhatReleaseWakeLock          = 'adRL',
    };

    enum AudioTearDownReason {
+6 −0
Original line number Diff line number Diff line
@@ -195,6 +195,12 @@ void Engine::filterOutputDevicesForStrategy(legacy_strategy strategy,
                    AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES,
                    AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, }));
        }
        // If connected to a dock, never use the device speaker for calls
        if (!availableOutputDevices.getDevicesFromTypes({AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET})
                .isEmpty()) {
            availableOutputDevices.remove(
                    availableOutputDevices.getDevicesFromTypes({AUDIO_DEVICE_OUT_SPEAKER}));
        }
        } break;
    case STRATEGY_ACCESSIBILITY: {
        // do not route accessibility prompts to a digital output currently configured with a
+2 −2
Original line number Diff line number Diff line
@@ -804,8 +804,8 @@ void Spatializer::checkSensorsState_l() {
    bool lowLatencySupported = mSupportedLatencyModes.empty()
            || (std::find(mSupportedLatencyModes.begin(), mSupportedLatencyModes.end(),
                    AUDIO_LATENCY_MODE_LOW) != mSupportedLatencyModes.end());
    if (mSupportsHeadTracking && mPoseController != nullptr && lowLatencySupported) {
        if (mNumActiveTracks > 0 && mLevel != SpatializationLevel::NONE
    if (mSupportsHeadTracking && mPoseController != nullptr) {
        if (lowLatencySupported && mNumActiveTracks > 0 && mLevel != SpatializationLevel::NONE
            && mDesiredHeadTrackingMode != HeadTrackingMode::STATIC
            && mHeadSensor != SpatializerPoseController::INVALID_SENSOR) {
            mPoseController->setHeadSensor(mHeadSensor);