Use system/audio to/from string converters in TypeConverter
Use of system functions eliminates the need for listing all enum
values in TypeConverter tables.
Slight changes in the converting functions:
1. 'channelMaskFromString' function now also accepts indexed
masks.
2. Fixed UB in 'formatFromString' function.
3. Removed 'deviceFromString' function, use
'DeviceConverter::fromString' instead.
Replaced direct includes of 'system/audio-base.h' with
includes of 'system/audio.h'.
Bug: 142480271
Test: m
Test: atest libmedia_helper_tests
Change-Id: Ia0e725026be80621bdc797299e63e134419b2b3d
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 46969ef..c1c3c44 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1914,9 +1914,8 @@
: AUDIO_DEVICE_NONE));
}
- // ++ operator does not compile
- for (audio_stream_type_t stream = AUDIO_STREAM_MIN; stream < AUDIO_STREAM_FOR_POLICY_CNT;
- stream = (audio_stream_type_t) (stream + 1)) {
+ for (int i = AUDIO_STREAM_MIN; i < AUDIO_STREAM_FOR_POLICY_CNT; ++i) {
+ const audio_stream_type_t stream{static_cast<audio_stream_type_t>(i)};
mStreamTypes[stream].volume = 0.0f;
mStreamTypes[stream].mute = mAudioFlinger->streamMute_l(stream);
}