blob: ef48180be92813d1c45a8109fbca13728326045d [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
mbonadei9aa3f0a2017-01-24 06:58:22 -08009import("../../webrtc.gni")
kjellander@webrtc.org1227ab82014-06-23 19:21:07 +000010
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 ]
kjellander@webrtc.org1227ab82014-06-23 19:21:07 +000022}
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000023
ehmaldonadod02fe4b2016-08-26 13:31:24 -070024config("audio_device_warnings_config") {
25 if (is_win && is_clang) {
26 cflags = [
27 # Disable warnings failing when compiling with Clang on Windows.
28 # https://bugs.chromium.org/p/webrtc/issues/detail?id=5366
29 "-Wno-bool-conversion",
30 "-Wno-delete-non-virtual-dtor",
31 "-Wno-logical-op-parentheses",
32 "-Wno-microsoft-extra-qualification",
33 "-Wno-microsoft-goto",
34 "-Wno-missing-braces",
35 "-Wno-parentheses-equality",
36 "-Wno-reorder",
37 "-Wno-shift-overflow",
38 "-Wno-tautological-compare",
39
40 # See https://bugs.chromium.org/p/webrtc/issues/detail?id=6265
41 # for -Wno-thread-safety-analysis
42 "-Wno-thread-safety-analysis",
43 "-Wno-unused-private-field",
44 ]
45 }
46}
47
mbonadeibcc21762017-09-12 04:45:24 -070048rtc_source_set("audio_device") {
49 public_deps = [
50 ":audio_device_generic",
51 ]
52 if (rtc_include_internal_audio_device && is_ios) {
53 public_deps += [ ":audio_device_ios_objc" ]
54 }
55}
56
57if (rtc_include_internal_audio_device && is_ios) {
58 rtc_source_set("audio_device_ios_objc") {
59 visibility = [ ":audio_device" ]
60 sources = [
61 "ios/audio_device_ios.h",
62 "ios/audio_device_ios.mm",
63 "ios/audio_device_not_implemented_ios.mm",
64 "ios/audio_session_observer.h",
65 "ios/objc/RTCAudioSessionDelegateAdapter.h",
66 "ios/objc/RTCAudioSessionDelegateAdapter.mm",
67 "ios/voice_processing_audio_unit.h",
68 "ios/voice_processing_audio_unit.mm",
69 ]
70 libs = [
71 "AudioToolbox.framework",
72 "AVFoundation.framework",
73 "Foundation.framework",
74 "UIKit.framework",
75 ]
76 deps = [
77 ":audio_device_generic",
78 "../../api:array_view",
Patrik Höglunda8005cf2017-12-13 16:05:42 +010079 "../../rtc_base:checks",
mbonadeibcc21762017-09-12 04:45:24 -070080 "../../rtc_base:gtest_prod",
81 "../../rtc_base:rtc_base",
82 "../../sdk:audio_objc",
83 "../../sdk:common_objc",
84 "../../system_wrappers:metrics_api",
85 ]
86 if (!build_with_chromium && is_clang) {
87 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
88 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
89 }
90 }
91}
92
93rtc_source_set("audio_device_generic") {
94 visibility = [
95 ":audio_device",
96 ":audio_device_ios_objc",
97 ]
ehmaldonadoe9cc6862016-09-05 06:10:18 -070098 public_configs = [ ":audio_device_config" ]
ehmaldonadod02fe4b2016-08-26 13:31:24 -070099
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800100 deps = [
mbonadei1140f972017-04-26 03:38:35 -0700101 "..:module_api",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800102 "../..:webrtc_common",
Patrik Höglund3e113432017-12-15 14:40:10 +0100103 "../../:typedefs",
kwiberg529662a2017-09-04 05:43:17 -0700104 "../../api:array_view",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800105 "../../common_audio",
Patrik Höglunda8005cf2017-12-13 16:05:42 +0100106 "../../rtc_base:checks",
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100107 "../../rtc_base:deprecation",
ehmaldonadof6a861a2017-07-19 10:40:47 -0700108 "../../rtc_base:rtc_base_approved",
109 "../../rtc_base:rtc_task_queue",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800110 "../../system_wrappers",
Mirko Bonadeia498ae82017-12-06 09:17:14 +0100111 "../../system_wrappers:metrics_api",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800112 "../utility",
113 ]
114
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000115 sources = [
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000116 "audio_device_buffer.cc",
117 "audio_device_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200118 "audio_device_config.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000119 "audio_device_generic.cc",
120 "audio_device_generic.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000121 "dummy/audio_device_dummy.cc",
122 "dummy/audio_device_dummy.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000123 "dummy/file_audio_device.cc",
124 "dummy/file_audio_device.h",
henrika86d907c2015-09-07 16:09:50 +0200125 "fine_audio_buffer.cc",
126 "fine_audio_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200127 "include/audio_device.h",
128 "include/audio_device_defines.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000129 ]
130
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000131 include_dirs = []
132 if (is_linux) {
133 include_dirs += [ "linux" ]
134 }
135 if (is_ios) {
136 include_dirs += [ "ios" ]
137 }
138 if (is_mac) {
139 include_dirs += [ "mac" ]
140 }
141 if (is_win) {
142 include_dirs += [ "win" ]
143 }
144 if (is_android) {
145 include_dirs += [ "android" ]
146 }
Henrik Kjellanderb79472a2015-10-14 08:13:58 +0200147 defines = []
kjellander70bed7d2015-11-23 17:23:44 -0800148 cflags = []
henrika7be78832017-06-13 17:34:16 +0200149 if (rtc_audio_device_plays_sinus_tone) {
150 defines += [ "AUDIO_DEVICE_PLAYS_SINUS_TONE" ]
151 }
kjellander@webrtc.org6d08ca62014-09-07 17:36:10 +0000152 if (rtc_include_internal_audio_device) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000153 sources += [
Lu Liu4b620012017-04-06 10:17:01 -0700154 "audio_device_data_observer.cc",
Tommi931e6582015-05-20 09:44:38 +0200155 "audio_device_impl.cc",
156 "audio_device_impl.h",
Lu Liu4b620012017-04-06 10:17:01 -0700157 "include/audio_device_data_observer.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000158 ]
kjellandera46a4c92016-01-07 02:54:22 -0800159 if (is_android) {
160 sources += [
161 "android/audio_device_template.h",
162 "android/audio_manager.cc",
163 "android/audio_manager.h",
164 "android/audio_record_jni.cc",
165 "android/audio_record_jni.h",
166 "android/audio_track_jni.cc",
167 "android/audio_track_jni.h",
168 "android/build_info.cc",
169 "android/build_info.h",
170 "android/opensles_common.cc",
171 "android/opensles_common.h",
172 "android/opensles_player.cc",
173 "android/opensles_player.h",
henrika918b5542016-09-19 15:44:09 +0200174 "android/opensles_recorder.cc",
175 "android/opensles_recorder.h",
kjellandera46a4c92016-01-07 02:54:22 -0800176 ]
177 libs = [
178 "log",
179 "OpenSLES",
180 ]
181 }
noahricc594aa612016-08-16 18:21:18 -0700182 if (rtc_use_dummy_audio_file_devices) {
183 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
184 } else {
185 if (is_linux) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000186 sources += [
noahricc594aa612016-08-16 18:21:18 -0700187 "linux/alsasymboltable_linux.cc",
188 "linux/alsasymboltable_linux.h",
189 "linux/audio_device_alsa_linux.cc",
190 "linux/audio_device_alsa_linux.h",
191 "linux/audio_mixer_manager_alsa_linux.cc",
192 "linux/audio_mixer_manager_alsa_linux.h",
193 "linux/latebindingsymboltable_linux.cc",
194 "linux/latebindingsymboltable_linux.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000195 ]
noahricc594aa612016-08-16 18:21:18 -0700196 defines += [ "LINUX_ALSA" ]
kjellanderc41d0c42017-05-30 12:06:04 -0700197 libs = [ "dl" ]
198 if (use_x11) {
199 libs += [ "X11" ]
200 }
noahricc594aa612016-08-16 18:21:18 -0700201 if (rtc_include_pulse_audio) {
202 sources += [
203 "linux/audio_device_pulse_linux.cc",
204 "linux/audio_device_pulse_linux.h",
205 "linux/audio_mixer_manager_pulse_linux.cc",
206 "linux/audio_mixer_manager_pulse_linux.h",
207 "linux/pulseaudiosymboltable_linux.cc",
208 "linux/pulseaudiosymboltable_linux.h",
209 ]
210 defines += [ "LINUX_PULSE" ]
211 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000212 }
noahricc594aa612016-08-16 18:21:18 -0700213 if (is_mac) {
214 sources += [
215 "mac/audio_device_mac.cc",
216 "mac/audio_device_mac.h",
217 "mac/audio_mixer_manager_mac.cc",
218 "mac/audio_mixer_manager_mac.h",
noahricc594aa612016-08-16 18:21:18 -0700219 ]
kjellander7439f972016-12-05 22:47:46 -0800220 deps += [ ":mac_portaudio" ]
noahricc594aa612016-08-16 18:21:18 -0700221 libs = [
maxmorin2ec45b92016-08-24 06:51:09 -0700222 # Needed for CoreGraphics:
223 "ApplicationServices.framework",
224
noahricc594aa612016-08-16 18:21:18 -0700225 "AudioToolbox.framework",
226 "CoreAudio.framework",
kjellanderbac04122016-06-02 02:18:48 -0700227
noahricc594aa612016-08-16 18:21:18 -0700228 # Needed for CGEventSourceKeyState in audio_device_mac.cc:
229 "CoreGraphics.framework",
230 ]
231 }
noahricc594aa612016-08-16 18:21:18 -0700232 if (is_win) {
233 sources += [
234 "win/audio_device_core_win.cc",
235 "win/audio_device_core_win.h",
noahricc594aa612016-08-16 18:21:18 -0700236 ]
237 libs = [
238 # Required for the built-in WASAPI AEC.
239 "dmoguids.lib",
240 "wmcodecdspuuid.lib",
241 "amstrmid.lib",
242 "msdmo.lib",
243 ]
244 }
ehmaldonadod02fe4b2016-08-26 13:31:24 -0700245 configs += [ ":audio_device_warnings_config" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000246 }
247 } else {
248 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
249 }
250
251 if (!build_with_chromium) {
252 sources += [
253 # Do not link these into Chrome since they contain static data.
254 "dummy/file_audio_device_factory.cc",
255 "dummy/file_audio_device_factory.h",
256 ]
257 }
258
kjellandere40a7ee2016-10-16 23:56:12 -0700259 if (!build_with_chromium && is_clang) {
260 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700261 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000262 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000263}
maxmorin69105372016-08-16 02:17:44 -0700264
kjellander7439f972016-12-05 22:47:46 -0800265rtc_source_set("mac_portaudio") {
266 visibility = [ ":*" ] # Only targets in this file can depend on this.
267 sources = [
268 "mac/portaudio/pa_memorybarrier.h",
269 "mac/portaudio/pa_ringbuffer.c",
270 "mac/portaudio/pa_ringbuffer.h",
271 ]
272}
273
aleloi44c7ecf2016-11-10 08:16:25 -0800274config("mock_audio_device_config") {
275 if (is_win) {
276 cflags = [
277 # TODO(phoglund): get rid of 4373 supression when
278 # http://code.google.com/p/webrtc/issues/detail?id=261 is solved.
279 # legacy warning for ignoring const / volatile in signatures.
280 "/wd4373",
281 ]
282 }
283}
284
mbonadei3edccb92017-06-01 04:47:20 -0700285rtc_source_set("mock_audio_device") {
286 testonly = true
287 sources = [
288 "include/mock_audio_device.h",
289 "include/mock_audio_transport.h",
290 ]
291 deps = [
292 ":audio_device",
293 "../../test:test_support",
294 ]
295 all_dependent_configs = [ ":mock_audio_device_config" ]
296}
297
aleloi5de52fd2016-11-10 01:05:34 -0800298if (rtc_include_tests) {
mbonadeibcc21762017-09-12 04:45:24 -0700299 # TODO(kthelgason): Reenable these tests on simulator.
300 # See bugs.webrtc.org/7812
301 if (is_ios && !use_ios_simulator) {
302 rtc_source_set("audio_device_ios_objc_unittests") {
303 testonly = true
304 visibility = [ ":*" ]
305 sources = [
306 "ios/audio_device_unittest_ios.mm",
307 ]
308 deps = [
309 ":audio_device",
310 ":mock_audio_device",
311 "../../rtc_base:rtc_base_approved",
312 "../../sdk:audio_objc",
313 "../../system_wrappers",
314 "../../test:test_support",
315 "//testing/gmock",
316 "//third_party/ocmock",
317 ]
318 if (!build_with_chromium && is_clang) {
319 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
320 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
321 }
322 }
323 }
324
ehmaldonado36268652017-01-19 08:27:11 -0800325 rtc_source_set("audio_device_unittests") {
326 testonly = true
kjellandere0629c02017-04-25 04:04:50 -0700327
ehmaldonado36268652017-01-19 08:27:11 -0800328 sources = [
329 "fine_audio_buffer_unittest.cc",
330 ]
331 deps = [
332 ":audio_device",
333 ":mock_audio_device",
kwiberg529662a2017-09-04 05:43:17 -0700334 "../../api:array_view",
kwiberg84f6a3f2017-09-05 08:43:13 -0700335 "../../api:optional",
Patrik Höglunda8005cf2017-12-13 16:05:42 +0100336 "../../rtc_base:checks",
ehmaldonadof6a861a2017-07-19 10:40:47 -0700337 "../../rtc_base:rtc_base_approved",
mbonadeibcc21762017-09-12 04:45:24 -0700338 "../../system_wrappers",
ehmaldonado36268652017-01-19 08:27:11 -0800339 "../../test:test_support",
340 "../utility:utility",
341 "//testing/gmock",
342 ]
henrika1b35bab2017-03-29 07:50:19 -0700343 if (is_linux || is_mac || is_win) {
henrikaf2f91fa2017-03-17 04:26:22 -0700344 sources += [ "audio_device_unittest.cc" ]
345 }
ehmaldonado36268652017-01-19 08:27:11 -0800346 if (is_android) {
347 # Need to disable error due to the line in
348 # base/android/jni_android.h triggering it:
349 # const BASE_EXPORT jobject GetApplicationContext()
350 # error: type qualifiers ignored on function return type
351 cflags = [ "-Wno-ignored-qualifiers" ]
352 sources += [
353 "android/audio_device_unittest.cc",
354 "android/audio_manager_unittest.cc",
355 "android/ensure_initialized.cc",
356 "android/ensure_initialized.h",
357 ]
358 deps += [
359 "../../../base",
jianjun.zhuc0247402017-07-11 06:20:45 -0700360 "../../sdk/android:libjingle_peerconnection_java",
ehmaldonado36268652017-01-19 08:27:11 -0800361 ]
362 }
ehmaldonado36268652017-01-19 08:27:11 -0800363 if (!build_with_chromium && is_clang) {
364 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
365 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
366 }
Joachim Bauch5d2bb362017-12-20 21:19:49 +0100367 if (!rtc_include_internal_audio_device) {
368 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
369 }
ehmaldonado36268652017-01-19 08:27:11 -0800370 }
maxmorin69105372016-08-16 02:17:44 -0700371}
mbonadei438062b2017-01-09 02:37:21 -0800372
373if (!build_with_chromium && is_android) {
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000374 rtc_android_library("audio_device_java") {
mbonadeib55bd972017-01-23 01:25:53 -0800375 java_files = [
mbonadei438062b2017-01-09 02:37:21 -0800376 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
377 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
378 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
379 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
380 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
381 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
382 ]
mbonadeib55bd972017-01-23 01:25:53 -0800383 deps = [
jianjun.zhuc0247402017-07-11 06:20:45 -0700384 "../../rtc_base:base_java",
mbonadeib55bd972017-01-23 01:25:53 -0800385 ]
mbonadei438062b2017-01-09 02:37:21 -0800386 }
387}