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.
slouken@4964
     1
LOCAL_PATH := $(call my-dir)
slouken@4964
     2
slouken@4964
     3
###########################
slouken@4964
     4
#
slouken@4964
     5
# SDL shared library
slouken@4964
     6
#
slouken@4964
     7
###########################
slouken@4964
     8
slouken@4964
     9
include $(CLEAR_VARS)
slouken@4964
    10
slouken@6270
    11
LOCAL_MODULE := SDL2
slouken@4964
    12
slouken@4964
    13
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
slouken@4964
    14
slouken@7311
    15
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
slouken@7311
    16
slouken@5090
    17
LOCAL_SRC_FILES := \
slouken@4964
    18
	$(subst $(LOCAL_PATH)/,, \
slouken@4964
    19
	$(wildcard $(LOCAL_PATH)/src/*.c) \
slouken@4964
    20
	$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
slouken@5090
    21
	$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
slouken@5090
    22
	$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
slouken@12534
    23
	$(wildcard $(LOCAL_PATH)/src/audio/openslES/*.c) \
slouken@10879
    24
	$(LOCAL_PATH)/src/atomic/SDL_atomic.c.arm \
slouken@5003
    25
	$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
ewing@7501
    26
	$(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
slouken@4964
    27
	$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
icculus@8097
    28
	$(wildcard $(LOCAL_PATH)/src/dynapi/*.c) \
slouken@4964
    29
	$(wildcard $(LOCAL_PATH)/src/events/*.c) \
slouken@4964
    30
	$(wildcard $(LOCAL_PATH)/src/file/*.c) \
slouken@5090
    31
	$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
slouken@11238
    32
	$(wildcard $(LOCAL_PATH)/src/haptic/android/*.c) \
slouken@4964
    33
	$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
slouken@5090
    34
	$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
slouken@12088
    35
	$(wildcard $(LOCAL_PATH)/src/joystick/hidapi/*.c) \
slouken@5092
    36
	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
slouken@5090
    37
	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
slouken@6448
    38
	$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
slouken@9054
    39
	$(wildcard $(LOCAL_PATH)/src/filesystem/android/*.c) \
slouken@12130
    40
	$(wildcard $(LOCAL_PATH)/src/sensor/*.c) \
slouken@12130
    41
	$(wildcard $(LOCAL_PATH)/src/sensor/android/*.c) \
slouken@5161
    42
	$(wildcard $(LOCAL_PATH)/src/render/*.c) \
slouken@5204
    43
	$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
slouken@4964
    44
	$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
slouken@4964
    45
	$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
slouken@5090
    46
	$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
slouken@4964
    47
	$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
slouken@5090
    48
	$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
slouken@4964
    49
	$(wildcard $(LOCAL_PATH)/src/video/*.c) \
gabomdq@7793
    50
	$(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
slouken@11702
    51
	$(wildcard $(LOCAL_PATH)/src/video/yuv2rgb/*.c) \
slouken@11534
    52
	$(wildcard $(LOCAL_PATH)/src/test/*.c))
slouken@4964
    53
slouken@12088
    54
LOCAL_SHARED_LIBRARIES := hidapi
slouken@12088
    55
slouken@6208
    56
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
slouken@12387
    57
LOCAL_CFLAGS += \
slouken@12387
    58
	-Wall -Wextra \
slouken@12387
    59
	-Wdocumentation \
slouken@12387
    60
	-Wdocumentation-unknown-command \
slouken@12387
    61
	-Wmissing-prototypes \
slouken@12387
    62
	-Wunreachable-code-break \
slouken@12387
    63
	-Wunneeded-internal-declaration \
slouken@12387
    64
	-Wmissing-variable-declarations \
slouken@12387
    65
	-Wfloat-conversion \
slouken@12387
    66
	-Wshorten-64-to-32 \
slouken@12387
    67
	-Wunreachable-code-return
slouken@12387
    68
slouken@12387
    69
# Warnings we haven't fixed (yet)
slouken@12387
    70
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare
slouken@12387
    71
 
slouken@12387
    72
slouken@12534
    73
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
slouken@4964
    74
icculus@12032
    75
ifeq ($(NDK_DEBUG),1)
icculus@12032
    76
    cmd-strip :=
icculus@12032
    77
endif
slouken@11777
    78
icculus@12439
    79
LOCAL_STATIC_LIBRARIES := cpufeatures
icculus@12439
    80
slouken@4964
    81
include $(BUILD_SHARED_LIBRARY)
slouken@7804
    82
slouken@7804
    83
###########################
slouken@7804
    84
#
slouken@7804
    85
# SDL static library
slouken@7804
    86
#
slouken@7804
    87
###########################
slouken@7804
    88
slouken@7804
    89
LOCAL_MODULE := SDL2_static
slouken@7804
    90
slouken@7804
    91
LOCAL_MODULE_FILENAME := libSDL2
slouken@7804
    92
slouken@7804
    93
LOCAL_LDLIBS := 
slouken@11429
    94
LOCAL_EXPORT_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
slouken@7804
    95
slouken@7804
    96
include $(BUILD_STATIC_LIBRARY)
slouken@11262
    97
slouken@11262
    98
###########################
slouken@11262
    99
#
slouken@11262
   100
# SDL main static library
slouken@11262
   101
#
slouken@11262
   102
###########################
slouken@11262
   103
slouken@11262
   104
include $(CLEAR_VARS)
slouken@11262
   105
slouken@11262
   106
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
slouken@11262
   107
slouken@11262
   108
LOCAL_MODULE := SDL2_main
slouken@11262
   109
slouken@11262
   110
LOCAL_MODULE_FILENAME := libSDL2main
slouken@11262
   111
slouken@11262
   112
include $(BUILD_STATIC_LIBRARY)
slouken@11262
   113
slouken@12088
   114
###########################
slouken@12088
   115
#
slouken@12088
   116
# hidapi library
slouken@12088
   117
#
slouken@12088
   118
###########################
slouken@11262
   119
slouken@12088
   120
include $(CLEAR_VARS)
slouken@12088
   121
slouken@12088
   122
LOCAL_CPPFLAGS += -std=c++11
slouken@12088
   123
slouken@12365
   124
LOCAL_SRC_FILES := src/hidapi/android/hid.cpp
slouken@12088
   125
slouken@12088
   126
LOCAL_MODULE := libhidapi
slouken@12088
   127
LOCAL_LDLIBS := -llog
slouken@12088
   128
slouken@12088
   129
include $(BUILD_SHARED_LIBRARY)
icculus@12439
   130
icculus@12439
   131
$(call import-module,android/cpufeatures)
icculus@12439
   132