diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-11-27 18:12:10 +0100 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-11-28 00:20:57 +0100 |
commit | 04f41326994b39ffded27647bdc22c075a8842c1 (patch) | |
tree | c2cc2a0c3da2b0c45f418271fae8e4ab47a91e8e | |
parent | 33361fcddb257b4373006ad56bb037a69aa4ca37 (diff) | |
download | device_samsung_i9300-04f41326994b39ffded27647bdc22c075a8842c1.tar.gz device_samsung_i9300-04f41326994b39ffded27647bdc22c075a8842c1.tar.bz2 device_samsung_i9300-04f41326994b39ffded27647bdc22c075a8842c1.zip |
use midas audio primary module
The default audio HAL is a stub that doesn't do any access to the
hardware. The code of the audio.primary.default default implementation
is in hardware/libhardware/modules/audio and in audio_hw.c we have:
static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
size_t bytes)
{
ALOGV("out_write: bytes: %zu", bytes);
/* XXX: fake timing for audio output */
struct stub_stream_out *out = (struct stub_stream_out *)stream;
struct timespec t = { .tv_sec = 0, .tv_nsec = 0 };
clock_gettime(CLOCK_MONOTONIC, &t);
const int64_t now = (t.tv_sec * 1000000000LL + t.tv_nsec) / 1000;
const int64_t elapsed_time_since_last_write = now - out->last_write_time_us;
int64_t sleep_time = bytes * 1000000LL / audio_stream_out_frame_size(stream) /
out_get_sample_rate(&stream->common) - elapsed_time_since_last_write;
if (sleep_time > 0) {
usleep(sleep_time);
} else {
// we don't sleep when we exit standby (this is typical for a real alsa buffer).
sleep_time = 0;
}
out->last_write_time_us = now + sleep_time;
// last_write_time_us is an approximation of when the (simulated) alsa
// buffer is believed completely full. The usleep above waits for more space
// in the buffer, but by the end of the sleep the buffer is considered
// topped-off.
//
// On the subsequent out_write(), we measure the elapsed time spent in
// the mixer. This is subtracted from the sleep estimate based on frames,
// thereby accounting for drain in the alsa buffer during mixing.
// This is a crude approximation; we don't handle underruns precisely.
return bytes;
}
This function is supposed to send the audio frames to the the audio driver,
but instead it doesn't send it anywhere. So we can safely deduce that this
implementation is a dummy one that implements the API just to make the
higher level of the stack happy.
Because of that the Dragonboard audio library which is known to work in
Android 11, has been imported in device_samsung_midas_common for now.
In order to use it, we need to change ro.hardware.audio.primary as it is
used by the higher level stack to find what HAL library to load for the
primary audio module.
While the Dragonboard audio library doesn't handle audio routing, it is
possible to either modify it to do that or use another library like
libaudioroute, and the associated mixer_paths.xml configuration file
to do it.
Thanks to Joonas Kylmälä who identified that the Dragonboard
audio library worked out of the box on Android 11 for the
Galaxy SIII 4G (GT-I9305).
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r-- | init.smdk4x12.rc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/init.smdk4x12.rc b/init.smdk4x12.rc index 97dbeb7..70a8ad8 100644 --- a/init.smdk4x12.rc +++ b/init.smdk4x12.rc @@ -16,7 +16,7 @@ on boot # Audio support - setprop ro.hardware.audio.primary i9300 + setprop ro.hardware.audio.primary exynos4 # adb support mkdir /dev/usb-ffs 0770 shell shell mkdir /dev/usb-ffs/adb 0770 shell shell |