blob: 3174ee907b5e0fa8b12452185c8e3a9f8ed510fc [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",
kwiberg529662a2017-09-04 05:43:17 -0700103 "../../api:array_view",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800104 "../../common_audio",
Patrik Höglunda8005cf2017-12-13 16:05:42 +0100105 "../../rtc_base:checks",
ehmaldonadof6a861a2017-07-19 10:40:47 -0700106 "../../rtc_base:rtc_base_approved",
107 "../../rtc_base:rtc_task_queue",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800108 "../../system_wrappers",
Mirko Bonadeia498ae82017-12-06 09:17:14 +0100109 "../../system_wrappers:metrics_api",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800110 "../utility",
111 ]
112
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000113 sources = [
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000114 "audio_device_buffer.cc",
115 "audio_device_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200116 "audio_device_config.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000117 "audio_device_generic.cc",
118 "audio_device_generic.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000119 "dummy/audio_device_dummy.cc",
120 "dummy/audio_device_dummy.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000121 "dummy/file_audio_device.cc",
122 "dummy/file_audio_device.h",
henrika86d907c2015-09-07 16:09:50 +0200123 "fine_audio_buffer.cc",
124 "fine_audio_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200125 "include/audio_device.h",
126 "include/audio_device_defines.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000127 ]
128
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000129 include_dirs = []
130 if (is_linux) {
131 include_dirs += [ "linux" ]
132 }
133 if (is_ios) {
134 include_dirs += [ "ios" ]
135 }
136 if (is_mac) {
137 include_dirs += [ "mac" ]
138 }
139 if (is_win) {
140 include_dirs += [ "win" ]
141 }
142 if (is_android) {
143 include_dirs += [ "android" ]
144 }
Henrik Kjellanderb79472a2015-10-14 08:13:58 +0200145 defines = []
kjellander70bed7d2015-11-23 17:23:44 -0800146 cflags = []
henrika7be78832017-06-13 17:34:16 +0200147 if (rtc_audio_device_plays_sinus_tone) {
148 defines += [ "AUDIO_DEVICE_PLAYS_SINUS_TONE" ]
149 }
kjellander@webrtc.org6d08ca62014-09-07 17:36:10 +0000150 if (rtc_include_internal_audio_device) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000151 sources += [
Lu Liu4b620012017-04-06 10:17:01 -0700152 "audio_device_data_observer.cc",
Tommi931e6582015-05-20 09:44:38 +0200153 "audio_device_impl.cc",
154 "audio_device_impl.h",
Lu Liu4b620012017-04-06 10:17:01 -0700155 "include/audio_device_data_observer.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000156 ]
kjellandera46a4c92016-01-07 02:54:22 -0800157 if (is_android) {
158 sources += [
159 "android/audio_device_template.h",
160 "android/audio_manager.cc",
161 "android/audio_manager.h",
162 "android/audio_record_jni.cc",
163 "android/audio_record_jni.h",
164 "android/audio_track_jni.cc",
165 "android/audio_track_jni.h",
166 "android/build_info.cc",
167 "android/build_info.h",
168 "android/opensles_common.cc",
169 "android/opensles_common.h",
170 "android/opensles_player.cc",
171 "android/opensles_player.h",
henrika918b5542016-09-19 15:44:09 +0200172 "android/opensles_recorder.cc",
173 "android/opensles_recorder.h",
kjellandera46a4c92016-01-07 02:54:22 -0800174 ]
175 libs = [
176 "log",
177 "OpenSLES",
178 ]
179 }
noahricc594aa612016-08-16 18:21:18 -0700180 if (rtc_use_dummy_audio_file_devices) {
181 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
182 } else {
183 if (is_linux) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000184 sources += [
noahricc594aa612016-08-16 18:21:18 -0700185 "linux/alsasymboltable_linux.cc",
186 "linux/alsasymboltable_linux.h",
187 "linux/audio_device_alsa_linux.cc",
188 "linux/audio_device_alsa_linux.h",
189 "linux/audio_mixer_manager_alsa_linux.cc",
190 "linux/audio_mixer_manager_alsa_linux.h",
191 "linux/latebindingsymboltable_linux.cc",
192 "linux/latebindingsymboltable_linux.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000193 ]
noahricc594aa612016-08-16 18:21:18 -0700194 defines += [ "LINUX_ALSA" ]
kjellanderc41d0c42017-05-30 12:06:04 -0700195 libs = [ "dl" ]
196 if (use_x11) {
197 libs += [ "X11" ]
198 }
noahricc594aa612016-08-16 18:21:18 -0700199 if (rtc_include_pulse_audio) {
200 sources += [
201 "linux/audio_device_pulse_linux.cc",
202 "linux/audio_device_pulse_linux.h",
203 "linux/audio_mixer_manager_pulse_linux.cc",
204 "linux/audio_mixer_manager_pulse_linux.h",
205 "linux/pulseaudiosymboltable_linux.cc",
206 "linux/pulseaudiosymboltable_linux.h",
207 ]
208 defines += [ "LINUX_PULSE" ]
209 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000210 }
noahricc594aa612016-08-16 18:21:18 -0700211 if (is_mac) {
212 sources += [
213 "mac/audio_device_mac.cc",
214 "mac/audio_device_mac.h",
215 "mac/audio_mixer_manager_mac.cc",
216 "mac/audio_mixer_manager_mac.h",
noahricc594aa612016-08-16 18:21:18 -0700217 ]
kjellander7439f972016-12-05 22:47:46 -0800218 deps += [ ":mac_portaudio" ]
noahricc594aa612016-08-16 18:21:18 -0700219 libs = [
maxmorin2ec45b92016-08-24 06:51:09 -0700220 # Needed for CoreGraphics:
221 "ApplicationServices.framework",
222
noahricc594aa612016-08-16 18:21:18 -0700223 "AudioToolbox.framework",
224 "CoreAudio.framework",
kjellanderbac04122016-06-02 02:18:48 -0700225
noahricc594aa612016-08-16 18:21:18 -0700226 # Needed for CGEventSourceKeyState in audio_device_mac.cc:
227 "CoreGraphics.framework",
228 ]
229 }
noahricc594aa612016-08-16 18:21:18 -0700230 if (is_win) {
231 sources += [
232 "win/audio_device_core_win.cc",
233 "win/audio_device_core_win.h",
noahricc594aa612016-08-16 18:21:18 -0700234 ]
235 libs = [
236 # Required for the built-in WASAPI AEC.
237 "dmoguids.lib",
238 "wmcodecdspuuid.lib",
239 "amstrmid.lib",
240 "msdmo.lib",
241 ]
242 }
ehmaldonadod02fe4b2016-08-26 13:31:24 -0700243 configs += [ ":audio_device_warnings_config" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000244 }
245 } else {
246 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
247 }
248
249 if (!build_with_chromium) {
250 sources += [
251 # Do not link these into Chrome since they contain static data.
252 "dummy/file_audio_device_factory.cc",
253 "dummy/file_audio_device_factory.h",
254 ]
255 }
256
kjellandere40a7ee2016-10-16 23:56:12 -0700257 if (!build_with_chromium && is_clang) {
258 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700259 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000260 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000261}
maxmorin69105372016-08-16 02:17:44 -0700262
kjellander7439f972016-12-05 22:47:46 -0800263rtc_source_set("mac_portaudio") {
264 visibility = [ ":*" ] # Only targets in this file can depend on this.
265 sources = [
266 "mac/portaudio/pa_memorybarrier.h",
267 "mac/portaudio/pa_ringbuffer.c",
268 "mac/portaudio/pa_ringbuffer.h",
269 ]
270}
271
aleloi44c7ecf2016-11-10 08:16:25 -0800272config("mock_audio_device_config") {
273 if (is_win) {
274 cflags = [
275 # TODO(phoglund): get rid of 4373 supression when
276 # http://code.google.com/p/webrtc/issues/detail?id=261 is solved.
277 # legacy warning for ignoring const / volatile in signatures.
278 "/wd4373",
279 ]
280 }
281}
282
mbonadei3edccb92017-06-01 04:47:20 -0700283rtc_source_set("mock_audio_device") {
284 testonly = true
285 sources = [
286 "include/mock_audio_device.h",
287 "include/mock_audio_transport.h",
288 ]
289 deps = [
290 ":audio_device",
291 "../../test:test_support",
292 ]
293 all_dependent_configs = [ ":mock_audio_device_config" ]
294}
295
aleloi5de52fd2016-11-10 01:05:34 -0800296if (rtc_include_tests) {
mbonadeibcc21762017-09-12 04:45:24 -0700297 # TODO(kthelgason): Reenable these tests on simulator.
298 # See bugs.webrtc.org/7812
299 if (is_ios && !use_ios_simulator) {
300 rtc_source_set("audio_device_ios_objc_unittests") {
301 testonly = true
302 visibility = [ ":*" ]
303 sources = [
304 "ios/audio_device_unittest_ios.mm",
305 ]
306 deps = [
307 ":audio_device",
308 ":mock_audio_device",
309 "../../rtc_base:rtc_base_approved",
310 "../../sdk:audio_objc",
311 "../../system_wrappers",
312 "../../test:test_support",
313 "//testing/gmock",
314 "//third_party/ocmock",
315 ]
316 if (!build_with_chromium && is_clang) {
317 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
318 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
319 }
320 }
321 }
322
ehmaldonado36268652017-01-19 08:27:11 -0800323 rtc_source_set("audio_device_unittests") {
324 testonly = true
kjellandere0629c02017-04-25 04:04:50 -0700325
ehmaldonado36268652017-01-19 08:27:11 -0800326 sources = [
327 "fine_audio_buffer_unittest.cc",
328 ]
329 deps = [
330 ":audio_device",
331 ":mock_audio_device",
kwiberg529662a2017-09-04 05:43:17 -0700332 "../../api:array_view",
kwiberg84f6a3f2017-09-05 08:43:13 -0700333 "../../api:optional",
Patrik Höglunda8005cf2017-12-13 16:05:42 +0100334 "../../rtc_base:checks",
ehmaldonadof6a861a2017-07-19 10:40:47 -0700335 "../../rtc_base:rtc_base_approved",
mbonadeibcc21762017-09-12 04:45:24 -0700336 "../../system_wrappers",
ehmaldonado36268652017-01-19 08:27:11 -0800337 "../../test:test_support",
338 "../utility:utility",
339 "//testing/gmock",
340 ]
henrika1b35bab2017-03-29 07:50:19 -0700341 if (is_linux || is_mac || is_win) {
henrikaf2f91fa2017-03-17 04:26:22 -0700342 sources += [ "audio_device_unittest.cc" ]
343 }
ehmaldonado36268652017-01-19 08:27:11 -0800344 if (is_android) {
345 # Need to disable error due to the line in
346 # base/android/jni_android.h triggering it:
347 # const BASE_EXPORT jobject GetApplicationContext()
348 # error: type qualifiers ignored on function return type
349 cflags = [ "-Wno-ignored-qualifiers" ]
350 sources += [
351 "android/audio_device_unittest.cc",
352 "android/audio_manager_unittest.cc",
353 "android/ensure_initialized.cc",
354 "android/ensure_initialized.h",
355 ]
356 deps += [
357 "../../../base",
jianjun.zhuc0247402017-07-11 06:20:45 -0700358 "../../sdk/android:libjingle_peerconnection_java",
ehmaldonado36268652017-01-19 08:27:11 -0800359 ]
360 }
ehmaldonado36268652017-01-19 08:27:11 -0800361 if (!build_with_chromium && is_clang) {
362 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
363 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
364 }
365 }
maxmorin69105372016-08-16 02:17:44 -0700366}
mbonadei438062b2017-01-09 02:37:21 -0800367
368if (!build_with_chromium && is_android) {
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000369 rtc_android_library("audio_device_java") {
mbonadeib55bd972017-01-23 01:25:53 -0800370 java_files = [
mbonadei438062b2017-01-09 02:37:21 -0800371 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
372 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
373 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
374 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
375 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
376 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
377 ]
mbonadeib55bd972017-01-23 01:25:53 -0800378 deps = [
jianjun.zhuc0247402017-07-11 06:20:45 -0700379 "../../rtc_base:base_java",
mbonadeib55bd972017-01-23 01:25:53 -0800380 ]
mbonadei438062b2017-01-09 02:37:21 -0800381 }
382}