blob: 2fd6f9b7bb5b6bde864009bf5d80982712320d7d [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",
79 "../../rtc_base:gtest_prod",
80 "../../rtc_base:rtc_base",
81 "../../sdk:audio_objc",
82 "../../sdk:common_objc",
83 "../../system_wrappers:metrics_api",
84 ]
85 if (!build_with_chromium && is_clang) {
86 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
87 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
88 }
89 }
90}
91
92rtc_source_set("audio_device_generic") {
93 visibility = [
94 ":audio_device",
95 ":audio_device_ios_objc",
96 ]
ehmaldonadoe9cc6862016-09-05 06:10:18 -070097 public_configs = [ ":audio_device_config" ]
ehmaldonadod02fe4b2016-08-26 13:31:24 -070098
Zeke Chinb3fb71c2016-02-18 15:44:07 -080099 deps = [
mbonadei1140f972017-04-26 03:38:35 -0700100 "..:module_api",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800101 "../..:webrtc_common",
kwiberg529662a2017-09-04 05:43:17 -0700102 "../../api:array_view",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800103 "../../common_audio",
ehmaldonadof6a861a2017-07-19 10:40:47 -0700104 "../../rtc_base:rtc_base_approved",
105 "../../rtc_base:rtc_task_queue",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800106 "../../system_wrappers",
Mirko Bonadeia498ae82017-12-06 09:17:14 +0100107 "../../system_wrappers:metrics_api",
Zeke Chinb3fb71c2016-02-18 15:44:07 -0800108 "../utility",
109 ]
110
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000111 sources = [
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000112 "audio_device_buffer.cc",
113 "audio_device_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200114 "audio_device_config.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000115 "audio_device_generic.cc",
116 "audio_device_generic.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000117 "dummy/audio_device_dummy.cc",
118 "dummy/audio_device_dummy.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000119 "dummy/file_audio_device.cc",
120 "dummy/file_audio_device.h",
henrika86d907c2015-09-07 16:09:50 +0200121 "fine_audio_buffer.cc",
122 "fine_audio_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200123 "include/audio_device.h",
124 "include/audio_device_defines.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000125 ]
126
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000127 include_dirs = []
128 if (is_linux) {
129 include_dirs += [ "linux" ]
130 }
131 if (is_ios) {
132 include_dirs += [ "ios" ]
133 }
134 if (is_mac) {
135 include_dirs += [ "mac" ]
136 }
137 if (is_win) {
138 include_dirs += [ "win" ]
139 }
140 if (is_android) {
141 include_dirs += [ "android" ]
142 }
Henrik Kjellanderb79472a2015-10-14 08:13:58 +0200143 defines = []
kjellander70bed7d2015-11-23 17:23:44 -0800144 cflags = []
henrika7be78832017-06-13 17:34:16 +0200145 if (rtc_audio_device_plays_sinus_tone) {
146 defines += [ "AUDIO_DEVICE_PLAYS_SINUS_TONE" ]
147 }
kjellander@webrtc.org6d08ca62014-09-07 17:36:10 +0000148 if (rtc_include_internal_audio_device) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000149 sources += [
Lu Liu4b620012017-04-06 10:17:01 -0700150 "audio_device_data_observer.cc",
Tommi931e6582015-05-20 09:44:38 +0200151 "audio_device_impl.cc",
152 "audio_device_impl.h",
Lu Liu4b620012017-04-06 10:17:01 -0700153 "include/audio_device_data_observer.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000154 ]
kjellandera46a4c92016-01-07 02:54:22 -0800155 if (is_android) {
156 sources += [
157 "android/audio_device_template.h",
158 "android/audio_manager.cc",
159 "android/audio_manager.h",
160 "android/audio_record_jni.cc",
161 "android/audio_record_jni.h",
162 "android/audio_track_jni.cc",
163 "android/audio_track_jni.h",
164 "android/build_info.cc",
165 "android/build_info.h",
166 "android/opensles_common.cc",
167 "android/opensles_common.h",
168 "android/opensles_player.cc",
169 "android/opensles_player.h",
henrika918b5542016-09-19 15:44:09 +0200170 "android/opensles_recorder.cc",
171 "android/opensles_recorder.h",
kjellandera46a4c92016-01-07 02:54:22 -0800172 ]
173 libs = [
174 "log",
175 "OpenSLES",
176 ]
177 }
noahricc594aa612016-08-16 18:21:18 -0700178 if (rtc_use_dummy_audio_file_devices) {
179 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
180 } else {
181 if (is_linux) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000182 sources += [
noahricc594aa612016-08-16 18:21:18 -0700183 "linux/alsasymboltable_linux.cc",
184 "linux/alsasymboltable_linux.h",
185 "linux/audio_device_alsa_linux.cc",
186 "linux/audio_device_alsa_linux.h",
187 "linux/audio_mixer_manager_alsa_linux.cc",
188 "linux/audio_mixer_manager_alsa_linux.h",
189 "linux/latebindingsymboltable_linux.cc",
190 "linux/latebindingsymboltable_linux.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000191 ]
noahricc594aa612016-08-16 18:21:18 -0700192 defines += [ "LINUX_ALSA" ]
kjellanderc41d0c42017-05-30 12:06:04 -0700193 libs = [ "dl" ]
194 if (use_x11) {
195 libs += [ "X11" ]
196 }
noahricc594aa612016-08-16 18:21:18 -0700197 if (rtc_include_pulse_audio) {
198 sources += [
199 "linux/audio_device_pulse_linux.cc",
200 "linux/audio_device_pulse_linux.h",
201 "linux/audio_mixer_manager_pulse_linux.cc",
202 "linux/audio_mixer_manager_pulse_linux.h",
203 "linux/pulseaudiosymboltable_linux.cc",
204 "linux/pulseaudiosymboltable_linux.h",
205 ]
206 defines += [ "LINUX_PULSE" ]
207 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000208 }
noahricc594aa612016-08-16 18:21:18 -0700209 if (is_mac) {
210 sources += [
211 "mac/audio_device_mac.cc",
212 "mac/audio_device_mac.h",
213 "mac/audio_mixer_manager_mac.cc",
214 "mac/audio_mixer_manager_mac.h",
noahricc594aa612016-08-16 18:21:18 -0700215 ]
kjellander7439f972016-12-05 22:47:46 -0800216 deps += [ ":mac_portaudio" ]
noahricc594aa612016-08-16 18:21:18 -0700217 libs = [
maxmorin2ec45b92016-08-24 06:51:09 -0700218 # Needed for CoreGraphics:
219 "ApplicationServices.framework",
220
noahricc594aa612016-08-16 18:21:18 -0700221 "AudioToolbox.framework",
222 "CoreAudio.framework",
kjellanderbac04122016-06-02 02:18:48 -0700223
noahricc594aa612016-08-16 18:21:18 -0700224 # Needed for CGEventSourceKeyState in audio_device_mac.cc:
225 "CoreGraphics.framework",
226 ]
227 }
noahricc594aa612016-08-16 18:21:18 -0700228 if (is_win) {
229 sources += [
230 "win/audio_device_core_win.cc",
231 "win/audio_device_core_win.h",
noahricc594aa612016-08-16 18:21:18 -0700232 ]
233 libs = [
234 # Required for the built-in WASAPI AEC.
235 "dmoguids.lib",
236 "wmcodecdspuuid.lib",
237 "amstrmid.lib",
238 "msdmo.lib",
239 ]
240 }
ehmaldonadod02fe4b2016-08-26 13:31:24 -0700241 configs += [ ":audio_device_warnings_config" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000242 }
243 } else {
244 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
245 }
246
247 if (!build_with_chromium) {
248 sources += [
249 # Do not link these into Chrome since they contain static data.
250 "dummy/file_audio_device_factory.cc",
251 "dummy/file_audio_device_factory.h",
252 ]
253 }
254
kjellandere40a7ee2016-10-16 23:56:12 -0700255 if (!build_with_chromium && is_clang) {
256 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700257 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000258 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000259}
maxmorin69105372016-08-16 02:17:44 -0700260
kjellander7439f972016-12-05 22:47:46 -0800261rtc_source_set("mac_portaudio") {
262 visibility = [ ":*" ] # Only targets in this file can depend on this.
263 sources = [
264 "mac/portaudio/pa_memorybarrier.h",
265 "mac/portaudio/pa_ringbuffer.c",
266 "mac/portaudio/pa_ringbuffer.h",
267 ]
268}
269
aleloi44c7ecf2016-11-10 08:16:25 -0800270config("mock_audio_device_config") {
271 if (is_win) {
272 cflags = [
273 # TODO(phoglund): get rid of 4373 supression when
274 # http://code.google.com/p/webrtc/issues/detail?id=261 is solved.
275 # legacy warning for ignoring const / volatile in signatures.
276 "/wd4373",
277 ]
278 }
279}
280
mbonadei3edccb92017-06-01 04:47:20 -0700281rtc_source_set("mock_audio_device") {
282 testonly = true
283 sources = [
284 "include/mock_audio_device.h",
285 "include/mock_audio_transport.h",
286 ]
287 deps = [
288 ":audio_device",
289 "../../test:test_support",
290 ]
291 all_dependent_configs = [ ":mock_audio_device_config" ]
292}
293
aleloi5de52fd2016-11-10 01:05:34 -0800294if (rtc_include_tests) {
mbonadeibcc21762017-09-12 04:45:24 -0700295 # TODO(kthelgason): Reenable these tests on simulator.
296 # See bugs.webrtc.org/7812
297 if (is_ios && !use_ios_simulator) {
298 rtc_source_set("audio_device_ios_objc_unittests") {
299 testonly = true
300 visibility = [ ":*" ]
301 sources = [
302 "ios/audio_device_unittest_ios.mm",
303 ]
304 deps = [
305 ":audio_device",
306 ":mock_audio_device",
307 "../../rtc_base:rtc_base_approved",
308 "../../sdk:audio_objc",
309 "../../system_wrappers",
310 "../../test:test_support",
311 "//testing/gmock",
312 "//third_party/ocmock",
313 ]
314 if (!build_with_chromium && is_clang) {
315 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
316 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
317 }
318 }
319 }
320
ehmaldonado36268652017-01-19 08:27:11 -0800321 rtc_source_set("audio_device_unittests") {
322 testonly = true
kjellandere0629c02017-04-25 04:04:50 -0700323
ehmaldonado36268652017-01-19 08:27:11 -0800324 sources = [
325 "fine_audio_buffer_unittest.cc",
326 ]
327 deps = [
328 ":audio_device",
329 ":mock_audio_device",
kwiberg529662a2017-09-04 05:43:17 -0700330 "../../api:array_view",
kwiberg84f6a3f2017-09-05 08:43:13 -0700331 "../../api:optional",
ehmaldonadof6a861a2017-07-19 10:40:47 -0700332 "../../rtc_base:rtc_base_approved",
mbonadeibcc21762017-09-12 04:45:24 -0700333 "../../system_wrappers",
ehmaldonado36268652017-01-19 08:27:11 -0800334 "../../test:test_support",
335 "../utility:utility",
336 "//testing/gmock",
337 ]
henrika1b35bab2017-03-29 07:50:19 -0700338 if (is_linux || is_mac || is_win) {
henrikaf2f91fa2017-03-17 04:26:22 -0700339 sources += [ "audio_device_unittest.cc" ]
340 }
ehmaldonado36268652017-01-19 08:27:11 -0800341 if (is_android) {
342 # Need to disable error due to the line in
343 # base/android/jni_android.h triggering it:
344 # const BASE_EXPORT jobject GetApplicationContext()
345 # error: type qualifiers ignored on function return type
346 cflags = [ "-Wno-ignored-qualifiers" ]
347 sources += [
348 "android/audio_device_unittest.cc",
349 "android/audio_manager_unittest.cc",
350 "android/ensure_initialized.cc",
351 "android/ensure_initialized.h",
352 ]
353 deps += [
354 "../../../base",
jianjun.zhuc0247402017-07-11 06:20:45 -0700355 "../../sdk/android:libjingle_peerconnection_java",
ehmaldonado36268652017-01-19 08:27:11 -0800356 ]
357 }
ehmaldonado36268652017-01-19 08:27:11 -0800358 if (!build_with_chromium && is_clang) {
359 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
360 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
361 }
362 }
maxmorin69105372016-08-16 02:17:44 -0700363}
mbonadei438062b2017-01-09 02:37:21 -0800364
365if (!build_with_chromium && is_android) {
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000366 rtc_android_library("audio_device_java") {
mbonadeib55bd972017-01-23 01:25:53 -0800367 java_files = [
mbonadei438062b2017-01-09 02:37:21 -0800368 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
369 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
370 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
371 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
372 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
373 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
374 ]
mbonadeib55bd972017-01-23 01:25:53 -0800375 deps = [
jianjun.zhuc0247402017-07-11 06:20:45 -0700376 "../../rtc_base:base_java",
mbonadeib55bd972017-01-23 01:25:53 -0800377 ]
mbonadei438062b2017-01-09 02:37:21 -0800378 }
379}