[vlc-commits] [Git][videolan/vlc][master] android: add audio denylist from HWDecoderUtil.java

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Aug 2 19:17:12 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
de86ad87 by Mangal Kushwah at 2024-08-02T15:55:05+00:00
android: add audio denylist from HWDecoderUtil.java

- - - - -


1 changed file:

- modules/audio_output/android/device.c


Changes:

=====================================
modules/audio_output/android/device.c
=====================================
@@ -24,10 +24,16 @@
 # include "config.h"
 #endif
 
+#include <string.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_modules.h>
 #include <vlc_aout.h>
+
+#include <android/api-level.h>
+#include <sys/system_properties.h>
+
 #include "device.h"
 #include "audioformat_jni.h"
 #include "../video_output/android/env.h"
@@ -59,6 +65,46 @@ static const struct {
     {  NULL, NULL, ANDROID_AUDIO_DEVICE_DEFAULT },
 };
 
+/* Audio output Allow/Deny Logic Start */
+enum AudioOutput
+{
+    OPENSLES, ALL
+};
+
+static const struct
+{
+    const char *property;
+    const char *property_value;
+    enum AudioOutput audio_output;
+} audio_output_by_soc[] = {
+    /* getPlaybackHeadPosition returns an invalid position on Fire OS,
+     * thus Audiotrack is not usable */
+    { "ro.product.brand", "Amazon", OPENSLES },
+    { "ro.product.manufacturer", "Amazon", OPENSLES }
+};
+
+
+static enum AudioOutput get_audio_output_from_device(void)
+{
+    if (android_get_device_api_level() >= 28)
+        return ALL;
+
+    int len = 0;
+    char value[PROP_VALUE_MAX];
+    for (int i = 0; i < ARRAY_SIZE(audio_output_by_soc); i++)
+    {
+        /* On return, len will equal (int)strlen(model_id) */
+        len = __system_property_get(audio_output_by_soc[i].property, value);
+        if (len > 0)
+        {
+            if (strstr(value, audio_output_by_soc[i].property_value) != NULL)
+                return audio_output_by_soc[i].audio_output;
+        }
+    }
+    return ALL;
+}
+/* Audio output Allow/Deny Logic End */
+
 struct sys {
     aout_stream_t *stream;
 
@@ -266,6 +312,10 @@ Open(vlc_object_t *obj)
     if (vlc_android_AudioFormat_InitJNI(obj) != VLC_SUCCESS)
         return VLC_EGENERIC;
 
+    /* Return an error if OpenSLES should be used */
+    if (get_audio_output_from_device() == OPENSLES)
+        return VLC_EGENERIC;
+
     struct sys *sys = aout->sys = vlc_obj_malloc(obj, sizeof(*sys));
     if (sys == NULL)
         return VLC_ENOMEM;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/de86ad87a732719896166f1d4f13f5d86b4fbf20

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/de86ad87a732719896166f1d4f13f5d86b4fbf20
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list