blob: b3ba8524a889d1811a0684ff2b3c5c955c82cd27 [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",
denicija59ee91b2017-06-05 05:48:47 -0700179 "../../sdk:objc_audio",
kthelgason2f088792017-05-30 01:48:47 -0700180 "../../sdk:objc_common",
noahricc594aa612016-08-16 18:21:18 -0700181 ]
182 sources += [
183 "ios/audio_device_ios.h",
184 "ios/audio_device_ios.mm",
185 "ios/audio_device_not_implemented_ios.mm",
186 "ios/audio_session_observer.h",
noahricc594aa612016-08-16 18:21:18 -0700187 "ios/objc/RTCAudioSessionDelegateAdapter.h",
188 "ios/objc/RTCAudioSessionDelegateAdapter.mm",
189 "ios/voice_processing_audio_unit.h",
190 "ios/voice_processing_audio_unit.mm",
191 ]
noahricc594aa612016-08-16 18:21:18 -0700192 libs = [
193 "AudioToolbox.framework",
194 "AVFoundation.framework",
195 "Foundation.framework",
196 "UIKit.framework",
197 ]
198 }
199 if (is_win) {
200 sources += [
201 "win/audio_device_core_win.cc",
202 "win/audio_device_core_win.h",
noahricc594aa612016-08-16 18:21:18 -0700203 ]
204 libs = [
205 # Required for the built-in WASAPI AEC.
206 "dmoguids.lib",
207 "wmcodecdspuuid.lib",
208 "amstrmid.lib",
209 "msdmo.lib",
210 ]
211 }
ehmaldonadod02fe4b2016-08-26 13:31:24 -0700212 configs += [ ":audio_device_warnings_config" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000213 }
214 } else {
215 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
216 }
217
218 if (!build_with_chromium) {
219 sources += [
220 # Do not link these into Chrome since they contain static data.
221 "dummy/file_audio_device_factory.cc",
222 "dummy/file_audio_device_factory.h",
223 ]
224 }
225
kjellandere40a7ee2016-10-16 23:56:12 -0700226 if (!build_with_chromium && is_clang) {
227 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700228 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000229 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000230}
maxmorin69105372016-08-16 02:17:44 -0700231
kjellander7439f972016-12-05 22:47:46 -0800232rtc_source_set("mac_portaudio") {
233 visibility = [ ":*" ] # Only targets in this file can depend on this.
234 sources = [
235 "mac/portaudio/pa_memorybarrier.h",
236 "mac/portaudio/pa_ringbuffer.c",
237 "mac/portaudio/pa_ringbuffer.h",
238 ]
239}
240
aleloi44c7ecf2016-11-10 08:16:25 -0800241config("mock_audio_device_config") {
242 if (is_win) {
243 cflags = [
244 # TODO(phoglund): get rid of 4373 supression when
245 # http://code.google.com/p/webrtc/issues/detail?id=261 is solved.
246 # legacy warning for ignoring const / volatile in signatures.
247 "/wd4373",
248 ]
249 }
250}
251
mbonadei3edccb92017-06-01 04:47:20 -0700252rtc_source_set("mock_audio_device") {
253 testonly = true
254 sources = [
255 "include/mock_audio_device.h",
256 "include/mock_audio_transport.h",
257 ]
258 deps = [
259 ":audio_device",
260 "../../test:test_support",
261 ]
262 all_dependent_configs = [ ":mock_audio_device_config" ]
263}
264
aleloi5de52fd2016-11-10 01:05:34 -0800265if (rtc_include_tests) {
ehmaldonado36268652017-01-19 08:27:11 -0800266 rtc_source_set("audio_device_unittests") {
267 testonly = true
kjellandere0629c02017-04-25 04:04:50 -0700268
269 # Skip restricting visibility on mobile platforms since the tests on those
270 # gets additional generated targets which would require many lines here to
271 # cover (which would be confusing to read and hard to maintain).
272 if (!is_android && !is_ios) {
273 visibility = [ "//webrtc/modules:modules_unittests" ]
274 }
ehmaldonado36268652017-01-19 08:27:11 -0800275 sources = [
276 "fine_audio_buffer_unittest.cc",
277 ]
278 deps = [
279 ":audio_device",
280 ":mock_audio_device",
281 "../../base:rtc_base_approved",
282 "../../system_wrappers:system_wrappers",
283 "../../test:test_support",
284 "../utility:utility",
285 "//testing/gmock",
286 ]
henrika1b35bab2017-03-29 07:50:19 -0700287 if (is_linux || is_mac || is_win) {
henrikaf2f91fa2017-03-17 04:26:22 -0700288 sources += [ "audio_device_unittest.cc" ]
289 }
ehmaldonado36268652017-01-19 08:27:11 -0800290 if (is_android) {
291 # Need to disable error due to the line in
292 # base/android/jni_android.h triggering it:
293 # const BASE_EXPORT jobject GetApplicationContext()
294 # error: type qualifiers ignored on function return type
295 cflags = [ "-Wno-ignored-qualifiers" ]
296 sources += [
297 "android/audio_device_unittest.cc",
298 "android/audio_manager_unittest.cc",
299 "android/ensure_initialized.cc",
300 "android/ensure_initialized.h",
301 ]
302 deps += [
303 "../../../base",
304 "//webrtc/sdk/android:libjingle_peerconnection_java",
305 ]
306 }
307 if (is_ios) {
denicija59ee91b2017-06-05 05:48:47 -0700308 sources += [ "ios/audio_device_unittest_ios.mm" ]
jttehf84c1d62017-04-21 13:56:39 -0700309 deps += [ "//third_party/ocmock" ]
ehmaldonado36268652017-01-19 08:27:11 -0800310 }
311 if (!build_with_chromium && is_clang) {
312 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
313 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
314 }
315 }
316
tommi3dda2462017-02-26 07:12:50 -0800317 if (!is_ios) {
318 # These tests do not work on ios, see
319 # https://bugs.chromium.org/p/webrtc/issues/detail?id=4755
320 rtc_executable("audio_device_tests") {
321 testonly = true
322 sources = [
323 "test/audio_device_test_api.cc",
324 "test/audio_device_test_defines.h",
325 ]
326 deps = [
327 ":audio_device",
328 "../..:webrtc_common",
tommidea489f2017-03-03 03:20:24 -0800329 "../../base:rtc_base_approved",
tommi3dda2462017-02-26 07:12:50 -0800330 "../../system_wrappers",
331 "../../test:test_main",
332 "../../test:test_support",
333 "../rtp_rtcp",
334 "../utility",
335 "//testing/gtest",
336 ]
337 public_configs = [ ":audio_device_config" ]
338 }
339 }
maxmorin69105372016-08-16 02:17:44 -0700340}
mbonadei438062b2017-01-09 02:37:21 -0800341
342if (!build_with_chromium && is_android) {
mbonadeib55bd972017-01-23 01:25:53 -0800343 android_library("audio_device_java") {
344 java_files = [
mbonadei438062b2017-01-09 02:37:21 -0800345 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
346 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
347 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
348 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
349 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
350 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
351 ]
mbonadeib55bd972017-01-23 01:25:53 -0800352 deps = [
353 "//webrtc/base:base_java",
354 ]
mbonadei438062b2017-01-09 02:37:21 -0800355 }
356}