Convert mask types from uint32_t to enum type
This applies to the following types:
- audio_gain_mode_t;
- audio_flags_mask_t;
- audio_channel_representation_t;
- audio_channel_mask_t;
- audio_devices_t.
Enum types are distinct thus proper overloading on the type
is possible in C++. Also, assignments to enum types are
less prone to errors.
Bug: 169889714
Test: basic audio functionality
m stagefright
atest audiopolicy_tests
Change-Id: I42506484b1d0b0482618b7314fad4c8012a06fb4
diff --git a/media/libaudiofoundation/AudioPort.cpp b/media/libaudiofoundation/AudioPort.cpp
index f988690..1846a6b 100644
--- a/media/libaudiofoundation/AudioPort.cpp
+++ b/media/libaudiofoundation/AudioPort.cpp
@@ -268,12 +268,17 @@
if ((status = parcel->readUint32(reinterpret_cast<uint32_t*>(&mFormat))) != NO_ERROR) {
return status;
}
- if ((status = parcel->readUint32(&mChannelMask)) != NO_ERROR) return status;
+ uint32_t rawChannelMask;
+ if ((status = parcel->readUint32(&rawChannelMask)) != NO_ERROR) return status;
+ mChannelMask = static_cast<audio_channel_mask_t>(rawChannelMask);
if ((status = parcel->readInt32(&mId)) != NO_ERROR) return status;
// Read mGain from parcel.
if ((status = parcel->readInt32(&mGain.index)) != NO_ERROR) return status;
- if ((status = parcel->readUint32(&mGain.mode)) != NO_ERROR) return status;
- if ((status = parcel->readUint32(&mGain.channel_mask)) != NO_ERROR) return status;
+ uint32_t rawGainMode;
+ if ((status = parcel->readUint32(&rawGainMode)) != NO_ERROR) return status;
+ mGain.mode = static_cast<audio_gain_mode_t>(rawGainMode);
+ if ((status = parcel->readUint32(&rawChannelMask)) != NO_ERROR) return status;
+ mGain.channel_mask = static_cast<audio_channel_mask_t>(rawChannelMask);
if ((status = parcel->readUint32(&mGain.ramp_duration_ms)) != NO_ERROR) return status;
std::vector<int> values;
if ((status = parcel->readInt32Vector(&values)) != NO_ERROR) return status;