blob: e2b510cd7203f1df956f2d9a81d06fef30361014 [file] [log] [blame]
kjellander@webrtc.org1227ab82014-06-23 19:21:07 +00001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
8
9import("../../build/webrtc.gni")
10
mbonadei438062b2017-01-09 02:37:21 -080011if (is_android) {
12 import("//build/config/android/config.gni")
13 import("//build/config/android/rules.gni")
14}
15
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000016config("audio_device_config") {
17 include_dirs = [
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010018 "../include",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000019 "include",
20 "dummy", # Contains dummy audio device implementations.
21 ]
kjellander95177d12016-04-07 00:13:58 -070022 if (is_ios) {
23 # GN orders flags on a target before flags from configs. In order to be able
24 # suppress the -Wthread-safety-analysis warning, it has come from a config
25 # and can't be on the target directly.
26 # TODO(tkchin): Remove after fixing
27 # https://bugs.chromium.org/p/webrtc/issues/detail?id=5748
28 cflags = [ "-Wno-thread-safety-analysis" ]
29 }
kjellander@webrtc.org1227ab82014-06-23 19:21:07 +000030}
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000031
ehmaldonadod02fe4b2016-08-26 13:31:24 -070032config("audio_device_warnings_config") {
33 if (is_win && is_clang) {
34 cflags = [
35 # Disable warnings failing when compiling with Clang on Windows.
36 # https://bugs.chromium.org/p/webrtc/issues/detail?id=5366
37 "-Wno-bool-conversion",
38 "-Wno-delete-non-virtual-dtor",
39 "-Wno-logical-op-parentheses",
40 "-Wno-microsoft-extra-qualification",
41 "-Wno-microsoft-goto",
42 "-Wno-missing-braces",
43 "-Wno-parentheses-equality",
44 "-Wno-reorder",
45 "-Wno-shift-overflow",
46 "-Wno-tautological-compare",
47
48 # See https://bugs.chromium.org/p/webrtc/issues/detail?id=6265
49 # for -Wno-thread-safety-analysis
50 "-Wno-thread-safety-analysis",
51 "-Wno-unused-private-field",
52 ]
53 }
54}
55
kjellanderb62dbbe2016-09-23 00:38:52 -070056rtc_static_library("audio_device") {
ehmaldonadoe9cc6862016-09-05 06:10:18 -070057 public_configs = [ ":audio_device_config" ]
ehmaldonadod02fe4b2016-08-26 13:31:24 -070058
Zeke Chinb3fb71c2016-02-18 15:44:07 -080059 deps = [
60 "../..:webrtc_common",
61 "../../base:rtc_base_approved",
maxmorin69105372016-08-16 02:17:44 -070062 "../../base:rtc_task_queue",
Zeke Chinb3fb71c2016-02-18 15:44:07 -080063 "../../common_audio",
64 "../../system_wrappers",
65 "../utility",
66 ]
67
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000068 sources = [
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000069 "audio_device_buffer.cc",
70 "audio_device_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +020071 "audio_device_config.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000072 "audio_device_generic.cc",
73 "audio_device_generic.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000074 "dummy/audio_device_dummy.cc",
75 "dummy/audio_device_dummy.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000076 "dummy/file_audio_device.cc",
77 "dummy/file_audio_device.h",
henrika86d907c2015-09-07 16:09:50 +020078 "fine_audio_buffer.cc",
79 "fine_audio_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +020080 "include/audio_device.h",
81 "include/audio_device_defines.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000082 ]
83
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000084 include_dirs = []
85 if (is_linux) {
86 include_dirs += [ "linux" ]
87 }
88 if (is_ios) {
89 include_dirs += [ "ios" ]
90 }
91 if (is_mac) {
92 include_dirs += [ "mac" ]
93 }
94 if (is_win) {
95 include_dirs += [ "win" ]
96 }
97 if (is_android) {
98 include_dirs += [ "android" ]
99 }
Henrik Kjellanderb79472a2015-10-14 08:13:58 +0200100 defines = []
kjellander70bed7d2015-11-23 17:23:44 -0800101 cflags = []
kjellander@webrtc.org6d08ca62014-09-07 17:36:10 +0000102 if (rtc_include_internal_audio_device) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000103 sources += [
Tommi931e6582015-05-20 09:44:38 +0200104 "audio_device_impl.cc",
105 "audio_device_impl.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000106 ]
kjellandera46a4c92016-01-07 02:54:22 -0800107 if (is_android) {
108 sources += [
109 "android/audio_device_template.h",
110 "android/audio_manager.cc",
111 "android/audio_manager.h",
112 "android/audio_record_jni.cc",
113 "android/audio_record_jni.h",
114 "android/audio_track_jni.cc",
115 "android/audio_track_jni.h",
116 "android/build_info.cc",
117 "android/build_info.h",
118 "android/opensles_common.cc",
119 "android/opensles_common.h",
120 "android/opensles_player.cc",
121 "android/opensles_player.h",
henrika918b5542016-09-19 15:44:09 +0200122 "android/opensles_recorder.cc",
123 "android/opensles_recorder.h",
kjellandera46a4c92016-01-07 02:54:22 -0800124 ]
125 libs = [
126 "log",
127 "OpenSLES",
128 ]
129 }
noahricc594aa612016-08-16 18:21:18 -0700130 if (rtc_use_dummy_audio_file_devices) {
131 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
132 } else {
133 if (is_linux) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000134 sources += [
noahricc594aa612016-08-16 18:21:18 -0700135 "linux/alsasymboltable_linux.cc",
136 "linux/alsasymboltable_linux.h",
137 "linux/audio_device_alsa_linux.cc",
138 "linux/audio_device_alsa_linux.h",
139 "linux/audio_mixer_manager_alsa_linux.cc",
140 "linux/audio_mixer_manager_alsa_linux.h",
141 "linux/latebindingsymboltable_linux.cc",
142 "linux/latebindingsymboltable_linux.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000143 ]
noahricc594aa612016-08-16 18:21:18 -0700144 defines += [ "LINUX_ALSA" ]
145 libs = [
146 "dl",
147 "X11",
148 ]
149 if (rtc_include_pulse_audio) {
150 sources += [
151 "linux/audio_device_pulse_linux.cc",
152 "linux/audio_device_pulse_linux.h",
153 "linux/audio_mixer_manager_pulse_linux.cc",
154 "linux/audio_mixer_manager_pulse_linux.h",
155 "linux/pulseaudiosymboltable_linux.cc",
156 "linux/pulseaudiosymboltable_linux.h",
157 ]
158 defines += [ "LINUX_PULSE" ]
159 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000160 }
noahricc594aa612016-08-16 18:21:18 -0700161 if (is_mac) {
162 sources += [
163 "mac/audio_device_mac.cc",
164 "mac/audio_device_mac.h",
165 "mac/audio_mixer_manager_mac.cc",
166 "mac/audio_mixer_manager_mac.h",
noahricc594aa612016-08-16 18:21:18 -0700167 ]
kjellander7439f972016-12-05 22:47:46 -0800168 deps += [ ":mac_portaudio" ]
noahricc594aa612016-08-16 18:21:18 -0700169 libs = [
maxmorin2ec45b92016-08-24 06:51:09 -0700170 # Needed for CoreGraphics:
171 "ApplicationServices.framework",
172
noahricc594aa612016-08-16 18:21:18 -0700173 "AudioToolbox.framework",
174 "CoreAudio.framework",
kjellanderbac04122016-06-02 02:18:48 -0700175
noahricc594aa612016-08-16 18:21:18 -0700176 # Needed for CGEventSourceKeyState in audio_device_mac.cc:
177 "CoreGraphics.framework",
178 ]
179 }
180 if (is_ios) {
181 public_deps = [
maxmorinec623742016-09-15 05:11:55 -0700182 "../../base:rtc_base",
noahricc594aa612016-08-16 18:21:18 -0700183 "../../sdk:rtc_sdk_common_objc",
184 ]
185 sources += [
186 "ios/audio_device_ios.h",
187 "ios/audio_device_ios.mm",
188 "ios/audio_device_not_implemented_ios.mm",
189 "ios/audio_session_observer.h",
190 "ios/objc/RTCAudioSession+Configuration.mm",
191 "ios/objc/RTCAudioSession+Private.h",
192 "ios/objc/RTCAudioSession.h",
193 "ios/objc/RTCAudioSession.mm",
194 "ios/objc/RTCAudioSessionConfiguration.h",
195 "ios/objc/RTCAudioSessionConfiguration.m",
196 "ios/objc/RTCAudioSessionDelegateAdapter.h",
197 "ios/objc/RTCAudioSessionDelegateAdapter.mm",
198 "ios/voice_processing_audio_unit.h",
199 "ios/voice_processing_audio_unit.mm",
200 ]
201 configs += [ "//build/config/compiler:enable_arc" ]
kjellander95177d12016-04-07 00:13:58 -0700202
noahricc594aa612016-08-16 18:21:18 -0700203 libs = [
204 "AudioToolbox.framework",
205 "AVFoundation.framework",
206 "Foundation.framework",
207 "UIKit.framework",
208 ]
209 }
210 if (is_win) {
211 sources += [
212 "win/audio_device_core_win.cc",
213 "win/audio_device_core_win.h",
214 "win/audio_device_wave_win.cc",
215 "win/audio_device_wave_win.h",
216 "win/audio_mixer_manager_win.cc",
217 "win/audio_mixer_manager_win.h",
218 ]
219 libs = [
220 # Required for the built-in WASAPI AEC.
221 "dmoguids.lib",
222 "wmcodecdspuuid.lib",
223 "amstrmid.lib",
224 "msdmo.lib",
225 ]
226 }
ehmaldonadod02fe4b2016-08-26 13:31:24 -0700227 configs += [ ":audio_device_warnings_config" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000228 }
229 } else {
230 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
231 }
232
233 if (!build_with_chromium) {
234 sources += [
235 # Do not link these into Chrome since they contain static data.
236 "dummy/file_audio_device_factory.cc",
237 "dummy/file_audio_device_factory.h",
238 ]
239 }
240
kjellandere40a7ee2016-10-16 23:56:12 -0700241 if (!build_with_chromium && is_clang) {
242 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700243 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000244 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000245}
maxmorin69105372016-08-16 02:17:44 -0700246
kjellander7439f972016-12-05 22:47:46 -0800247rtc_source_set("mac_portaudio") {
248 visibility = [ ":*" ] # Only targets in this file can depend on this.
249 sources = [
250 "mac/portaudio/pa_memorybarrier.h",
251 "mac/portaudio/pa_ringbuffer.c",
252 "mac/portaudio/pa_ringbuffer.h",
253 ]
254}
255
aleloi44c7ecf2016-11-10 08:16:25 -0800256config("mock_audio_device_config") {
257 if (is_win) {
258 cflags = [
259 # TODO(phoglund): get rid of 4373 supression when
260 # http://code.google.com/p/webrtc/issues/detail?id=261 is solved.
261 # legacy warning for ignoring const / volatile in signatures.
262 "/wd4373",
263 ]
264 }
265}
266
aleloi5de52fd2016-11-10 01:05:34 -0800267if (rtc_include_tests) {
ehmaldonado36268652017-01-19 08:27:11 -0800268 rtc_source_set("audio_device_unittests") {
269 testonly = true
270 sources = [
271 "fine_audio_buffer_unittest.cc",
272 ]
273 deps = [
274 ":audio_device",
275 ":mock_audio_device",
276 "../../base:rtc_base_approved",
277 "../../system_wrappers:system_wrappers",
278 "../../test:test_support",
279 "../utility:utility",
280 "//testing/gmock",
281 ]
282 if (is_android) {
283 # Need to disable error due to the line in
284 # base/android/jni_android.h triggering it:
285 # const BASE_EXPORT jobject GetApplicationContext()
286 # error: type qualifiers ignored on function return type
287 cflags = [ "-Wno-ignored-qualifiers" ]
288 sources += [
289 "android/audio_device_unittest.cc",
290 "android/audio_manager_unittest.cc",
291 "android/ensure_initialized.cc",
292 "android/ensure_initialized.h",
293 ]
294 deps += [
295 "../../../base",
296 "//webrtc/sdk/android:libjingle_peerconnection_java",
297 ]
298 }
299 if (is_ios) {
300 sources += [ "ios/objc/RTCAudioSessionTest.mm" ]
301 configs += [ "//build/config/compiler:enable_arc" ]
302 if (target_cpu != "x64") {
303 sources += [ "ios/audio_device_unittest_ios.cc" ]
304 }
305 }
306 if (!build_with_chromium && is_clang) {
307 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
308 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
309 }
310 }
311
aleloi5de52fd2016-11-10 01:05:34 -0800312 rtc_source_set("mock_audio_device") {
313 testonly = true
314 sources = [
315 "include/mock_audio_device.h",
316 "include/mock_audio_transport.h",
317 ]
318 deps = [
319 ":audio_device",
320 "../../test:test_support",
321 ]
aleloi44c7ecf2016-11-10 08:16:25 -0800322 all_dependent_configs = [ ":mock_audio_device_config" ]
aleloi5de52fd2016-11-10 01:05:34 -0800323 }
aleloi5de52fd2016-11-10 01:05:34 -0800324
ehmaldonado36268652017-01-19 08:27:11 -0800325 if (!is_ios) {
326 # These tests do not work on ios, see
327 # https://bugs.chromium.org/p/webrtc/issues/detail?id=4755
328 rtc_executable("audio_device_tests") {
329 testonly = true
330 sources = [
331 "test/audio_device_test_api.cc",
332 "test/audio_device_test_defines.h",
333 ]
334 deps = [
335 ":audio_device",
336 "../..:webrtc_common",
337 "../../system_wrappers",
338 "../../test:test_main",
339 "../../test:test_support",
340 "../rtp_rtcp",
341 "../utility",
342 "//testing/gtest",
343 ]
344 public_configs = [ ":audio_device_config" ]
345 }
maxmorin69105372016-08-16 02:17:44 -0700346 }
347}
mbonadei438062b2017-01-09 02:37:21 -0800348
349if (!build_with_chromium && is_android) {
350 android_shared_srcjar("audio_device_java") {
351 sources = [
352 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
353 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
354 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
355 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
356 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
357 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
358 ]
359 }
360}