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

Unverified Commit 7935d121 authored by Michael Bestas's avatar Michael Bestas
Browse files

Merge tag 'android-13.0.0_r8' into staging/lineage-20.0_merge-android-13.0.0_r8

Android 13.0.0 Release 8 (TP1A.221005.003)

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCYzModQAKCRDorT+BmrEO
# eCTPAJwPSw5q3dQXMOkqCI1RmKSQHwAPaACfZOVRknlNff11HW60DmYwRQvmmuU=
# =bOsD
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Sep 27 19:44:37 2022 EEST
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 1312 signatures in the past
#      11 months.  Encrypted 4 messages in the past 8 months.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381  0964 E8AD 3F81 9AB1 0E78

# By Jean-Michel Trivi (1) and others
# Via Android Build Coastguard Worker
* tag 'android-13.0.0_r8':
  MediaPlayer: fix channel mask handling
  Add missing bounds checks
  Cache MMAP client silenced state.

Change-Id: If1a2314182bce74f5eb0ac614295df70835d3a0f
parents 792eeb91 b4b328f2
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -1946,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));
+4 −3
Original line number Diff line number Diff line
@@ -618,13 +618,14 @@ void AAVCAssembler::submitAccessUnit() {

int32_t AAVCAssembler::pickStartSeq(const Queue *queue,
        uint32_t first, int64_t play, int64_t jit) {
    CHECK(!queue->empty());
    // pick the first sequence number has the start bit.
    sp<ABuffer> buffer = *(queue->begin());
    int32_t firstSeqNo = buffer->int32Data();

    // This only works for FU-A type & non-start sequence
    unsigned nalType = buffer->data()[0] & 0x1f;
    if (nalType != 28 || buffer->data()[1] & 0x80) {
    int32_t nalType = buffer->size() >= 1 ? buffer->data()[0] & 0x1f : -1;
    if (nalType != 28 || (buffer->size() >= 2 && buffer->data()[1] & 0x80)) {
        return firstSeqNo;
    }

@@ -634,7 +635,7 @@ int32_t AAVCAssembler::pickStartSeq(const Queue *queue,
        if (rtpTime + jit >= play) {
            break;
        }
        if ((data[1] & 0x80)) {
        if (it->size() >= 2 && (data[1] & 0x80)) {
            const int32_t seqNo = it->int32Data();
            ALOGE("finding [HEAD] pkt. \t Seq# (%d ~ )[%d", firstSeqNo, seqNo);
            firstSeqNo = seqNo;
+12 −0
Original line number Diff line number Diff line
@@ -9560,6 +9560,12 @@ status_t AudioFlinger::MmapThread::start(const AudioClient& client,
    if (isOutput()) {
        ret = AudioSystem::startOutput(portId);
    } else {
        {
            // Add the track record before starting input so that the silent status for the
            // client can be cached.
            Mutex::Autolock _l(mLock);
            setClientSilencedState_l(portId, false /*silenced*/);
        }
        ret = AudioSystem::startInput(portId);
    }

@@ -9578,6 +9584,7 @@ status_t AudioFlinger::MmapThread::start(const AudioClient& client,
        } else {
            mHalStream->stop();
        }
        eraseClientSilencedState_l(portId);
        return PERMISSION_DENIED;
    }

@@ -9586,6 +9593,9 @@ status_t AudioFlinger::MmapThread::start(const AudioClient& client,
                                        mChannelMask, mSessionId, isOutput(),
                                        client.attributionSource,
                                        IPCThreadState::self()->getCallingPid(), portId);
    if (!isOutput()) {
        track->setSilenced_l(isClientSilenced_l(portId));
    }

    if (isOutput()) {
        // force volume update when a new track is added
@@ -9643,6 +9653,7 @@ status_t AudioFlinger::MmapThread::stop(audio_port_handle_t handle)
    }

    mActiveTracks.remove(track);
    eraseClientSilencedState_l(track->portId());

    mLock.unlock();
    if (isOutput()) {
@@ -10433,6 +10444,7 @@ void AudioFlinger::MmapCaptureThread::setRecordSilenced(audio_port_handle_t port
            broadcast_l();
        }
    }
    setClientSilencedIfExists_l(portId, silenced);
}

void AudioFlinger::MmapCaptureThread::toAudioPortConfig(struct audio_port_config *config)
+21 −0
Original line number Diff line number Diff line
@@ -2057,6 +2057,26 @@ class MmapThread : public ThreadBase

    virtual     bool        isStreamInitialized() { return false; }

                void        setClientSilencedState_l(audio_port_handle_t portId, bool silenced) {
                                mClientSilencedStates[portId] = silenced;
                            }

                size_t      eraseClientSilencedState_l(audio_port_handle_t portId) {
                                return mClientSilencedStates.erase(portId);
                            }

                bool        isClientSilenced_l(audio_port_handle_t portId) const {
                                const auto it = mClientSilencedStates.find(portId);
                                return it != mClientSilencedStates.end() ? it->second : false;
                            }

                void        setClientSilencedIfExists_l(audio_port_handle_t portId, bool silenced) {
                                const auto it = mClientSilencedStates.find(portId);
                                if (it != mClientSilencedStates.end()) {
                                    it->second = silenced;
                                }
                            }

 protected:
                void        dumpInternals_l(int fd, const Vector<String16>& args) override;
                void        dumpTracks_l(int fd, const Vector<String16>& args) override;
@@ -2076,6 +2096,7 @@ class MmapThread : public ThreadBase
                AudioHwDevice* const    mAudioHwDev;
                ActiveTracks<MmapTrack> mActiveTracks;
                float                   mHalVolFloat;
                std::map<audio_port_handle_t, bool> mClientSilencedStates;

                int32_t                 mNoCallbackWarningCount;
     static     constexpr int32_t       kMaxNoCallbackWarnings = 5;