blob: 2db993b7b38b1bfbe2a4dfadd8afa772def72430 [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",
kwiberg529662a2017-09-04 05:43:17 -070054 "../../api:array_view",
Zeke Chinb3fb71c2016-02-18 15:44:07 -080055 "../../common_audio",
ehmaldonadof6a861a2017-07-19 10:40:47 -070056 "../../rtc_base:rtc_base_approved",
57 "../../rtc_base:rtc_task_queue",
Zeke Chinb3fb71c2016-02-18 15:44:07 -080058 "../../system_wrappers",
59 "../utility",
60 ]
61
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000062 sources = [
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000063 "audio_device_buffer.cc",
64 "audio_device_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +020065 "audio_device_config.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000066 "audio_device_generic.cc",
67 "audio_device_generic.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000068 "dummy/audio_device_dummy.cc",
69 "dummy/audio_device_dummy.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000070 "dummy/file_audio_device.cc",
71 "dummy/file_audio_device.h",
henrika86d907c2015-09-07 16:09:50 +020072 "fine_audio_buffer.cc",
73 "fine_audio_buffer.h",
Henrik Kjellander57e5fd22015-05-25 12:55:39 +020074 "include/audio_device.h",
75 "include/audio_device_defines.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000076 ]
77
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +000078 include_dirs = []
79 if (is_linux) {
80 include_dirs += [ "linux" ]
81 }
82 if (is_ios) {
83 include_dirs += [ "ios" ]
84 }
85 if (is_mac) {
86 include_dirs += [ "mac" ]
87 }
88 if (is_win) {
89 include_dirs += [ "win" ]
90 }
91 if (is_android) {
92 include_dirs += [ "android" ]
93 }
Henrik Kjellanderb79472a2015-10-14 08:13:58 +020094 defines = []
kjellander70bed7d2015-11-23 17:23:44 -080095 cflags = []
henrika7be78832017-06-13 17:34:16 +020096 if (rtc_audio_device_plays_sinus_tone) {
97 defines += [ "AUDIO_DEVICE_PLAYS_SINUS_TONE" ]
98 }
kjellander@webrtc.org6d08ca62014-09-07 17:36:10 +000099 if (rtc_include_internal_audio_device) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000100 sources += [
Lu Liu4b620012017-04-06 10:17:01 -0700101 "audio_device_data_observer.cc",
Tommi931e6582015-05-20 09:44:38 +0200102 "audio_device_impl.cc",
103 "audio_device_impl.h",
Lu Liu4b620012017-04-06 10:17:01 -0700104 "include/audio_device_data_observer.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000105 ]
kjellandera46a4c92016-01-07 02:54:22 -0800106 if (is_android) {
107 sources += [
108 "android/audio_device_template.h",
109 "android/audio_manager.cc",
110 "android/audio_manager.h",
111 "android/audio_record_jni.cc",
112 "android/audio_record_jni.h",
113 "android/audio_track_jni.cc",
114 "android/audio_track_jni.h",
115 "android/build_info.cc",
116 "android/build_info.h",
117 "android/opensles_common.cc",
118 "android/opensles_common.h",
119 "android/opensles_player.cc",
120 "android/opensles_player.h",
henrika918b5542016-09-19 15:44:09 +0200121 "android/opensles_recorder.cc",
122 "android/opensles_recorder.h",
kjellandera46a4c92016-01-07 02:54:22 -0800123 ]
124 libs = [
125 "log",
126 "OpenSLES",
127 ]
128 }
noahricc594aa612016-08-16 18:21:18 -0700129 if (rtc_use_dummy_audio_file_devices) {
130 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
131 } else {
132 if (is_linux) {
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000133 sources += [
noahricc594aa612016-08-16 18:21:18 -0700134 "linux/alsasymboltable_linux.cc",
135 "linux/alsasymboltable_linux.h",
136 "linux/audio_device_alsa_linux.cc",
137 "linux/audio_device_alsa_linux.h",
138 "linux/audio_mixer_manager_alsa_linux.cc",
139 "linux/audio_mixer_manager_alsa_linux.h",
140 "linux/latebindingsymboltable_linux.cc",
141 "linux/latebindingsymboltable_linux.h",
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000142 ]
noahricc594aa612016-08-16 18:21:18 -0700143 defines += [ "LINUX_ALSA" ]
kjellanderc41d0c42017-05-30 12:06:04 -0700144 libs = [ "dl" ]
145 if (use_x11) {
146 libs += [ "X11" ]
147 }
noahricc594aa612016-08-16 18:21:18 -0700148 if (rtc_include_pulse_audio) {
149 sources += [
150 "linux/audio_device_pulse_linux.cc",
151 "linux/audio_device_pulse_linux.h",
152 "linux/audio_mixer_manager_pulse_linux.cc",
153 "linux/audio_mixer_manager_pulse_linux.h",
154 "linux/pulseaudiosymboltable_linux.cc",
155 "linux/pulseaudiosymboltable_linux.h",
156 ]
157 defines += [ "LINUX_PULSE" ]
158 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000159 }
noahricc594aa612016-08-16 18:21:18 -0700160 if (is_mac) {
161 sources += [
162 "mac/audio_device_mac.cc",
163 "mac/audio_device_mac.h",
164 "mac/audio_mixer_manager_mac.cc",
165 "mac/audio_mixer_manager_mac.h",
noahricc594aa612016-08-16 18:21:18 -0700166 ]
kjellander7439f972016-12-05 22:47:46 -0800167 deps += [ ":mac_portaudio" ]
noahricc594aa612016-08-16 18:21:18 -0700168 libs = [
maxmorin2ec45b92016-08-24 06:51:09 -0700169 # Needed for CoreGraphics:
170 "ApplicationServices.framework",
171
noahricc594aa612016-08-16 18:21:18 -0700172 "AudioToolbox.framework",
173 "CoreAudio.framework",
kjellanderbac04122016-06-02 02:18:48 -0700174
noahricc594aa612016-08-16 18:21:18 -0700175 # Needed for CGEventSourceKeyState in audio_device_mac.cc:
176 "CoreGraphics.framework",
177 ]
178 }
179 if (is_ios) {
180 public_deps = [
ehmaldonadof6a861a2017-07-19 10:40:47 -0700181 "../../rtc_base:gtest_prod",
182 "../../rtc_base:rtc_base",
kthelgason36d658d2017-08-24 05:43:45 -0700183 "../../sdk:audio_objc",
184 "../../sdk:common_objc",
noahricc594aa612016-08-16 18:21:18 -0700185 ]
186 sources += [
187 "ios/audio_device_ios.h",
188 "ios/audio_device_ios.mm",
189 "ios/audio_device_not_implemented_ios.mm",
190 "ios/audio_session_observer.h",
noahricc594aa612016-08-16 18:21:18 -0700191 "ios/objc/RTCAudioSessionDelegateAdapter.h",
192 "ios/objc/RTCAudioSessionDelegateAdapter.mm",
193 "ios/voice_processing_audio_unit.h",
194 "ios/voice_processing_audio_unit.mm",
195 ]
noahricc594aa612016-08-16 18:21:18 -0700196 libs = [
197 "AudioToolbox.framework",
198 "AVFoundation.framework",
199 "Foundation.framework",
200 "UIKit.framework",
201 ]
202 }
203 if (is_win) {
204 sources += [
205 "win/audio_device_core_win.cc",
206 "win/audio_device_core_win.h",
noahricc594aa612016-08-16 18:21:18 -0700207 ]
208 libs = [
209 # Required for the built-in WASAPI AEC.
210 "dmoguids.lib",
211 "wmcodecdspuuid.lib",
212 "amstrmid.lib",
213 "msdmo.lib",
214 ]
215 }
ehmaldonadod02fe4b2016-08-26 13:31:24 -0700216 configs += [ ":audio_device_warnings_config" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000217 }
218 } else {
219 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ]
220 }
221
222 if (!build_with_chromium) {
223 sources += [
224 # Do not link these into Chrome since they contain static data.
225 "dummy/file_audio_device_factory.cc",
226 "dummy/file_audio_device_factory.h",
227 ]
228 }
229
kjellandere40a7ee2016-10-16 23:56:12 -0700230 if (!build_with_chromium && is_clang) {
231 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700232 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000233 }
kjellander@webrtc.orgc4870bb2014-09-01 04:24:11 +0000234}
maxmorin69105372016-08-16 02:17:44 -0700235
kjellander7439f972016-12-05 22:47:46 -0800236rtc_source_set("mac_portaudio") {
237 visibility = [ ":*" ] # Only targets in this file can depend on this.
238 sources = [
239 "mac/portaudio/pa_memorybarrier.h",
240 "mac/portaudio/pa_ringbuffer.c",
241 "mac/portaudio/pa_ringbuffer.h",
242 ]
243}
244
aleloi44c7ecf2016-11-10 08:16:25 -0800245config("mock_audio_device_config") {
246 if (is_win) {
247 cflags = [
248 # TODO(phoglund): get rid of 4373 supression when
249 # http://code.google.com/p/webrtc/issues/detail?id=261 is solved.
250 # legacy warning for ignoring const / volatile in signatures.
251 "/wd4373",
252 ]
253 }
254}
255
mbonadei3edccb92017-06-01 04:47:20 -0700256rtc_source_set("mock_audio_device") {
257 testonly = true
258 sources = [
259 "include/mock_audio_device.h",
260 "include/mock_audio_transport.h",
261 ]
262 deps = [
263 ":audio_device",
264 "../../test:test_support",
265 ]
266 all_dependent_configs = [ ":mock_audio_device_config" ]
267}
268
aleloi5de52fd2016-11-10 01:05:34 -0800269if (rtc_include_tests) {
ehmaldonado36268652017-01-19 08:27:11 -0800270 rtc_source_set("audio_device_unittests") {
271 testonly = true
kjellandere0629c02017-04-25 04:04:50 -0700272
273 # Skip restricting visibility on mobile platforms since the tests on those
274 # gets additional generated targets which would require many lines here to
275 # cover (which would be confusing to read and hard to maintain).
276 if (!is_android && !is_ios) {
jianjun.zhuc0247402017-07-11 06:20:45 -0700277 visibility = [ "..:modules_unittests" ]
kjellandere0629c02017-04-25 04:04:50 -0700278 }
ehmaldonado36268652017-01-19 08:27:11 -0800279 sources = [
280 "fine_audio_buffer_unittest.cc",
281 ]
282 deps = [
283 ":audio_device",
284 ":mock_audio_device",
kwiberg529662a2017-09-04 05:43:17 -0700285 "../../api:array_view",
kwiberg84f6a3f2017-09-05 08:43:13 -0700286 "../../api:optional",
ehmaldonadof6a861a2017-07-19 10:40:47 -0700287 "../../rtc_base:rtc_base_approved",
ehmaldonado36268652017-01-19 08:27:11 -0800288 "../../system_wrappers:system_wrappers",
289 "../../test:test_support",
290 "../utility:utility",
291 "//testing/gmock",
292 ]
henrika1b35bab2017-03-29 07:50:19 -0700293 if (is_linux || is_mac || is_win) {
henrikaf2f91fa2017-03-17 04:26:22 -0700294 sources += [ "audio_device_unittest.cc" ]
295 }
ehmaldonado36268652017-01-19 08:27:11 -0800296 if (is_android) {
297 # Need to disable error due to the line in
298 # base/android/jni_android.h triggering it:
299 # const BASE_EXPORT jobject GetApplicationContext()
300 # error: type qualifiers ignored on function return type
301 cflags = [ "-Wno-ignored-qualifiers" ]
302 sources += [
303 "android/audio_device_unittest.cc",
304 "android/audio_manager_unittest.cc",
305 "android/ensure_initialized.cc",
306 "android/ensure_initialized.h",
307 ]
308 deps += [
309 "../../../base",
jianjun.zhuc0247402017-07-11 06:20:45 -0700310 "../../sdk/android:libjingle_peerconnection_java",
ehmaldonado36268652017-01-19 08:27:11 -0800311 ]
312 }
oprypin45197522017-06-22 01:47:20 -0700313 if (is_ios && !use_ios_simulator) {
314 # TODO(kthelgason): Reenable these tests on simulator.
315 # See bugs.webrtc.org/7812
denicija59ee91b2017-06-05 05:48:47 -0700316 sources += [ "ios/audio_device_unittest_ios.mm" ]
jttehf84c1d62017-04-21 13:56:39 -0700317 deps += [ "//third_party/ocmock" ]
ehmaldonado36268652017-01-19 08:27:11 -0800318 }
319 if (!build_with_chromium && is_clang) {
320 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
321 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
322 }
323 }
maxmorin69105372016-08-16 02:17:44 -0700324}
mbonadei438062b2017-01-09 02:37:21 -0800325
326if (!build_with_chromium && is_android) {
mbonadeib55bd972017-01-23 01:25:53 -0800327 android_library("audio_device_java") {
328 java_files = [
mbonadei438062b2017-01-09 02:37:21 -0800329 "android/java/src/org/webrtc/voiceengine/BuildInfo.java",
330 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java",
331 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java",
332 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java",
333 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java",
334 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java",
335 ]
mbonadeib55bd972017-01-23 01:25:53 -0800336 deps = [
jianjun.zhuc0247402017-07-11 06:20:45 -0700337 "../../rtc_base:base_java",
mbonadeib55bd972017-01-23 01:25:53 -0800338 ]
charujain474acce2017-08-25 06:21:52 -0700339
340 # TODO(sakal): Fix build hooks crbug.com/webrtc/8148
341 no_build_hooks = true
mbonadei438062b2017-01-09 02:37:21 -0800342 }
343}