From: Jan Altensen Date: Wed, 5 May 2021 11:53:33 +0000 (+0200) Subject: exynos9610: shim: add better reverse engineered mixer_read_event X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2106233ae00ffdd683e5e8fb1f63e899649d2f43;p=GitHub%2FLineageOS%2Fandroid_device_motorola_exynos9610-common.git exynos9610: shim: add better reverse engineered mixer_read_event * decompiled output more or less matches now with thats on stock Change-Id: I5b525342e0cf2b731f93bd3ac74b636fd533969d --- diff --git a/shims/libaudioproxy/shim.cpp b/shims/libaudioproxy/shim.cpp index 5c9c33f..fa79502 100644 --- a/shims/libaudioproxy/shim.cpp +++ b/shims/libaudioproxy/shim.cpp @@ -53,8 +53,26 @@ struct audio_route { struct mixer_path *mixer_path; }; -extern "C" int mixer_read_event(struct mixer *mixer, struct snd_ctl_event *ev) { - ssize_t count = read(mixer->fd, ev, sizeof(*ev)); +extern "C" int * mixer_read_event(struct mixer *mixer, uint param_2) { + struct snd_ctl_event *ev = NULL; + ssize_t count; - return (count >= 0) ? 0 : -errno; -} \ No newline at end of file + if (mixer && mixer->fd >= 0) { + ev = (struct snd_ctl_event *)calloc(1, sizeof(*ev)); + + if (ev) { + count = read(mixer->fd, ev, sizeof(*ev)); + + while (0 < count) { + if (ev->type == 0 && (ev->data.elem.mask & param_2) != 0) { + return (int *)ev; + } + + count = read(mixer->fd, ev, sizeof(*ev)); + } + free(ev); + } + } + + return NULL; +}