summaryrefslogtreecommitdiffstats
path: root/media/libsoundtouch/src/moz.build
blob: c7a160fe12f347f4618e1d78ab567b14a270710b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

EXPORTS += [
    "RLBoxSoundTouch.h",
    "RLBoxSoundTouchTypes.h",
]

EXPORTS.soundtouch += [
    'FIFOSamplePipe.h',
    'RLBoxSoundTouchFactory.h',
    'SoundTouch.h',
    'soundtouch_config.h',
    'SoundTouchFactory.h',
    'STTypes.h',
]

LOCAL_INCLUDES += ["!/security/rlbox"]

LOCAL_INCLUDES += [
    "/third_party/simde/",
    "/third_party/wasm2c/wasm2c/",
]

SOURCES += ["RLBoxSoundTouch.cpp"]
# Some xpcom things are #included indirectly (but not actually used), and
# it's simpler to set MOZILLA_INTERNAL_API to make it compile than to
# disentangle the whole thing.
SOURCES["RLBoxSoundTouch.cpp"].flags += ["-DMOZILLA_INTERNAL_API"]

if CONFIG["MOZ_WASM_SANDBOXING_SOUNDTOUCH"]:
    include("/security/rlbox/rlbox.mozbuild")

    RLBoxLibrary("rlboxsoundtouch")

    DEFINES["WASM_RT_GROW_FAILED_CRASH"] = True

    SOURCES += [
        "/config/external/rlbox_wasm2c_sandbox/rlbox_wasm2c_thread_locals.cpp",
        "/third_party/rlbox_wasm2c_sandbox/src/wasm2c_rt_mem.c",
        "/third_party/rlbox_wasm2c_sandbox/src/wasm2c_rt_minwasi.c",
    ]
    if CONFIG['OS_ARCH'] != 'WINNT':
        OS_LIBS += ["m"]

    if CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]:
        WASM_DEFINES["MOZ_SAMPLE_TYPE_FLOAT32"] = 1

        # Clang older than version 14 does not have the necessary
        # WASMSIMD intrinsics, so we disable SoundTouch WASMSIMD.
        # See Bug 1851301
        if int(CONFIG["WASM_CC_VERSION"].split(".")[0]) > 13:
            WASM_SOURCES += ['sse_optimized.cpp']

            WASM_DEFINES["SOUNDTOUCH_ALLOW_SSE"] = 1
            WASM_DEFINES["SOUNDTOUCH_WASM_SIMD"] = 1
            WASM_DEFINES["SIMDE_ENABLE_NATIVE_ALIASES"] = 1

    soundtouch_sources = WASM_SOURCES
    soundtouch_defines = WASM_DEFINES

else:
    SOURCES += ["/config/external/rlbox/rlbox_thread_locals.cpp"]
    if CONFIG['INTEL_ARCHITECTURE']:
        if CONFIG['MOZ_SAMPLE_TYPE_FLOAT32']:
            SOURCES += ['sse_optimized.cpp']
            SOURCES['sse_optimized.cpp'].flags += CONFIG['SSE2_FLAGS']
        else:
            SOURCES += ['mmx_optimized.cpp']
            SOURCES['mmx_optimized.cpp'].flags += CONFIG['MMX_FLAGS']

    if CONFIG['OS_ARCH'] != 'WINNT':
        # GCC/Clang require permissions to be explicitly set for the soundtouch
        # header.
        CXXFLAGS += ['-include', SRCDIR + '/soundtouch_perms.h']
    else:
        # Windows need alloca renamed to _alloca
        DEFINES['alloca'] = '_alloca'

    soundtouch_sources = UNIFIED_SOURCES
    soundtouch_defines = DEFINES

soundtouch_sources += [
    'AAFilter.cpp',
    'cpu_detect_x86.cpp',
    'FIFOSampleBuffer.cpp',
    'FIRFilter.cpp',
    'InterpolateCubic.cpp',
    'InterpolateLinear.cpp',
    'InterpolateShannon.cpp',
    'RateTransposer.cpp',
    'RLBoxSoundTouchFactory.cpp',
    'SoundTouch.cpp',
    'SoundTouchFactory.cpp',
    'TDStretch.cpp',
]

for k, v in (
    ('BUILDING_SOUNDTOUCH', 1),
    # Use abort() instead of exception in SoundTouch.
    ('ST_NO_EXCEPTION_HANDLING', 1)
):
    soundtouch_defines[k] = v


# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

FINAL_LIBRARY = 'lgpllibs'