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

Commit 4389ae64 authored by Robert Wu's avatar Robert Wu
Browse files

aaudio: clean up MMAP volume TODO

onVolumeChanged() passes in a list of channels and an associated
volume for each one.

However, both the sender (AudioFlinger) and the consumer (AAudio)
is not using this efficiently. AudioFlinger simply sets all the
volumes as the same value and AAudio simply uses the first value.

This CL removes the TODO and cleans up the function parameters.

Bug: 220162278
Test: OboeTester
Change-Id: I3d8b1ad7228e02e2db6d776af7f5a618fdf50a53
parent b0f71f0b
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -37,12 +37,9 @@ class MmapStreamCallback : public virtual RefBase {

    /**
     * The volume to be applied to the use case specified when opening the stream has changed
     * \param[in] channels a channel mask containing all channels the volume should be applied to.
     * \param[in] values the volume values to be applied to each channel. The size of the vector
     *                   should correspond to the channel count retrieved with
     *                   audio_channel_count_from_in_mask() or audio_channel_count_from_out_mask()
     * \param[in] volume the new target volume
     */
    virtual void onVolumeChanged(audio_channel_mask_t channels, Vector<float> values) = 0;
    virtual void onVolumeChanged(float volume) = 0;

    /**
     * The device the stream is routed to/from has changed
+1 −11
Original line number Diff line number Diff line
@@ -10261,20 +10261,10 @@ void AudioFlinger::MmapPlaybackThread::processVolume_l()
        } else {
            sp<MmapStreamCallback> callback = mCallback.promote();
            if (callback != 0) {
                int channelCount;
                if (isOutput()) {
                    channelCount = audio_channel_count_from_out_mask(mChannelMask);
                } else {
                    channelCount = audio_channel_count_from_in_mask(mChannelMask);
                }
                Vector<float> values;
                for (int i = 0; i < channelCount; i++) {
                    values.add(volume);
                }
                mHalVolFloat = volume; // SW volume control worked, so update value.
                mNoCallbackWarningCount = 0;
                mLock.unlock();
                callback->onVolumeChanged(mChannelMask, values);
                callback->onVolumeChanged(volume);
                mLock.lock();
            } else {
                if (mNoCallbackWarningCount < kMaxNoCallbackWarnings) {
+2 −6
Original line number Diff line number Diff line
@@ -358,12 +358,8 @@ void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) {
    asyncTask.detach();
}

void AAudioServiceEndpointMMAP::onVolumeChanged(audio_channel_mask_t channels,
                                              android::Vector<float> values) {
    // TODO Do we really need a different volume for each channel?
    // We get called with an array filled with a single value!
    float volume = values[0];
    ALOGD("%s() volume[0] = %f", __func__, volume);
void AAudioServiceEndpointMMAP::onVolumeChanged(float volume) {
    ALOGD("%s() volume = %f", __func__, volume);
    std::lock_guard<std::mutex> lock(mLockStreams);
    for(const auto& stream : mRegisteredStreams) {
        stream->onVolumeChanged(volume);
+1 −2
Original line number Diff line number Diff line
@@ -77,8 +77,7 @@ public:
    // -------------- Callback functions for MmapStreamCallback ---------------------
    void onTearDown(audio_port_handle_t portHandle) override;

    void onVolumeChanged(audio_channel_mask_t channels,
                         android::Vector<float> values) override;
    void onVolumeChanged(float volume) override;

    void onRoutingChanged(audio_port_handle_t portHandle) override;
    // ------------------------------------------------------------------------------