blob: c737ac3cd5207cb7ca69e96c3c5fb53b3d6c0be2 [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
kjellanderb62dbbe2016-09-23 00:38:52 -070048rtc_static_library("audio_device") {
ehmaldonadoe9cc6862016-09-05 06:10:18 -070049 public_configs = [ ":audio_device_config" ]
ehmaldonadod02fe4b2016-08-26 13:31:24 -070050
Zeke Chinb3fb71c2016-02-18 15:44:07 -080051 deps = [
mbonadei1140f972017-04-26 03:38:35 -070052 "..:module_api",
Zeke Chinb3fb71c2016-02-18 15:44:07 -080053 "../..:webrtc_common",
54 "../../base:rtc_base_approved",
maxmorin69105372016-08-16 02:17:44 -070055 "../../base:rtc_task_queue",
Zeke Chinb3fb71c2016-02-18 15:44:07 -080056 "../../common_audio",
57 "../../system_wrappers",
58 "../utility",
59 ]
60
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000061 sources = [
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000062 "audio_device_buffer.cc",
63 "audio_device_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +020064 "audio_device_config.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000065 "audio_device_generic.cc",
66 "audio_device_generic.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000067 "dummy/audio_device_dummy.cc",
68 "dummy/audio_device_dummy.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000069 "dummy/file_audio_device.cc",
70 "dummy/file_audio_device.h",
henrika86d907c2015-09-07 16:09:50 +020071 "fine_audio_buffer.cc",
72 "fine_audio_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +020073 "include/audio_device.h",
74 "include/audio_device_defines.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000075 ]
76
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000077 include_dirs = []
78 if (is_linux) {
79 include_dirs += [ "linux" ]
80 }
81 if (is_ios) {
82 include_dirs += [ "ios" ]
83 }
84 if (is_mac) {
85 include_dirs += [ "mac" ]
86 }
87 if (is_win) {
88 include_dirs += [ "win" ]
89 }
90 if (is_android) {
91 include_dirs += [ "android" ]
92 }
Henrik Kjellanderb79472a2015-10-14 08:13:58 +020093 defines = []
kjellander70bed7d2015-11-23 17:23:44 -080094 cflags = []
henrika7be78832017-06-13 17:34:16 +020095 if (rtc_audio_device_plays_sinus_tone) {
96 defines += [ "AUDIO_DEVICE_PLAYS_SINUS_TONE" ]
97 }
kjellander@webrtc.org6d08ca62014-09-07 17:36:10 +000098 if (rtc_include_internal_audio_device) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000099 sources += [
Lu Liu4b620012017-04-06 10:17:01 -0700100 "audio_device_data_observer.cc",
Tommi931e6582015-05-20 09:44:38 +0200101 "audio_device_impl.cc",
102 "audio_device_impl.h",
Lu Liu4b620012017-04-06 10:17:01 -0700103 "include/audio_device_data_observer.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000104 ]
kjellandera46a4c92016-01-07 02:54:22 -0800105 if (is_android) {
106 sources += [
107 "android/audio_device_template.h",
108 "android/audio_manager.cc",
109 "android/audio_manager.h",
110 "android/audio_record_jni.cc",
111 "android/audio_record_jni.h",
112 "android/audio_track_jni.cc",
113 "android/audio_track_jni.h",
114 "android/build_info.cc",
115 "android/build_info.h",
116 "android/opensles_common.cc",
117 "android/opensles_common.h",
118 "android/opensles_player.cc",
119 "android/opensles_player.h",
henrika918b5542016-09-19 15:44:09 +0200120 "android/opensles_recorder.cc",
121 "android/opensles_recorder.h",
kjellandera46a4c92016-01-07 02:54:22 -0800122 ]
123 libs = [
124 "log",
125 "OpenSLES",
126 ]
127 }
noahricc594aa612016-08-16 18:21:18 -0700128 if (rtc_use_dummy_audio_file_devices) {
129 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
130 } else {
131 if (is_linux) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000132 sources += [
noahricc594aa612016-08-16 18:21:18 -0700133 "linux/alsasymboltable_linux.cc",
134 "linux/alsasymboltable_linux.h",
135 "linux/audio_device_alsa_linux.cc",
136 "linux/audio_device_alsa_linux.h",
137 "linux/audio_mixer_manager_alsa_linux.cc",
138 "linux/audio_mixer_manager_alsa_linux.h",
139 "linux/latebindingsymboltable_linux.cc",
140 "linux/latebindingsymboltable_linux.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000141 ]
noahricc594aa612016-08-16 18:21:18 -0700142 defines += [ "LINUX_ALSA" ]
kjellanderc41d0c42017-05-30 12:06:04 -0700143 libs = [ "dl" ]
144 if (use_x11) {
145 libs += [ "X11" ]
146 }
noahricc594aa612016-08-16 18:21:18 -0700147 if (rtc_include_pulse_audio) {
148 sources += [
149 "linux/audio_device_pulse_linux.cc",
150 "linux/audio_device_pulse_linux.h",
151 "linux/audio_mixer_manager_pulse_linux.cc",
152 "linux/audio_mixer_manager_pulse_linux.h",
153 "linux/pulseaudiosymboltable_linux.cc",
154 "linux/pulseaudiosymboltable_linux.h",
155 ]
156 defines += [ "LINUX_PULSE" ]
157 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000158 }
noahricc594aa612016-08-16 18:21:18 -0700159 if (is_mac) {
160 sources += [
161 "mac/audio_device_mac.cc",
162 "mac/audio_device_mac.h",
163 "mac/audio_mixer_manager_mac.cc",
164 "mac/audio_mixer_manager_mac.h",
noahricc594aa612016-08-16 18:21:18 -0700165 ]
kjellander7439f972016-12-05 22:47:46 -0800166 deps += [ ":mac_portaudio" ]
noahricc594aa612016-08-16 18:21:18 -0700167 libs = [
maxmorin2ec45b92016-08-24 06:51:09 -0700168 # Needed for CoreGraphics:
169 "ApplicationServices.framework",
170
noahricc594aa612016-08-16 18:21:18 -0700171 "AudioToolbox.framework",
172 "CoreAudio.framework",
kjellanderbac04122016-06-02 02:18:48 -0700173
noahricc594aa612016-08-16 18:21:18 -0700174 # Needed for CGEventSourceKeyState in audio_device_mac.cc:
175 "CoreGraphics.framework",
176 ]
177 }
178 if (is_ios) {
179 public_deps = [
jtteh5171a7f2017-05-09 15:09:37 -0700180 "../../base:gtest_prod",
maxmorinec623742016-09-15 05:11:55 -0700181 "../../base:rtc_base",
denicija59ee91b2017-06-05 05:48:47 -0700182 "../../sdk:objc_audio",
kthelgason2f088792017-05-30 01:48:47 -0700183 "../../sdk:objc_common",
noahricc594aa612016-08-16 18:21:18 -0700184 ]
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",
noahricc594aa612016-08-16 18:21:18 -0700190 "ios/objc/RTCAudioSessionDelegateAdapter.h",
191 "ios/objc/RTCAudioSessionDelegateAdapter.mm",
192 "ios/voice_processing_audio_unit.h",
193 "ios/voice_processing_audio_unit.mm",
194 ]
noahricc594aa612016-08-16 18:21:18 -0700195 libs = [
196 "AudioToolbox.framework",
197 "AVFoundation.framework",
198 "Foundation.framework",
199 "UIKit.framework",
200 ]
201 }
202 if (is_win) {
203 sources += [
204 "win/audio_device_core_win.cc",
205 "win/audio_device_core_win.h",
noahricc594aa612016-08-16 18:21:18 -0700206 ]
207 libs = [
208 # Required for the built-in WASAPI AEC.
209 "dmoguids.lib",
210 "wmcodecdspuuid.lib",
211 "amstrmid.lib",
212 "msdmo.lib",
213 ]
214 }
ehmaldonadod02fe4b2016-08-26 13:31:24 -0700215 configs += [ ":audio_device_warnings_config" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000216 }
217 } else {
218 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
219 }
220
221 if (!build_with_chromium) {
222 sources += [
223 # Do not link these into Chrome since they contain static data.
224 "dummy/file_audio_device_factory.cc",
225 "dummy/file_audio_device_factory.h",
226 ]
227 }
228
kjellandere40a7ee2016-10-16 23:56:12 -0700229 if (!build_with_chromium && is_clang) {
230 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700231 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000232 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000233}
maxmorin69105372016-08-16 02:17:44 -0700234
kjellander7439f972016-12-05 22:47:46 -0800235rtc_source_set("mac_portaudio") {
236 visibility = [ ":*" ] # Only targets in this file can depend on this.
237 sources = [
238 "mac/portaudio/pa_memorybarrier.h",
239 "mac/portaudio/pa_ringbuffer.c",
240 "mac/portaudio/pa_ringbuffer.h",
241 ]
242}
243
aleloi44c7ecf2016-11-10 08:16:25 -0800244config("mock_audio_device_config") {
245 if (is_win) {
246 cflags = [
247 # TODO(phoglund): get rid of 4373 supression when
248 # http://code.google.com/p/webrtc/issues/detail?id=261 is solved.
249 # legacy warning for ignoring const / volatile in signatures.
250 "/wd4373",
251 ]
252 }
253}
254
mbonadei3edccb92017-06-01 04:47:20 -0700255rtc_source_set("mock_audio_device") {
256 testonly = true
257 sources = [
258 "include/mock_audio_device.h",
259 "include/mock_audio_transport.h",
260 ]
261 deps = [
262 ":audio_device",
263 "../../test:test_support",
264 ]
265 all_dependent_configs = [ ":mock_audio_device_config" ]
266}
267
aleloi5de52fd2016-11-10 01:05:34 -0800268if (rtc_include_tests) {
ehmaldonado36268652017-01-19 08:27:11 -0800269 rtc_source_set("audio_device_unittests") {
270 testonly = true
kjellandere0629c02017-04-25 04:04:50 -0700271
272 # Skip restricting visibility on mobile platforms since the tests on those
273 # gets additional generated targets which would require many lines here to
274 # cover (which would be confusing to read and hard to maintain).
275 if (!is_android && !is_ios) {
276 visibility = [ "//webrtc/modules:modules_unittests" ]
277 }
ehmaldonado36268652017-01-19 08:27:11 -0800278 sources = [
279 "fine_audio_buffer_unittest.cc",
280 ]
281 deps = [
282 ":audio_device",
283 ":mock_audio_device",
284 "../../base:rtc_base_approved",
285 "../../system_wrappers:system_wrappers",
286 "../../test:test_support",
287 "../utility:utility",
288 "//testing/gmock",
289 ]
henrika1b35bab2017-03-29 07:50:19 -0700290 if (is_linux || is_mac || is_win) {
henrikaf2f91fa2017-03-17 04:26:22 -0700291 sources += [ "audio_device_unittest.cc" ]
292 }
ehmaldonado36268652017-01-19 08:27:11 -0800293 if (is_android) {
294 # Need to disable error due to the line in
295 # base/android/jni_android.h triggering it:
296 # const BASE_EXPORT jobject GetApplicationContext()
297 # error: type qualifiers ignored on function return type
298 cflags = [ "-Wno-ignored-qualifiers" ]
299 sources += [
300 "android/audio_device_unittest.cc",
301 "android/audio_manager_unittest.cc",
302 "android/ensure_initialized.cc",
303 "android/ensure_initialized.h",
304 ]
305 deps += [
306 "../../../base",
307 "//webrtc/sdk/android:libjingle_peerconnection_java",
308 ]
309 }
oprypin45197522017-06-22 01:47:20 -0700310 if (is_ios && !use_ios_simulator) {
311 # TODO(kthelgason): Reenable these tests on simulator.
312 # See bugs.webrtc.org/7812
denicija59ee91b2017-06-05 05:48:47 -0700313 sources += [ "ios/audio_device_unittest_ios.mm" ]
jttehf84c1d62017-04-21 13:56:39 -0700314 deps += [ "//third_party/ocmock" ]
ehmaldonado36268652017-01-19 08:27:11 -0800315 }
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
tommi3dda2462017-02-26 07:12:50 -0800322 if (!is_ios) {
323 # These tests do not work on ios, see
324 # https://bugs.chromium.org/p/webrtc/issues/detail?id=4755
325 rtc_executable("audio_device_tests") {
326 testonly = true
327 sources = [
328 "test/audio_device_test_api.cc",
329 "test/audio_device_test_defines.h",
330 ]
331 deps = [
332 ":audio_device",
333 "../..:webrtc_common",
tommidea489f2017-03-03 03:20:24 -0800334 "../../base:rtc_base_approved",
tommi3dda2462017-02-26 07:12:50 -0800335 "../../system_wrappers",
336 "../../test:test_main",
337 "../../test:test_support",
338 "../rtp_rtcp",
339 "../utility",
340 "//testing/gtest",
341 ]
342 public_configs = [ ":audio_device_config" ]
343 }
344 }
maxmorin69105372016-08-16 02:17:44 -0700345}
mbonadei438062b2017-01-09 02:37:21 -0800346
347if (!build_with_chromium && is_android) {
mbonadeib55bd972017-01-23 01:25:53 -0800348 android_library("audio_device_java") {
349 java_files = [
mbonadei438062b2017-01-09 02:37:21 -0800350 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
351 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
352 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
353 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
354 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
355 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
356 ]
mbonadeib55bd972017-01-23 01:25:53 -0800357 deps = [
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +0200358 "//webrtc/base:base_java",
mbonadeib55bd972017-01-23 01:25:53 -0800359 ]
mbonadei438062b2017-01-09 02:37:21 -0800360 }
361}