hal: Remove storage of audio device on bitfields
Audio devices were stored in HAL on variables with
type audio_devices_t. This change removes the storage
of multiple devices on a bitfield. Device comparisons,
assigments, removal have been updated. Helper functions
have been introduced for device operations.
Change-Id: I9ce8b0f9bdc542c386cbfe45b685158cc51d47b6
diff --git a/hal/audio_extn/qaf.c b/hal/audio_extn/qaf.c
index 4ec524e..46e625d 100644
--- a/hal/audio_extn/qaf.c
+++ b/hal/audio_extn/qaf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -464,7 +464,9 @@
}
if ((p_qaf->qaf_mod[i].stream_out[QAF_OUT_OFFLOAD])
- && (p_qaf->qaf_mod[i].stream_out[QAF_OUT_OFFLOAD]->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
+ && compare_device_type(
+ &p_qaf->qaf_mod[i].stream_out[QAF_OUT_OFFLOAD]->device_list,
+ AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
adev_close_output_stream((struct audio_hw_device *)p_qaf->adev,
(struct audio_stream_out *)(p_qaf->qaf_mod[i].stream_out[QAF_OUT_OFFLOAD]));
p_qaf->qaf_mod[i].stream_out[QAF_OUT_OFFLOAD] = NULL;
@@ -525,7 +527,7 @@
config.offload_info.channel_mask = config.channel_mask = out->channel_mask;
//Device is copied from the QAF passthrough input stream.
- devices = out->devices;
+ devices = get_device_types(&out->device_list);
flags = out->flags;
ret = adev_open_output_stream((struct audio_hw_device *)p_qaf->adev,
@@ -711,7 +713,7 @@
ALOGD("%s: enter: stream(%p)usecase(%d: %s) devices(%#x)",
__func__, &out->stream, out->usecase, use_case_table[out->usecase],
- out->devices);
+ get_device_types(&out->device_list));
if (CARD_STATUS_OFFLINE == out->card_status ||
CARD_STATUS_OFFLINE == adev->card_status) {
@@ -781,7 +783,8 @@
}
}
- if ((adev->is_channel_status_set == false) && (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
+ if ((adev->is_channel_status_set == false) &&
+ compare_device_type(&out->device_list, AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
audio_utils_set_hdmi_channel_status(out, (char *)buffer, bytes);
adev->is_channel_status_set = true;
}
@@ -1637,9 +1640,9 @@
audio_devices_t devices;
if (qaf_mod->stream_in[QAF_IN_MAIN])
- devices = qaf_mod->stream_in[QAF_IN_MAIN]->devices;
+ devices = get_device_types(&qaf_mod->stream_in[QAF_IN_MAIN]->device_list);
else
- devices = qaf_mod->stream_in[QAF_IN_PCM]->devices;
+ devices = get_device_types(&qaf_mod->stream_in[QAF_IN_PCM]->device_list);
//If multi channel pcm or passthrough is already enabled then remove the hdmi flag from device.
if (p_qaf->mch_pcm_hdmi_enabled || p_qaf->passthrough_enabled) {
@@ -2348,7 +2351,7 @@
/* Setting new device information to the mm module input streams.
* This is needed if QAF module output streams are not created yet.
*/
- out->devices = val;
+ reassign_device_list(&out->device_list, val, "");
#ifndef A2DP_OFFLOAD_ENABLED
if (val == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP) {