CSD: report the new csd values to AudioService
We are reporting with every new callback from the MelProcessor the
values that lead to a change of at least 1% of CSD.
Test: manual, logs
Bug: 257238734
Change-Id: I3f0c39c9fda62bfccd3401e065586ca8621627ca
diff --git a/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
index 57a4133..df3dec7 100644
--- a/media/libaudioclient/Android.bp
+++ b/media/libaudioclient/Android.bp
@@ -453,6 +453,7 @@
"aidl/android/media/IAudioTrackCallback.aidl",
"aidl/android/media/ISoundDoseCallback.aidl",
+ "aidl/android/media/SoundDoseRecord.aidl",
],
imports: [
"android.media.audio.common.types-V2",
@@ -551,6 +552,7 @@
local_include_dir: "aidl",
srcs: [
"aidl/android/media/ISoundDoseCallback.aidl",
+ "aidl/android/media/SoundDoseRecord.aidl",
],
double_loadable: true,
diff --git a/media/libaudioclient/aidl/android/media/ISoundDoseCallback.aidl b/media/libaudioclient/aidl/android/media/ISoundDoseCallback.aidl
index 3edf681..7e59409 100644
--- a/media/libaudioclient/aidl/android/media/ISoundDoseCallback.aidl
+++ b/media/libaudioclient/aidl/android/media/ISoundDoseCallback.aidl
@@ -16,6 +16,8 @@
package android.media;
+import android.media.SoundDoseRecord;
+
/**
* Interface used to push the sound dose related information from the audio
* server to the AudioService#SoundDoseHelper.
@@ -23,4 +25,11 @@
interface ISoundDoseCallback {
/** Called whenever the momentary exposure exceeds the RS2 value. */
oneway void onMomentaryExposure(float currentMel, int deviceId);
+
+ /**
+ * Notifies that the CSD value has changed. The currentCsd is normalized
+ * with value 1 representing 100% of sound dose. SoundDoseRecord represents
+ * the newest record that lead to the new currentCsd.
+ */
+ oneway void onNewCsdValue(float currentCsd, in SoundDoseRecord[] records);
}
diff --git a/media/libaudioclient/aidl/android/media/SoundDoseRecord.aidl b/media/libaudioclient/aidl/android/media/SoundDoseRecord.aidl
new file mode 100644
index 0000000..94b8ce2
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/SoundDoseRecord.aidl
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media;
+
+/** Record containing information about the computed sound dose. */
+parcelable SoundDoseRecord {
+ /**
+ * Corresponds to the time in seconds when the CSD value is calculated from.
+ * Values should be consistent and referenced from the same clock (e.g.: monotonic)
+ */
+ long timestamp;
+ /** Corresponds to the duration that leads to the CSD value. */
+ int duration;
+ /** The actual contribution to the CSD computation normalized: 1.f is 100%CSD. */
+ float value;
+ /** The average MEL value in this time frame that lead to this CSD value. */
+ float averageMel;
+}