From ca32aa9f6a089a37753ba60cb41348d21658e020 Mon Sep 17 00:00:00 2001 From: Konsta Date: Mon, 31 Mar 2025 00:51:09 +0300 Subject: [PATCH] hdmi audio: cache alsa device * It's always been intended that changing audio output devices requires a reboot. Get the ALSA device once when the HAL is initialized. Might save a few ms on start_output_stream. --- audio/audio_hw_hdmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/audio/audio_hw_hdmi.c b/audio/audio_hw_hdmi.c index 71261d7..573c01a 100644 --- a/audio/audio_hw_hdmi.c +++ b/audio/audio_hw_hdmi.c @@ -55,6 +55,8 @@ #define CHANNEL_STEREO 2 #define MIN_WRITE_SLEEP_US 5000 +char device_name[PROPERTY_VALUE_MAX]; + struct stub_stream_in { struct audio_stream_in stream; }; @@ -101,8 +103,6 @@ static int start_output_stream(struct alsa_stream_out *out) if (out->unavailable) return -ENODEV; - char device_name[PROPERTY_VALUE_MAX]; - get_alsa_device_name(device_name); ALOGI("start_output_stream: %s", device_name); int r; @@ -717,6 +717,9 @@ static int adev_open(const hw_module_t* module, const char* name, ALOGV("adev_open: %s", name); + get_alsa_device_name(device_name); + ALOGI("adev_open: %s", device_name); + if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0) return -EINVAL;