Loading services/audioflinger/PatchPanel.cpp +16 −8 Original line number Diff line number Diff line Loading @@ -111,7 +111,8 @@ status_t AudioFlinger::PatchPanel::getAudioPort(struct audio_port *port __unused /* Connect a patch between several source and sink ports */ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *patch, audio_patch_handle_t *handle) audio_patch_handle_t *handle, bool endpointPatch) { if (handle == NULL || patch == NULL) { return BAD_VALUE; Loading Loading @@ -174,7 +175,7 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa } } Patch newPatch{*patch}; Patch newPatch{*patch, endpointPatch}; audio_module_handle_t insertedModule = AUDIO_MODULE_HANDLE_NONE; switch (patch->sources[0].type) { Loading Loading @@ -396,12 +397,17 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa } // remove stale audio patch with same output as source if any // Prevent to remove endpoint patches (involved in a SwBridge) // Prevent to remove AudioPatch used to route an output involved in an endpoint. if (!endpointPatch) { for (auto& iter : mPatches) { if (iter.second.mAudioPatch.sources[0].ext.mix.handle == thread->id()) { if (iter.second.mAudioPatch.sources[0].ext.mix.handle == thread->id() && !iter.second.mIsEndpointPatch) { erasePatch(iter.first); break; } } } } break; default: status = BAD_VALUE; Loading Loading @@ -435,7 +441,8 @@ status_t AudioFlinger::PatchPanel::Patch::createConnections(PatchPanel *panel) status_t status = panel->createAudioPatch( PatchBuilder().addSource(mAudioPatch.sources[0]). addSink(mRecord.thread(), { .source = AUDIO_SOURCE_MIC }).patch(), mRecord.handlePtr()); mRecord.handlePtr(), true /*endpointPatch*/); if (status != NO_ERROR) { *mRecord.handlePtr() = AUDIO_PATCH_HANDLE_NONE; return status; Loading @@ -445,7 +452,8 @@ status_t AudioFlinger::PatchPanel::Patch::createConnections(PatchPanel *panel) if (mAudioPatch.num_sinks != 0) { status = panel->createAudioPatch( PatchBuilder().addSource(mPlayback.thread()).addSink(mAudioPatch.sinks[0]).patch(), mPlayback.handlePtr()); mPlayback.handlePtr(), true /*endpointPatch*/); if (status != NO_ERROR) { *mPlayback.handlePtr() = AUDIO_PATCH_HANDLE_NONE; return status; Loading services/audioflinger/PatchPanel.h +7 −2 Original line number Diff line number Diff line Loading @@ -56,7 +56,8 @@ public: /* Create a patch between several source and sink ports */ status_t createAudioPatch(const struct audio_patch *patch, audio_patch_handle_t *handle); audio_patch_handle_t *handle, bool endpointPatch = false); /* Release a patch */ status_t releaseAudioPatch(audio_patch_handle_t handle); Loading Loading @@ -161,7 +162,8 @@ public: class Patch final { public: explicit Patch(const struct audio_patch &patch) : mAudioPatch(patch) {} Patch(const struct audio_patch &patch, bool endpointPatch) : mAudioPatch(patch), mIsEndpointPatch(endpointPatch) {} Patch() = default; ~Patch(); Patch(const Patch& other) noexcept { Loading @@ -170,6 +172,7 @@ public: mPlayback = other.mPlayback; mRecord = other.mRecord; mThread = other.mThread; mIsEndpointPatch = other.mIsEndpointPatch; } Patch(Patch&& other) noexcept { swap(other); } Patch& operator=(Patch&& other) noexcept { Loading @@ -184,6 +187,7 @@ public: swap(mPlayback, other.mPlayback); swap(mRecord, other.mRecord); swap(mThread, other.mThread); swap(mIsEndpointPatch, other.mIsEndpointPatch); } friend void swap(Patch &a, Patch &b) noexcept { Loading Loading @@ -218,6 +222,7 @@ public: Endpoint<RecordThread, RecordThread::PatchRecord> mRecord; wp<ThreadBase> mThread; bool mIsEndpointPatch; }; // Call with AudioFlinger mLock held Loading Loading
services/audioflinger/PatchPanel.cpp +16 −8 Original line number Diff line number Diff line Loading @@ -111,7 +111,8 @@ status_t AudioFlinger::PatchPanel::getAudioPort(struct audio_port *port __unused /* Connect a patch between several source and sink ports */ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *patch, audio_patch_handle_t *handle) audio_patch_handle_t *handle, bool endpointPatch) { if (handle == NULL || patch == NULL) { return BAD_VALUE; Loading Loading @@ -174,7 +175,7 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa } } Patch newPatch{*patch}; Patch newPatch{*patch, endpointPatch}; audio_module_handle_t insertedModule = AUDIO_MODULE_HANDLE_NONE; switch (patch->sources[0].type) { Loading Loading @@ -396,12 +397,17 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa } // remove stale audio patch with same output as source if any // Prevent to remove endpoint patches (involved in a SwBridge) // Prevent to remove AudioPatch used to route an output involved in an endpoint. if (!endpointPatch) { for (auto& iter : mPatches) { if (iter.second.mAudioPatch.sources[0].ext.mix.handle == thread->id()) { if (iter.second.mAudioPatch.sources[0].ext.mix.handle == thread->id() && !iter.second.mIsEndpointPatch) { erasePatch(iter.first); break; } } } } break; default: status = BAD_VALUE; Loading Loading @@ -435,7 +441,8 @@ status_t AudioFlinger::PatchPanel::Patch::createConnections(PatchPanel *panel) status_t status = panel->createAudioPatch( PatchBuilder().addSource(mAudioPatch.sources[0]). addSink(mRecord.thread(), { .source = AUDIO_SOURCE_MIC }).patch(), mRecord.handlePtr()); mRecord.handlePtr(), true /*endpointPatch*/); if (status != NO_ERROR) { *mRecord.handlePtr() = AUDIO_PATCH_HANDLE_NONE; return status; Loading @@ -445,7 +452,8 @@ status_t AudioFlinger::PatchPanel::Patch::createConnections(PatchPanel *panel) if (mAudioPatch.num_sinks != 0) { status = panel->createAudioPatch( PatchBuilder().addSource(mPlayback.thread()).addSink(mAudioPatch.sinks[0]).patch(), mPlayback.handlePtr()); mPlayback.handlePtr(), true /*endpointPatch*/); if (status != NO_ERROR) { *mPlayback.handlePtr() = AUDIO_PATCH_HANDLE_NONE; return status; Loading
services/audioflinger/PatchPanel.h +7 −2 Original line number Diff line number Diff line Loading @@ -56,7 +56,8 @@ public: /* Create a patch between several source and sink ports */ status_t createAudioPatch(const struct audio_patch *patch, audio_patch_handle_t *handle); audio_patch_handle_t *handle, bool endpointPatch = false); /* Release a patch */ status_t releaseAudioPatch(audio_patch_handle_t handle); Loading Loading @@ -161,7 +162,8 @@ public: class Patch final { public: explicit Patch(const struct audio_patch &patch) : mAudioPatch(patch) {} Patch(const struct audio_patch &patch, bool endpointPatch) : mAudioPatch(patch), mIsEndpointPatch(endpointPatch) {} Patch() = default; ~Patch(); Patch(const Patch& other) noexcept { Loading @@ -170,6 +172,7 @@ public: mPlayback = other.mPlayback; mRecord = other.mRecord; mThread = other.mThread; mIsEndpointPatch = other.mIsEndpointPatch; } Patch(Patch&& other) noexcept { swap(other); } Patch& operator=(Patch&& other) noexcept { Loading @@ -184,6 +187,7 @@ public: swap(mPlayback, other.mPlayback); swap(mRecord, other.mRecord); swap(mThread, other.mThread); swap(mIsEndpointPatch, other.mIsEndpointPatch); } friend void swap(Patch &a, Patch &b) noexcept { Loading Loading @@ -218,6 +222,7 @@ public: Endpoint<RecordThread, RecordThread::PatchRecord> mRecord; wp<ThreadBase> mThread; bool mIsEndpointPatch; }; // Call with AudioFlinger mLock held Loading