blob: f9b7f8b6238c9140552c858cb687fd945154fae9 [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 = [
52 "../..:webrtc_common",
53 "../../base:rtc_base_approved",
maxmorin69105372016-08-16 02:17:44 -070054 "../../base:rtc_task_queue",
Zeke Chinb3fb71c2016-02-18 15:44:07 -080055 "../../common_audio",
56 "../../system_wrappers",
57 "../utility",
58 ]
59
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000060 sources = [
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000061 "audio_device_buffer.cc",
62 "audio_device_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +020063 "audio_device_config.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000064 "audio_device_generic.cc",
65 "audio_device_generic.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000066 "dummy/audio_device_dummy.cc",
67 "dummy/audio_device_dummy.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000068 "dummy/file_audio_device.cc",
69 "dummy/file_audio_device.h",
henrika86d907c2015-09-07 16:09:50 +020070 "fine_audio_buffer.cc",
71 "fine_audio_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +020072 "include/audio_device.h",
73 "include/audio_device_defines.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000074 ]
75
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000076 include_dirs = []
77 if (is_linux) {
78 include_dirs += [ "linux" ]
79 }
80 if (is_ios) {
81 include_dirs += [ "ios" ]
82 }
83 if (is_mac) {
84 include_dirs += [ "mac" ]
85 }
86 if (is_win) {
87 include_dirs += [ "win" ]
88 }
89 if (is_android) {
90 include_dirs += [ "android" ]
91 }
Henrik Kjellanderb79472a2015-10-14 08:13:58 +020092 defines = []
kjellander70bed7d2015-11-23 17:23:44 -080093 cflags = []
kjellander@webrtc.org6d08ca62014-09-07 17:36:10 +000094 if (rtc_include_internal_audio_device) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000095 sources += [
Tommi931e6582015-05-20 09:44:38 +020096 "audio_device_impl.cc",
97 "audio_device_impl.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000098 ]
kjellandera46a4c92016-01-07 02:54:22 -080099 if (is_android) {
100 sources += [
101 "android/audio_device_template.h",
102 "android/audio_manager.cc",
103 "android/audio_manager.h",
104 "android/audio_record_jni.cc",
105 "android/audio_record_jni.h",
106 "android/audio_track_jni.cc",
107 "android/audio_track_jni.h",
108 "android/build_info.cc",
109 "android/build_info.h",
110 "android/opensles_common.cc",
111 "android/opensles_common.h",
112 "android/opensles_player.cc",
113 "android/opensles_player.h",
henrika918b5542016-09-19 15:44:09 +0200114 "android/opensles_recorder.cc",
115 "android/opensles_recorder.h",
kjellandera46a4c92016-01-07 02:54:22 -0800116 ]
117 libs = [
118 "log",
119 "OpenSLES",
120 ]
121 }
noahricc594aa612016-08-16 18:21:18 -0700122 if (rtc_use_dummy_audio_file_devices) {
123 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
124 } else {
125 if (is_linux) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000126 sources += [
noahricc594aa612016-08-16 18:21:18 -0700127 "linux/alsasymboltable_linux.cc",
128 "linux/alsasymboltable_linux.h",
129 "linux/audio_device_alsa_linux.cc",
130 "linux/audio_device_alsa_linux.h",
131 "linux/audio_mixer_manager_alsa_linux.cc",
132 "linux/audio_mixer_manager_alsa_linux.h",
133 "linux/latebindingsymboltable_linux.cc",
134 "linux/latebindingsymboltable_linux.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000135 ]
noahricc594aa612016-08-16 18:21:18 -0700136 defines += [ "LINUX_ALSA" ]
137 libs = [
138 "dl",
139 "X11",
140 ]
141 if (rtc_include_pulse_audio) {
142 sources += [
143 "linux/audio_device_pulse_linux.cc",
144 "linux/audio_device_pulse_linux.h",
145 "linux/audio_mixer_manager_pulse_linux.cc",
146 "linux/audio_mixer_manager_pulse_linux.h",
147 "linux/pulseaudiosymboltable_linux.cc",
148 "linux/pulseaudiosymboltable_linux.h",
149 ]
150 defines += [ "LINUX_PULSE" ]
151 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000152 }
noahricc594aa612016-08-16 18:21:18 -0700153 if (is_mac) {
154 sources += [
155 "mac/audio_device_mac.cc",
156 "mac/audio_device_mac.h",
157 "mac/audio_mixer_manager_mac.cc",
158 "mac/audio_mixer_manager_mac.h",
noahricc594aa612016-08-16 18:21:18 -0700159 ]
kjellander7439f972016-12-05 22:47:46 -0800160 deps += [ ":mac_portaudio" ]
noahricc594aa612016-08-16 18:21:18 -0700161 libs = [
maxmorin2ec45b92016-08-24 06:51:09 -0700162 # Needed for CoreGraphics:
163 "ApplicationServices.framework",
164
noahricc594aa612016-08-16 18:21:18 -0700165 "AudioToolbox.framework",
166 "CoreAudio.framework",
kjellanderbac04122016-06-02 02:18:48 -0700167
noahricc594aa612016-08-16 18:21:18 -0700168 # Needed for CGEventSourceKeyState in audio_device_mac.cc:
169 "CoreGraphics.framework",
170 ]
171 }
172 if (is_ios) {
173 public_deps = [
maxmorinec623742016-09-15 05:11:55 -0700174 "../../base:rtc_base",
noahricc594aa612016-08-16 18:21:18 -0700175 "../../sdk:rtc_sdk_common_objc",
176 ]
177 sources += [
178 "ios/audio_device_ios.h",
179 "ios/audio_device_ios.mm",
180 "ios/audio_device_not_implemented_ios.mm",
181 "ios/audio_session_observer.h",
182 "ios/objc/RTCAudioSession+Configuration.mm",
183 "ios/objc/RTCAudioSession+Private.h",
184 "ios/objc/RTCAudioSession.h",
185 "ios/objc/RTCAudioSession.mm",
186 "ios/objc/RTCAudioSessionConfiguration.h",
187 "ios/objc/RTCAudioSessionConfiguration.m",
188 "ios/objc/RTCAudioSessionDelegateAdapter.h",
189 "ios/objc/RTCAudioSessionDelegateAdapter.mm",
190 "ios/voice_processing_audio_unit.h",
191 "ios/voice_processing_audio_unit.mm",
192 ]
193 configs += [ "//build/config/compiler:enable_arc" ]
kjellander95177d12016-04-07 00:13:58 -0700194
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
aleloi5de52fd2016-11-10 01:05:34 -0800255if (rtc_include_tests) {
ehmaldonado36268652017-01-19 08:27:11 -0800256 rtc_source_set("audio_device_unittests") {
257 testonly = true
258 sources = [
259 "fine_audio_buffer_unittest.cc",
260 ]
261 deps = [
262 ":audio_device",
263 ":mock_audio_device",
264 "../../base:rtc_base_approved",
265 "../../system_wrappers:system_wrappers",
266 "../../test:test_support",
267 "../utility:utility",
268 "//testing/gmock",
269 ]
henrika1b35bab2017-03-29 07:50:19 -0700270 if (is_linux || is_mac || is_win) {
henrikaf2f91fa2017-03-17 04:26:22 -0700271 sources += [ "audio_device_unittest.cc" ]
272 }
ehmaldonado36268652017-01-19 08:27:11 -0800273 if (is_android) {
274 # Need to disable error due to the line in
275 # base/android/jni_android.h triggering it:
276 # const BASE_EXPORT jobject GetApplicationContext()
277 # error: type qualifiers ignored on function return type
278 cflags = [ "-Wno-ignored-qualifiers" ]
279 sources += [
280 "android/audio_device_unittest.cc",
281 "android/audio_manager_unittest.cc",
282 "android/ensure_initialized.cc",
283 "android/ensure_initialized.h",
284 ]
285 deps += [
286 "../../../base",
287 "//webrtc/sdk/android:libjingle_peerconnection_java",
288 ]
289 }
290 if (is_ios) {
291 sources += [ "ios/objc/RTCAudioSessionTest.mm" ]
292 configs += [ "//build/config/compiler:enable_arc" ]
293 if (target_cpu != "x64") {
294 sources += [ "ios/audio_device_unittest_ios.cc" ]
295 }
296 }
297 if (!build_with_chromium && is_clang) {
298 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
299 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
300 }
301 }
302
aleloi5de52fd2016-11-10 01:05:34 -0800303 rtc_source_set("mock_audio_device") {
304 testonly = true
305 sources = [
306 "include/mock_audio_device.h",
307 "include/mock_audio_transport.h",
308 ]
309 deps = [
310 ":audio_device",
311 "../../test:test_support",
312 ]
aleloi44c7ecf2016-11-10 08:16:25 -0800313 all_dependent_configs = [ ":mock_audio_device_config" ]
aleloi5de52fd2016-11-10 01:05:34 -0800314 }
tommi3dda2462017-02-26 07:12:50 -0800315
316 if (!is_ios) {
317 # These tests do not work on ios, see
318 # https://bugs.chromium.org/p/webrtc/issues/detail?id=4755
319 rtc_executable("audio_device_tests") {
320 testonly = true
321 sources = [
322 "test/audio_device_test_api.cc",
323 "test/audio_device_test_defines.h",
324 ]
325 deps = [
326 ":audio_device",
327 "../..:webrtc_common",
tommidea489f2017-03-03 03:20:24 -0800328 "../../base:rtc_base_approved",
tommi3dda2462017-02-26 07:12:50 -0800329 "../../system_wrappers",
330 "../../test:test_main",
331 "../../test:test_support",
332 "../rtp_rtcp",
333 "../utility",
334 "//testing/gtest",
335 ]
336 public_configs = [ ":audio_device_config" ]
337 }
338 }
maxmorin69105372016-08-16 02:17:44 -0700339}
mbonadei438062b2017-01-09 02:37:21 -0800340
341if (!build_with_chromium && is_android) {
mbonadeib55bd972017-01-23 01:25:53 -0800342 android_library("audio_device_java") {
343 java_files = [
mbonadei438062b2017-01-09 02:37:21 -0800344 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
345 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
346 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
347 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
348 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
349 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
350 ]
mbonadeib55bd972017-01-23 01:25:53 -0800351 deps = [
352 "//webrtc/base:base_java",
353 ]
mbonadei438062b2017-01-09 02:37:21 -0800354 }
355}