audio: Use auto-generated MicrophoneInfoFw class
Replace use of manually written MicrophoneInfo class
with MicrophoneInfoFw which is generated automatically
from the AIDL definition.
Rename MicrophoneInfoData AIDL to MicrophoneInfoFw for
consistency with other framework-side AIDL types.
MicrophoneInfoFw is defined using stable shared data
types.
Bug: 263964254
Test: atest audio_aidl_conversion_tests
Change-Id: I93e4fe08fc294350c9b06f2959f84b24f31f6881
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 7bb0fd3..3b73333 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2857,7 +2857,7 @@
return mAudioManager.load();
}
-status_t AudioFlinger::getMicrophones(std::vector<media::MicrophoneInfo> *microphones)
+status_t AudioFlinger::getMicrophones(std::vector<media::MicrophoneInfoFw> *microphones)
{
AutoMutex lock(mHardwareLock);
status_t status = INVALID_OPERATION;
@@ -2870,8 +2870,12 @@
mHardwareStatus = AUDIO_HW_IDLE;
if (devStatus == NO_ERROR) {
// report success if at least one HW module supports the function.
- std::transform(mics.begin(), mics.end(), std::back_inserter(*microphones),
- [](auto& mic) { return media::MicrophoneInfo(mic); });
+ std::transform(mics.begin(), mics.end(), std::back_inserter(*microphones), [](auto& mic)
+ {
+ auto microphone =
+ legacy2aidl_audio_microphone_characteristic_t_MicrophoneInfoFw(mic);
+ return microphone.ok() ? microphone.value() : media::MicrophoneInfoFw{};
+ });
status = NO_ERROR;
}
}
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index e8133d9..9fc503b 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -281,7 +281,7 @@
bool isAudioPolicyReady() const { return mAudioPolicyReady.load(); }
- virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones);
+ virtual status_t getMicrophones(std::vector<media::MicrophoneInfoFw> *microphones);
virtual status_t setAudioHalPids(const std::vector<pid_t>& pids);
@@ -726,7 +726,7 @@
int /*audio_session_t*/ triggerSession);
virtual binder::Status stop();
virtual binder::Status getActiveMicrophones(
- std::vector<media::MicrophoneInfoData>* activeMicrophones);
+ std::vector<media::MicrophoneInfoFw>* activeMicrophones);
virtual binder::Status setPreferredMicrophoneDirection(
int /*audio_microphone_direction_t*/ direction);
virtual binder::Status setPreferredMicrophoneFieldDimension(float zoom);
diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h
index daec57e..f0a5f76 100644
--- a/services/audioflinger/RecordTracks.h
+++ b/services/audioflinger/RecordTracks.h
@@ -73,7 +73,8 @@
void setSilenced(bool silenced) { if (!isPatchTrack()) mSilenced = silenced; }
bool isSilenced() const { return mSilenced; }
- status_t getActiveMicrophones(std::vector<media::MicrophoneInfo>* activeMicrophones);
+ status_t getActiveMicrophones(
+ std::vector<media::MicrophoneInfoFw>* activeMicrophones);
status_t setPreferredMicrophoneDirection(audio_microphone_direction_t direction);
status_t setPreferredMicrophoneFieldDimension(float zoom);
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 4ca8a8e..fdf3306 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -8949,7 +8949,7 @@
}
status_t AudioFlinger::RecordThread::getActiveMicrophones(
- std::vector<media::MicrophoneInfo>* activeMicrophones)
+ std::vector<media::MicrophoneInfoFw>* activeMicrophones)
{
ALOGV("RecordThread::getActiveMicrophones");
AutoMutex _l(mLock);
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index f829efc..ddae7ae 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -1982,7 +1982,8 @@
// Sets the UID records silence
void setRecordSilenced(audio_port_handle_t portId, bool silenced);
- status_t getActiveMicrophones(std::vector<media::MicrophoneInfo>* activeMicrophones);
+ status_t getActiveMicrophones(
+ std::vector<media::MicrophoneInfoFw>* activeMicrophones);
status_t setPreferredMicrophoneDirection(audio_microphone_direction_t direction);
status_t setPreferredMicrophoneFieldDimension(float zoom);
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 382e4f9..1fbf720 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -2391,15 +2391,9 @@
}
binder::Status AudioFlinger::RecordHandle::getActiveMicrophones(
- std::vector<media::MicrophoneInfoData>* activeMicrophones) {
+ std::vector<media::MicrophoneInfoFw>* activeMicrophones) {
ALOGV("%s()", __func__);
- std::vector<media::MicrophoneInfo> mics;
- status_t status = mRecordTrack->getActiveMicrophones(&mics);
- activeMicrophones->resize(mics.size());
- for (size_t i = 0; status == OK && i < mics.size(); ++i) {
- status = mics[i].writeToParcelable(&activeMicrophones->at(i));
- }
- return binderStatusFromStatusT(status);
+ return binderStatusFromStatusT(mRecordTrack->getActiveMicrophones(activeMicrophones));
}
binder::Status AudioFlinger::RecordHandle::setPreferredMicrophoneDirection(
@@ -2719,7 +2713,7 @@
}
status_t AudioFlinger::RecordThread::RecordTrack::getActiveMicrophones(
- std::vector<media::MicrophoneInfo>* activeMicrophones)
+ std::vector<media::MicrophoneInfoFw>* activeMicrophones)
{
sp<ThreadBase> thread = mThread.promote();
if (thread != 0) {