Skip to content

Commit 7948516

Browse files
audio: add get_micropones() function
The Google VTS tests for Android VtsHalAudioV5_0Target(GetMicrophonesTest) needs to use pointer of function (*get_micropones)() which is not initialized and function adev_get_microphones() required for initialization witch is not implemented in tinyhal. The analysis of the implementation of the audio hal for Qualcomm (https://android.googlesource.com/platform/hardware/qcom/audio/+/refs/heads/ master/hal/audio_hw.c) and Goldfish (https://android.googlesource.com/device/generic/goldfish/+/dc18a59%5E%21/) have been made. The implementation similar to Goldfish(stub) has been chosen as basic. Function adev_get_microphones() was implemented as stub function that will expand in the future. This function fill array audio_microphone_characteristic_t with default microphone information. Signed-off-by: Anton Dehtiarov <anton.dehtiarov@globallogic.com>
1 parent 5f03d4a commit 7948516

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

audio/audio_hw.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,6 +2036,48 @@ static int do_init_in_pcm(struct stream_in_pcm *in,
20362036
return 0;
20372037
}
20382038

2039+
static int adev_get_microphones(const struct audio_hw_device *dev,
2040+
struct audio_microphone_characteristic_t *mic_array,
2041+
size_t *mic_count)
2042+
{
2043+
if (mic_count == NULL) {
2044+
return -ENOSYS;
2045+
}
2046+
2047+
if (*mic_count == 0) {
2048+
*mic_count = 1;
2049+
return 0;
2050+
}
2051+
2052+
if (mic_array == NULL) {
2053+
return -ENOSYS;
2054+
}
2055+
2056+
strncpy(mic_array->device_id, "mic_generic", AUDIO_MICROPHONE_ID_MAX_LEN - 1);
2057+
mic_array->device = AUDIO_DEVICE_IN_BUILTIN_MIC;
2058+
strncpy(mic_array->address, AUDIO_BOTTOM_MICROPHONE_ADDRESS,
2059+
AUDIO_DEVICE_MAX_ADDRESS_LEN - 1);
2060+
memset(mic_array->channel_mapping, AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED,
2061+
sizeof(mic_array->channel_mapping));
2062+
mic_array->location = AUDIO_MICROPHONE_LOCATION_UNKNOWN;
2063+
mic_array->group = 0;
2064+
mic_array->index_in_the_group = 0;
2065+
mic_array->sensitivity = AUDIO_MICROPHONE_SENSITIVITY_UNKNOWN;
2066+
mic_array->max_spl = AUDIO_MICROPHONE_SPL_UNKNOWN;
2067+
mic_array->min_spl = AUDIO_MICROPHONE_SPL_UNKNOWN;
2068+
mic_array->directionality = AUDIO_MICROPHONE_DIRECTIONALITY_UNKNOWN;
2069+
mic_array->num_frequency_responses = 0;
2070+
mic_array->geometric_location.x = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
2071+
mic_array->geometric_location.y = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
2072+
mic_array->geometric_location.z = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
2073+
mic_array->orientation.x = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
2074+
mic_array->orientation.y = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
2075+
mic_array->orientation.z = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
2076+
2077+
*mic_count = 1;
2078+
return 0;
2079+
}
2080+
20392081
/*********************************************************************
20402082
* Stream open and close
20412083
*********************************************************************/
@@ -2343,6 +2385,7 @@ static int adev_open(const hw_module_t *module, const char *name,
23432385
adev->hw_device.open_input_stream = adev_open_input_stream;
23442386
adev->hw_device.close_input_stream = adev_close_input_stream;
23452387
adev->hw_device.dump = adev_dump;
2388+
adev->hw_device.get_microphones = adev_get_microphones;
23462389

23472390
property_get("ro.product.device", property, "generic");
23482391
snprintf(file_name, sizeof(file_name), "%s/audio.%s.xml", ETC_PATH, property);

0 commit comments

Comments
 (0)