Loading services/audioflinger/AudioFlinger.cpp +19 −1 Original line number Diff line number Diff line Loading @@ -1492,6 +1492,20 @@ void AudioFlinger::forwardParametersToDownstreamPatches_l( } } // Update downstream patches for all playback threads attached to an MSD module void AudioFlinger::updateDownStreamPatches_l(const struct audio_patch *patch, const std::set<audio_io_handle_t> streams) { for (const audio_io_handle_t stream : streams) { PlaybackThread *playbackThread = checkPlaybackThread_l(stream); if (playbackThread == nullptr || !playbackThread->isMsdDevice()) { continue; } playbackThread->setDownStreamPatch(patch); playbackThread->sendIoConfigEvent(AUDIO_OUTPUT_CONFIG_CHANGED); } } // Filter reserved keys from setParameters() before forwarding to audio HAL or acting upon. // Some keys are used for audio routing and audio path configuration and should be reserved for use // by audio policy and audio flinger for functional, privacy and security reasons. Loading Loading @@ -2575,7 +2589,11 @@ sp<AudioFlinger::ThreadBase> AudioFlinger::openOutput_l(audio_module_handle_t mo *output, thread.get()); } mPlaybackThreads.add(*output, thread); mPatchPanel.notifyStreamOpened(outHwDev, *output); struct audio_patch patch; mPatchPanel.notifyStreamOpened(outHwDev, *output, &patch); if (thread->isMsdDevice()) { thread->setDownStreamPatch(&patch); } return thread; } } Loading services/audioflinger/AudioFlinger.h +3 −0 Original line number Diff line number Diff line Loading @@ -292,6 +292,9 @@ public: status_t removeEffectFromHal(audio_port_handle_t deviceId, audio_module_handle_t hwModuleId, sp<EffectHalInterface> effect); void updateDownStreamPatches_l(const struct audio_patch *patch, const std::set<audio_io_handle_t> streams); private: // FIXME The 400 is temporarily too high until a leak of writers in media.log is fixed. static const size_t kLogMemorySize = 400 * 1024; Loading services/audioflinger/PatchPanel.cpp +17 −3 Original line number Diff line number Diff line Loading @@ -437,7 +437,7 @@ exit: mAudioFlinger.mDeviceEffectManager.createAudioPatch(*handle, newPatch); mPatches.insert(std::make_pair(*handle, std::move(newPatch))); if (insertedModule != AUDIO_MODULE_HANDLE_NONE) { addSoftwarePatchToInsertedModules(insertedModule, *handle); addSoftwarePatchToInsertedModules(insertedModule, *handle, &newPatch.mAudioPatch); } } else { newPatch.clearConnections(this); Loading Loading @@ -803,10 +803,20 @@ status_t AudioFlinger::PatchPanel::getDownstreamSoftwarePatches( } void AudioFlinger::PatchPanel::notifyStreamOpened( AudioHwDevice *audioHwDevice, audio_io_handle_t stream) AudioHwDevice *audioHwDevice, audio_io_handle_t stream, struct audio_patch *patch) { if (audioHwDevice->isInsert()) { mInsertedModules[audioHwDevice->handle()].streams.insert(stream); if (patch != nullptr) { std::vector <SoftwarePatch> swPatches; getDownstreamSoftwarePatches(stream, &swPatches); if (swPatches.size() > 0) { auto iter = mPatches.find(swPatches[0].getPatchHandle()); if (iter != mPatches.end()) { *patch = iter->second.mAudioPatch; } } } } } Loading Loading @@ -835,9 +845,13 @@ sp<DeviceHalInterface> AudioFlinger::PatchPanel::findHwDeviceByModule(audio_modu } void AudioFlinger::PatchPanel::addSoftwarePatchToInsertedModules( audio_module_handle_t module, audio_patch_handle_t handle) audio_module_handle_t module, audio_patch_handle_t handle, const struct audio_patch *patch) { mInsertedModules[module].sw_patches.insert(handle); if (!mInsertedModules[module].streams.empty()) { mAudioFlinger.updateDownStreamPatches_l(patch, mInsertedModules[module].streams); } } void AudioFlinger::PatchPanel::removeSoftwarePatchFromInsertedModules( Loading services/audioflinger/PatchPanel.h +4 −2 Original line number Diff line number Diff line Loading @@ -71,7 +71,8 @@ public: std::vector<SoftwarePatch> *patches) const; // Notifies patch panel about all opened and closed streams. void notifyStreamOpened(AudioHwDevice *audioHwDevice, audio_io_handle_t stream); void notifyStreamOpened(AudioHwDevice *audioHwDevice, audio_io_handle_t stream, struct audio_patch *patch); void notifyStreamClosed(audio_io_handle_t stream); void dump(int fd) const; Loading Loading @@ -226,7 +227,8 @@ private: AudioHwDevice* findAudioHwDeviceByModule(audio_module_handle_t module); sp<DeviceHalInterface> findHwDeviceByModule(audio_module_handle_t module); void addSoftwarePatchToInsertedModules( audio_module_handle_t module, audio_patch_handle_t handle); audio_module_handle_t module, audio_patch_handle_t handle, const struct audio_patch *patch); void removeSoftwarePatchFromInsertedModules(audio_patch_handle_t handle); void erasePatch(audio_patch_handle_t handle); Loading services/audioflinger/Threads.cpp +8 −3 Original line number Diff line number Diff line Loading @@ -1876,7 +1876,8 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge // index 0 is reserved for normal mixer's submix mFastTrackAvailMask(((1 << FastMixerState::sMaxFastTracks) - 1) & ~1), mHwSupportsPause(false), mHwPaused(false), mFlushPending(false), mLeftVolFloat(-1.0), mRightVolFloat(-1.0) mLeftVolFloat(-1.0), mRightVolFloat(-1.0), mDownStreamPatch{} { snprintf(mThreadName, kThreadNameLength, "AudioOut_%X", id); mNBLogWriter = audioFlinger->newWriter_l(kLogSize, mThreadName); Loading Loading @@ -2660,12 +2661,16 @@ void AudioFlinger::PlaybackThread::ioConfigChanged(audio_io_config_event event, ALOGV("PlaybackThread::ioConfigChanged, thread %p, event %d", this, event); desc->mIoHandle = mId; struct audio_patch patch = mPatch; if (isMsdDevice()) { patch = mDownStreamPatch; } switch (event) { case AUDIO_OUTPUT_OPENED: case AUDIO_OUTPUT_REGISTERED: case AUDIO_OUTPUT_CONFIG_CHANGED: desc->mPatch = mPatch; desc->mPatch = patch; desc->mChannelMask = mChannelMask; desc->mSamplingRate = mSampleRate; desc->mFormat = mFormat; Loading @@ -2675,7 +2680,7 @@ void AudioFlinger::PlaybackThread::ioConfigChanged(audio_io_config_event event, desc->mLatency = latency_l(); break; case AUDIO_CLIENT_STARTED: desc->mPatch = mPatch; desc->mPatch = patch; desc->mPortId = portId; break; case AUDIO_OUTPUT_CLOSED: Loading Loading
services/audioflinger/AudioFlinger.cpp +19 −1 Original line number Diff line number Diff line Loading @@ -1492,6 +1492,20 @@ void AudioFlinger::forwardParametersToDownstreamPatches_l( } } // Update downstream patches for all playback threads attached to an MSD module void AudioFlinger::updateDownStreamPatches_l(const struct audio_patch *patch, const std::set<audio_io_handle_t> streams) { for (const audio_io_handle_t stream : streams) { PlaybackThread *playbackThread = checkPlaybackThread_l(stream); if (playbackThread == nullptr || !playbackThread->isMsdDevice()) { continue; } playbackThread->setDownStreamPatch(patch); playbackThread->sendIoConfigEvent(AUDIO_OUTPUT_CONFIG_CHANGED); } } // Filter reserved keys from setParameters() before forwarding to audio HAL or acting upon. // Some keys are used for audio routing and audio path configuration and should be reserved for use // by audio policy and audio flinger for functional, privacy and security reasons. Loading Loading @@ -2575,7 +2589,11 @@ sp<AudioFlinger::ThreadBase> AudioFlinger::openOutput_l(audio_module_handle_t mo *output, thread.get()); } mPlaybackThreads.add(*output, thread); mPatchPanel.notifyStreamOpened(outHwDev, *output); struct audio_patch patch; mPatchPanel.notifyStreamOpened(outHwDev, *output, &patch); if (thread->isMsdDevice()) { thread->setDownStreamPatch(&patch); } return thread; } } Loading
services/audioflinger/AudioFlinger.h +3 −0 Original line number Diff line number Diff line Loading @@ -292,6 +292,9 @@ public: status_t removeEffectFromHal(audio_port_handle_t deviceId, audio_module_handle_t hwModuleId, sp<EffectHalInterface> effect); void updateDownStreamPatches_l(const struct audio_patch *patch, const std::set<audio_io_handle_t> streams); private: // FIXME The 400 is temporarily too high until a leak of writers in media.log is fixed. static const size_t kLogMemorySize = 400 * 1024; Loading
services/audioflinger/PatchPanel.cpp +17 −3 Original line number Diff line number Diff line Loading @@ -437,7 +437,7 @@ exit: mAudioFlinger.mDeviceEffectManager.createAudioPatch(*handle, newPatch); mPatches.insert(std::make_pair(*handle, std::move(newPatch))); if (insertedModule != AUDIO_MODULE_HANDLE_NONE) { addSoftwarePatchToInsertedModules(insertedModule, *handle); addSoftwarePatchToInsertedModules(insertedModule, *handle, &newPatch.mAudioPatch); } } else { newPatch.clearConnections(this); Loading Loading @@ -803,10 +803,20 @@ status_t AudioFlinger::PatchPanel::getDownstreamSoftwarePatches( } void AudioFlinger::PatchPanel::notifyStreamOpened( AudioHwDevice *audioHwDevice, audio_io_handle_t stream) AudioHwDevice *audioHwDevice, audio_io_handle_t stream, struct audio_patch *patch) { if (audioHwDevice->isInsert()) { mInsertedModules[audioHwDevice->handle()].streams.insert(stream); if (patch != nullptr) { std::vector <SoftwarePatch> swPatches; getDownstreamSoftwarePatches(stream, &swPatches); if (swPatches.size() > 0) { auto iter = mPatches.find(swPatches[0].getPatchHandle()); if (iter != mPatches.end()) { *patch = iter->second.mAudioPatch; } } } } } Loading Loading @@ -835,9 +845,13 @@ sp<DeviceHalInterface> AudioFlinger::PatchPanel::findHwDeviceByModule(audio_modu } void AudioFlinger::PatchPanel::addSoftwarePatchToInsertedModules( audio_module_handle_t module, audio_patch_handle_t handle) audio_module_handle_t module, audio_patch_handle_t handle, const struct audio_patch *patch) { mInsertedModules[module].sw_patches.insert(handle); if (!mInsertedModules[module].streams.empty()) { mAudioFlinger.updateDownStreamPatches_l(patch, mInsertedModules[module].streams); } } void AudioFlinger::PatchPanel::removeSoftwarePatchFromInsertedModules( Loading
services/audioflinger/PatchPanel.h +4 −2 Original line number Diff line number Diff line Loading @@ -71,7 +71,8 @@ public: std::vector<SoftwarePatch> *patches) const; // Notifies patch panel about all opened and closed streams. void notifyStreamOpened(AudioHwDevice *audioHwDevice, audio_io_handle_t stream); void notifyStreamOpened(AudioHwDevice *audioHwDevice, audio_io_handle_t stream, struct audio_patch *patch); void notifyStreamClosed(audio_io_handle_t stream); void dump(int fd) const; Loading Loading @@ -226,7 +227,8 @@ private: AudioHwDevice* findAudioHwDeviceByModule(audio_module_handle_t module); sp<DeviceHalInterface> findHwDeviceByModule(audio_module_handle_t module); void addSoftwarePatchToInsertedModules( audio_module_handle_t module, audio_patch_handle_t handle); audio_module_handle_t module, audio_patch_handle_t handle, const struct audio_patch *patch); void removeSoftwarePatchFromInsertedModules(audio_patch_handle_t handle); void erasePatch(audio_patch_handle_t handle); Loading
services/audioflinger/Threads.cpp +8 −3 Original line number Diff line number Diff line Loading @@ -1876,7 +1876,8 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge // index 0 is reserved for normal mixer's submix mFastTrackAvailMask(((1 << FastMixerState::sMaxFastTracks) - 1) & ~1), mHwSupportsPause(false), mHwPaused(false), mFlushPending(false), mLeftVolFloat(-1.0), mRightVolFloat(-1.0) mLeftVolFloat(-1.0), mRightVolFloat(-1.0), mDownStreamPatch{} { snprintf(mThreadName, kThreadNameLength, "AudioOut_%X", id); mNBLogWriter = audioFlinger->newWriter_l(kLogSize, mThreadName); Loading Loading @@ -2660,12 +2661,16 @@ void AudioFlinger::PlaybackThread::ioConfigChanged(audio_io_config_event event, ALOGV("PlaybackThread::ioConfigChanged, thread %p, event %d", this, event); desc->mIoHandle = mId; struct audio_patch patch = mPatch; if (isMsdDevice()) { patch = mDownStreamPatch; } switch (event) { case AUDIO_OUTPUT_OPENED: case AUDIO_OUTPUT_REGISTERED: case AUDIO_OUTPUT_CONFIG_CHANGED: desc->mPatch = mPatch; desc->mPatch = patch; desc->mChannelMask = mChannelMask; desc->mSamplingRate = mSampleRate; desc->mFormat = mFormat; Loading @@ -2675,7 +2680,7 @@ void AudioFlinger::PlaybackThread::ioConfigChanged(audio_io_config_event event, desc->mLatency = latency_l(); break; case AUDIO_CLIENT_STARTED: desc->mPatch = mPatch; desc->mPatch = patch; desc->mPortId = portId; break; case AUDIO_OUTPUT_CLOSED: Loading