Android.mk
author Sam Lantinga
Sat, 08 Jun 2019 18:22:18 -0700
changeset 12803 70d338e248c8
parent 12534 682d9b5ecbed
child 13040 58a4430a9492
permissions -rwxr-xr-x
Fixed bug 4294 - Audio: perform more validation on conversion request

janisozaur

There are many cases which are not able to be handled by SDL's audio conversion routines, including too low (negative) rate, too high rate (impossible to allocate).

This patch aims to report such issues early and handle others in a graceful manner. The "INT32_MAX / RESAMPLER_SAMPLES_PER_ZERO_CROSSING" value is the conservative approach in terms of what can _technically_ be supported, but its value is 4'194'303, or just shy of 4.2MHz. I highly doubt any sane person would use such rates, especially in SDL2, so I would like to drive this limit further down, but would need some assistance to do that, as doing so would have to introduce an arbitrary value. Are you OK with such approach? What would a good value be? Wikipedia (https://en.wikipedia.org/wiki/High-resolution_audio) lists 96kHz as the highest sampling rate in use, even if I quadruple it for a good measure, to 384kHz it's still an order of magnitude lower than 4MHz.
     1 LOCAL_PATH := $(call my-dir)
     2 
     3 ###########################
     4 #
     5 # SDL shared library
     6 #
     7 ###########################
     8 
     9 include $(CLEAR_VARS)
    10 
    11 LOCAL_MODULE := SDL2
    12 
    13 LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
    14 
    15 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
    16 
    17 LOCAL_SRC_FILES := \
    18 	$(subst $(LOCAL_PATH)/,, \
    19 	$(wildcard $(LOCAL_PATH)/src/*.c) \
    20 	$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
    21 	$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
    22 	$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
    23 	$(wildcard $(LOCAL_PATH)/src/audio/openslES/*.c) \
    24 	$(LOCAL_PATH)/src/atomic/SDL_atomic.c.arm \
    25 	$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
    26 	$(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
    27 	$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
    28 	$(wildcard $(LOCAL_PATH)/src/dynapi/*.c) \
    29 	$(wildcard $(LOCAL_PATH)/src/events/*.c) \
    30 	$(wildcard $(LOCAL_PATH)/src/file/*.c) \
    31 	$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
    32 	$(wildcard $(LOCAL_PATH)/src/haptic/android/*.c) \
    33 	$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
    34 	$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
    35 	$(wildcard $(LOCAL_PATH)/src/joystick/hidapi/*.c) \
    36 	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
    37 	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
    38 	$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
    39 	$(wildcard $(LOCAL_PATH)/src/filesystem/android/*.c) \
    40 	$(wildcard $(LOCAL_PATH)/src/sensor/*.c) \
    41 	$(wildcard $(LOCAL_PATH)/src/sensor/android/*.c) \
    42 	$(wildcard $(LOCAL_PATH)/src/render/*.c) \
    43 	$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
    44 	$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
    45 	$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
    46 	$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
    47 	$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
    48 	$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
    49 	$(wildcard $(LOCAL_PATH)/src/video/*.c) \
    50 	$(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
    51 	$(wildcard $(LOCAL_PATH)/src/video/yuv2rgb/*.c) \
    52 	$(wildcard $(LOCAL_PATH)/src/test/*.c))
    53 
    54 LOCAL_SHARED_LIBRARIES := hidapi
    55 
    56 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
    57 LOCAL_CFLAGS += \
    58 	-Wall -Wextra \
    59 	-Wdocumentation \
    60 	-Wdocumentation-unknown-command \
    61 	-Wmissing-prototypes \
    62 	-Wunreachable-code-break \
    63 	-Wunneeded-internal-declaration \
    64 	-Wmissing-variable-declarations \
    65 	-Wfloat-conversion \
    66 	-Wshorten-64-to-32 \
    67 	-Wunreachable-code-return
    68 
    69 # Warnings we haven't fixed (yet)
    70 LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare
    71  
    72 
    73 LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
    74 
    75 ifeq ($(NDK_DEBUG),1)
    76     cmd-strip :=
    77 endif
    78 
    79 LOCAL_STATIC_LIBRARIES := cpufeatures
    80 
    81 include $(BUILD_SHARED_LIBRARY)
    82 
    83 ###########################
    84 #
    85 # SDL static library
    86 #
    87 ###########################
    88 
    89 LOCAL_MODULE := SDL2_static
    90 
    91 LOCAL_MODULE_FILENAME := libSDL2
    92 
    93 LOCAL_LDLIBS := 
    94 LOCAL_EXPORT_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
    95 
    96 include $(BUILD_STATIC_LIBRARY)
    97 
    98 ###########################
    99 #
   100 # SDL main static library
   101 #
   102 ###########################
   103 
   104 include $(CLEAR_VARS)
   105 
   106 LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
   107 
   108 LOCAL_MODULE := SDL2_main
   109 
   110 LOCAL_MODULE_FILENAME := libSDL2main
   111 
   112 include $(BUILD_STATIC_LIBRARY)
   113 
   114 ###########################
   115 #
   116 # hidapi library
   117 #
   118 ###########################
   119 
   120 include $(CLEAR_VARS)
   121 
   122 LOCAL_CPPFLAGS += -std=c++11
   123 
   124 LOCAL_SRC_FILES := src/hidapi/android/hid.cpp
   125 
   126 LOCAL_MODULE := libhidapi
   127 LOCAL_LDLIBS := -llog
   128 
   129 include $(BUILD_SHARED_LIBRARY)
   130 
   131 $(call import-module,android/cpufeatures)
   132