CSD: enable CSD for MMap threads
Using the buffer provided by the AAudio service to add values to the
sound dosage.
Test: OboeTester with AAudio and MMap
Bug: 264254430
Change-Id: I38b7d3b69bc8d6923f848bc504c6290ae1961cbc
diff --git a/services/audioflinger/MelReporter.cpp b/services/audioflinger/MelReporter.cpp
index cfa02bb..52af56f 100644
--- a/services/audioflinger/MelReporter.cpp
+++ b/services/audioflinger/MelReporter.cpp
@@ -170,8 +170,8 @@
}
void AudioFlinger::MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) {
- auto thread = mAudioFlinger.checkPlaybackThread_l(patch.streamHandle);
- if (thread == nullptr) {
+ auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle);
+ if (outputThread == nullptr) {
ALOGE("%s cannot find thread for stream handle %d", __func__, patch.streamHandle);
return;
}
@@ -180,13 +180,16 @@
++mActiveDevices[deviceHandle];
ALOGI("%s add stream %d that uses device %d for CSD, nr of streams: %d", __func__,
patch.streamHandle, deviceHandle, mActiveDevices[deviceHandle]);
- thread->startMelComputation(mSoundDoseManager->getOrCreateProcessorForDevice(
- deviceHandle,
- patch.streamHandle,
- thread->mSampleRate,
- thread->mChannelCount,
- thread->mFormat));
+
+ if (outputThread != nullptr) {
+ outputThread->startMelComputation_l(mSoundDoseManager->getOrCreateProcessorForDevice(
+ deviceHandle,
+ patch.streamHandle,
+ outputThread->mSampleRate,
+ outputThread->mChannelCount,
+ outputThread->mFormat));
}
+ }
}
void AudioFlinger::MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) {
@@ -229,7 +232,8 @@
return;
}
- auto thread = mAudioFlinger.checkPlaybackThread_l(patch.streamHandle);
+ auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle);
+
ALOGV("%s: stop MEL for stream id: %d", __func__, patch.streamHandle);
for (const auto& deviceId : patch.deviceHandles) {
if (mActiveDevices[deviceId] > 0) {
@@ -243,8 +247,8 @@
}
mSoundDoseManager->removeStreamProcessor(patch.streamHandle);
- if (thread != nullptr) {
- thread->stopMelComputation();
+ if (outputThread != nullptr) {
+ outputThread->stopMelComputation_l();
}
}