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

Commit dea53040 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Refactor PatchPanel

Major changes:

 * since PatchPanel is internal to AudioFlinger, and has the same
   lifetime period, there is no need to use reference counting;

 * setAudioPortConfig moved to AudioFlinger;

 * store Patches in std::map instead of SortedVector, and
   directly--not as pointers;

 * move {create|clear}PatchConnections into Patch class;

 * use __func__ in logging.

Test: test basic audio functionality on taimen
Change-Id: I813fd8430a0e97cd01cc74e6b3b828b10ff5acd4
parent 03625f6e
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ AudioFlinger::AudioFlinger()
      mTotalMemory(0),
      mClientSharedHeapSize(kMinimumClientSharedHeapSizeBytes),
      mGlobalEffectEnableTime(0),
      mPatchPanel(this),
      mSystemReady(false)
{
    // unsigned instead of audio_unique_id_use_t, because ++ operator is unavailable for enum
@@ -225,8 +226,6 @@ void AudioFlinger::onFirstRef()
        }
    }

    mPatchPanel = new PatchPanel(this);

    mMode = AUDIO_MODE_NORMAL;

    gAudioFlinger = this;
@@ -1928,6 +1927,28 @@ size_t AudioFlinger::getClientSharedHeapSize() const
    return mClientSharedHeapSize;
}

status_t AudioFlinger::setAudioPortConfig(const struct audio_port_config *config)
{
    ALOGV(__func__);

    audio_module_handle_t module;
    if (config->type == AUDIO_PORT_TYPE_DEVICE) {
        module = config->ext.device.hw_module;
    } else {
        module = config->ext.mix.hw_module;
    }

    Mutex::Autolock _l(mLock);
    ssize_t index = mAudioHwDevs.indexOfKey(module);
    if (index < 0) {
        ALOGW("%s() bad hw module %d", __func__, module);
        return BAD_VALUE;
    }

    AudioHwDevice *audioHwDevice = mAudioHwDevs.valueAt(index);
    return audioHwDevice->hwDevice()->setAudioPortConfig(config);
}

audio_hw_sync_t AudioFlinger::getAudioHwSyncForSession(audio_session_t sessionId)
{
    Mutex::Autolock _l(mLock);
+2 −1
Original line number Diff line number Diff line
@@ -843,7 +843,8 @@ private:

    nsecs_t mGlobalEffectEnableTime;  // when a global effect was last enabled

    sp<PatchPanel> mPatchPanel;
    // protected by mLock
    PatchPanel mPatchPanel;
    sp<EffectsFactoryHalInterface> mEffectsFactoryHal;

    bool        mSystemReady;