blob: 2f678d6dc082529657946346d84dac3e36960508 [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 = []
kjellander@webrtc.org6d08ca62014-09-07 17:36:10 +000095 if (rtc_include_internal_audio_device) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000096 sources += [
Lu Liu4b620012017-04-06 10:17:01 -070097 "audio_device_data_observer.cc",
Tommi931e6582015-05-20 09:44:38 +020098 "audio_device_impl.cc",
99 "audio_device_impl.h",
Lu Liu4b620012017-04-06 10:17:01 -0700100 "include/audio_device_data_observer.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000101 ]
kjellandera46a4c92016-01-07 02:54:22 -0800102 if (is_android) {
103 sources += [
104 "android/audio_device_template.h",
105 "android/audio_manager.cc",
106 "android/audio_manager.h",
107 "android/audio_record_jni.cc",
108 "android/audio_record_jni.h",
109 "android/audio_track_jni.cc",
110 "android/audio_track_jni.h",
111 "android/build_info.cc",
112 "android/build_info.h",
113 "android/opensles_common.cc",
114 "android/opensles_common.h",
115 "android/opensles_player.cc",
116 "android/opensles_player.h",
henrika918b5542016-09-19 15:44:09 +0200117 "android/opensles_recorder.cc",
118 "android/opensles_recorder.h",
kjellandera46a4c92016-01-07 02:54:22 -0800119 ]
120 libs = [
121 "log",
122 "OpenSLES",
123 ]
124 }
noahricc594aa612016-08-16 18:21:18 -0700125 if (rtc_use_dummy_audio_file_devices) {
126 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
127 } else {
128 if (is_linux) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000129 sources += [
noahricc594aa612016-08-16 18:21:18 -0700130 "linux/alsasymboltable_linux.cc",
131 "linux/alsasymboltable_linux.h",
132 "linux/audio_device_alsa_linux.cc",
133 "linux/audio_device_alsa_linux.h",
134 "linux/audio_mixer_manager_alsa_linux.cc",
135 "linux/audio_mixer_manager_alsa_linux.h",
136 "linux/latebindingsymboltable_linux.cc",
137 "linux/latebindingsymboltable_linux.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000138 ]
noahricc594aa612016-08-16 18:21:18 -0700139 defines += [ "LINUX_ALSA" ]
kjellanderc41d0c42017-05-30 12:06:04 -0700140 libs = [ "dl" ]
141 if (use_x11) {
142 libs += [ "X11" ]
143 }
noahricc594aa612016-08-16 18:21:18 -0700144 if (rtc_include_pulse_audio) {
145 sources += [
146 "linux/audio_device_pulse_linux.cc",
147 "linux/audio_device_pulse_linux.h",
148 "linux/audio_mixer_manager_pulse_linux.cc",
149 "linux/audio_mixer_manager_pulse_linux.h",
150 "linux/pulseaudiosymboltable_linux.cc",
151 "linux/pulseaudiosymboltable_linux.h",
152 ]
153 defines += [ "LINUX_PULSE" ]
154 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000155 }
noahricc594aa612016-08-16 18:21:18 -0700156 if (is_mac) {
157 sources += [
158 "mac/audio_device_mac.cc",
159 "mac/audio_device_mac.h",
160 "mac/audio_mixer_manager_mac.cc",
161 "mac/audio_mixer_manager_mac.h",
noahricc594aa612016-08-16 18:21:18 -0700162 ]
kjellander7439f972016-12-05 22:47:46 -0800163 deps += [ ":mac_portaudio" ]
noahricc594aa612016-08-16 18:21:18 -0700164 libs = [
maxmorin2ec45b92016-08-24 06:51:09 -0700165 # Needed for CoreGraphics:
166 "ApplicationServices.framework",
167
noahricc594aa612016-08-16 18:21:18 -0700168 "AudioToolbox.framework",
169 "CoreAudio.framework",
kjellanderbac04122016-06-02 02:18:48 -0700170
noahricc594aa612016-08-16 18:21:18 -0700171 # Needed for CGEventSourceKeyState in audio_device_mac.cc:
172 "CoreGraphics.framework",
173 ]
174 }
175 if (is_ios) {
176 public_deps = [
jtteh5171a7f2017-05-09 15:09:37 -0700177 "../../base:gtest_prod",
maxmorinec623742016-09-15 05:11:55 -0700178 "../../base:rtc_base",
kthelgason2f088792017-05-30 01:48:47 -0700179 "../../sdk:objc_common",
noahricc594aa612016-08-16 18:21:18 -0700180 ]
181 sources += [
182 "ios/audio_device_ios.h",
183 "ios/audio_device_ios.mm",
184 "ios/audio_device_not_implemented_ios.mm",
185 "ios/audio_session_observer.h",
186 "ios/objc/RTCAudioSession+Configuration.mm",
187 "ios/objc/RTCAudioSession+Private.h",
188 "ios/objc/RTCAudioSession.h",
189 "ios/objc/RTCAudioSession.mm",
190 "ios/objc/RTCAudioSessionConfiguration.h",
191 "ios/objc/RTCAudioSessionConfiguration.m",
192 "ios/objc/RTCAudioSessionDelegateAdapter.h",
193 "ios/objc/RTCAudioSessionDelegateAdapter.mm",
194 "ios/voice_processing_audio_unit.h",
195 "ios/voice_processing_audio_unit.mm",
196 ]
noahricc594aa612016-08-16 18:21:18 -0700197 libs = [
198 "AudioToolbox.framework",
199 "AVFoundation.framework",
200 "Foundation.framework",
201 "UIKit.framework",
202 ]
203 }
204 if (is_win) {
205 sources += [
206 "win/audio_device_core_win.cc",
207 "win/audio_device_core_win.h",
noahricc594aa612016-08-16 18:21:18 -0700208 ]
209 libs = [
210 # Required for the built-in WASAPI AEC.
211 "dmoguids.lib",
212 "wmcodecdspuuid.lib",
213 "amstrmid.lib",
214 "msdmo.lib",
215 ]
216 }
ehmaldonadod02fe4b2016-08-26 13:31:24 -0700217 configs += [ ":audio_device_warnings_config" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000218 }
219 } else {
220 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
221 }
222
223 if (!build_with_chromium) {
224 sources += [
225 # Do not link these into Chrome since they contain static data.
226 "dummy/file_audio_device_factory.cc",
227 "dummy/file_audio_device_factory.h",
228 ]
229 }
230
kjellandere40a7ee2016-10-16 23:56:12 -0700231 if (!build_with_chromium && is_clang) {
232 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700233 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000234 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000235}
maxmorin69105372016-08-16 02:17:44 -0700236
kjellander7439f972016-12-05 22:47:46 -0800237rtc_source_set("mac_portaudio") {
238 visibility = [ ":*" ] # Only targets in this file can depend on this.
239 sources = [
240 "mac/portaudio/pa_memorybarrier.h",
241 "mac/portaudio/pa_ringbuffer.c",
242 "mac/portaudio/pa_ringbuffer.h",
243 ]
244}
245
aleloi44c7ecf2016-11-10 08:16:25 -0800246config("mock_audio_device_config") {
247 if (is_win) {
248 cflags = [
249 # TODO(phoglund): get rid of 4373 supression when
250 # http://code.google.com/p/webrtc/issues/detail?id=261 is solved.
251 # legacy warning for ignoring const / volatile in signatures.
252 "/wd4373",
253 ]
254 }
255}
256
aleloi5de52fd2016-11-10 01:05:34 -0800257if (rtc_include_tests) {
ehmaldonado36268652017-01-19 08:27:11 -0800258 rtc_source_set("audio_device_unittests") {
259 testonly = true
kjellandere0629c02017-04-25 04:04:50 -0700260
261 # Skip restricting visibility on mobile platforms since the tests on those
262 # gets additional generated targets which would require many lines here to
263 # cover (which would be confusing to read and hard to maintain).
264 if (!is_android && !is_ios) {
265 visibility = [ "//webrtc/modules:modules_unittests" ]
266 }
ehmaldonado36268652017-01-19 08:27:11 -0800267 sources = [
268 "fine_audio_buffer_unittest.cc",
269 ]
270 deps = [
271 ":audio_device",
272 ":mock_audio_device",
273 "../../base:rtc_base_approved",
274 "../../system_wrappers:system_wrappers",
275 "../../test:test_support",
276 "../utility:utility",
277 "//testing/gmock",
278 ]
henrika1b35bab2017-03-29 07:50:19 -0700279 if (is_linux || is_mac || is_win) {
henrikaf2f91fa2017-03-17 04:26:22 -0700280 sources += [ "audio_device_unittest.cc" ]
281 }
ehmaldonado36268652017-01-19 08:27:11 -0800282 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" ]
ehmaldonado36268652017-01-19 08:27:11 -0800301 if (target_cpu != "x64") {
jtteh5171a7f2017-05-09 15:09:37 -0700302 sources += [ "ios/audio_device_unittest_ios.mm" ]
ehmaldonado36268652017-01-19 08:27:11 -0800303 }
jttehf84c1d62017-04-21 13:56:39 -0700304 deps += [ "//third_party/ocmock" ]
ehmaldonado36268652017-01-19 08:27:11 -0800305 }
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
mbonadei1a6f1432017-06-01 04:25:40 -0700312 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 ]
322 all_dependent_configs = [ ":mock_audio_device_config" ]
323 }
324
tommi3dda2462017-02-26 07:12:50 -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",
tommidea489f2017-03-03 03:20:24 -0800337 "../../base:rtc_base_approved",
tommi3dda2462017-02-26 07:12:50 -0800338 "../../system_wrappers",
339 "../../test:test_main",
340 "../../test:test_support",
341 "../rtp_rtcp",
342 "../utility",
343 "//testing/gtest",
344 ]
345 public_configs = [ ":audio_device_config" ]
346 }
347 }
maxmorin69105372016-08-16 02:17:44 -0700348}
mbonadei438062b2017-01-09 02:37:21 -0800349
350if (!build_with_chromium && is_android) {
mbonadeib55bd972017-01-23 01:25:53 -0800351 android_library("audio_device_java") {
352 java_files = [
mbonadei438062b2017-01-09 02:37:21 -0800353 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
354 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
355 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
356 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
357 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
358 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
359 ]
mbonadeib55bd972017-01-23 01:25:53 -0800360 deps = [
361 "//webrtc/base:base_java",
362 ]
mbonadei438062b2017-01-09 02:37:21 -0800363 }
364}