Create an initial chrome://supervised-user-internals page
[chromium-blink-merge.git] / media / audio / BUILD.gn
blob8d1b802c53f8ccccedcb274dff83f32e1eae674d
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/linux/pkg_config.gni")
6 import("//media/media_options.gni")
8 # When libpulse is not directly linked, use stubs to allow for dlopening of the
9 # binary.
10 if (!link_pulseaudio) {
11   action("pulse_generate_stubs") {
12     extra_header = "pulse/pulse_stub_header.fragment"
14     script = "../../tools/generate_stubs/generate_stubs.py"
15     sources = [
16       "pulse/pulse.sigs",
17     ]
18     inputs = [
19       extra_header,
20     ]
21     stubs_filename_root = "pulse_stubs"
23     # TODO(ajwong): these need to be included in the pulse build.
24     outputs = [
25       "$target_gen_dir/pulse/$stubs_filename_root.cc",
26       "$target_gen_dir/pulse/$stubs_filename_root.h",
27     ]
28     args = [
29       "-i",
30       rebase_path("$target_gen_dir/pulse", root_build_dir),
31       "-o",
32       rebase_path("$target_gen_dir/pulse", root_build_dir),
33       "-t",
34       "posix_stubs",
35       "-e",
36       rebase_path(extra_header, root_build_dir),
37       "-s",
38       stubs_filename_root,
39       "-p",
40       "media/audio/pulse",
41     ]
43     args += rebase_path(sources, root_build_dir)
44   }
47 source_set("audio") {
48   visibility = [ "//media/*" ]
49   sources = [
50     "agc_audio_stream.h",
51     "audio_device_name.cc",
52     "audio_device_name.h",
53     "audio_device_thread.cc",
54     "audio_device_thread.h",
55     "audio_input_controller.cc",
56     "audio_input_controller.h",
57     "audio_input_device.cc",
58     "audio_input_device.h",
59     "audio_input_ipc.cc",
60     "audio_input_ipc.h",
61     "audio_io.h",
62     "audio_manager.cc",
63     "audio_manager.h",
64     "audio_manager_base.cc",
65     "audio_manager_base.h",
66     "audio_output_controller.cc",
67     "audio_output_controller.h",
68     "audio_output_device.cc",
69     "audio_output_device.h",
70     "audio_output_dispatcher.cc",
71     "audio_output_dispatcher.h",
72     "audio_output_dispatcher_impl.cc",
73     "audio_output_dispatcher_impl.h",
74     "audio_output_ipc.cc",
75     "audio_output_ipc.h",
76     "audio_output_proxy.cc",
77     "audio_output_proxy.h",
78     "audio_output_resampler.cc",
79     "audio_output_resampler.h",
80     "audio_output_stream_sink.cc",
81     "audio_output_stream_sink.h",
82     "audio_power_monitor.cc",
83     "audio_power_monitor.h",
84     "audio_source_diverter.h",
85     "clockless_audio_sink.cc",
86     "clockless_audio_sink.h",
87     "fake_audio_input_stream.cc",
88     "fake_audio_input_stream.h",
89     "fake_audio_log_factory.cc",
90     "fake_audio_log_factory.h",
91     "fake_audio_manager.cc",
92     "fake_audio_manager.h",
93     "fake_audio_output_stream.cc",
94     "fake_audio_output_stream.h",
95     "fake_audio_worker.cc",
96     "fake_audio_worker.h",
97     "null_audio_sink.cc",
98     "null_audio_sink.h",
99     "sample_rates.cc",
100     "sample_rates.h",
101     "scoped_task_runner_observer.cc",
102     "scoped_task_runner_observer.h",
103     "simple_sources.cc",
104     "simple_sources.h",
105     "sounds/audio_stream_handler.cc",
106     "sounds/audio_stream_handler.h",
107     "sounds/sounds_manager.cc",
108     "sounds/sounds_manager.h",
109     "sounds/wav_audio_handler.cc",
110     "sounds/wav_audio_handler.h",
111     "virtual_audio_input_stream.cc",
112     "virtual_audio_input_stream.h",
113     "virtual_audio_output_stream.cc",
114     "virtual_audio_output_stream.h",
115   ]
116   deps = []
117   libs = []
118   configs += [
119     "//media:media_config",
120     "//media:media_implementation",
121   ]
123   if (is_mac) {
124     sources += [
125       "mac/audio_auhal_mac.cc",
126       "mac/audio_auhal_mac.h",
127       "mac/audio_device_listener_mac.cc",
128       "mac/audio_device_listener_mac.h",
129       "mac/audio_input_mac.cc",
130       "mac/audio_input_mac.h",
131       "mac/audio_low_latency_input_mac.cc",
132       "mac/audio_low_latency_input_mac.h",
133       "mac/audio_manager_mac.cc",
134       "mac/audio_manager_mac.h",
135     ]
136     libs += [
137       "AudioToolbox.framework",
138       "AudioUnit.framework",
139       "CoreAudio.framework",
140     ]
141   }
143   if (is_win) {
144     sources += [
145       "win/audio_device_listener_win.cc",
146       "win/audio_device_listener_win.h",
147       "win/audio_low_latency_input_win.cc",
148       "win/audio_low_latency_input_win.h",
149       "win/audio_low_latency_output_win.cc",
150       "win/audio_low_latency_output_win.h",
151       "win/audio_manager_win.cc",
152       "win/audio_manager_win.h",
153       "win/avrt_wrapper_win.cc",
154       "win/avrt_wrapper_win.h",
155       "win/core_audio_util_win.cc",
156       "win/core_audio_util_win.h",
157       "win/device_enumeration_win.cc",
158       "win/device_enumeration_win.h",
159       "win/wavein_input_win.cc",
160       "win/wavein_input_win.h",
161       "win/waveout_output_win.cc",
162       "win/waveout_output_win.h",
163     ]
164   }
166   if (is_android) {
167     sources += [
168       "android/audio_manager_android.cc",
169       "android/audio_manager_android.h",
170       "android/audio_record_input.cc",
171       "android/audio_record_input.h",
172       "android/opensles_input.cc",
173       "android/opensles_input.h",
174       "android/opensles_output.cc",
175       "android/opensles_output.h",
176       "android/opensles_wrapper.cc",
177     ]
178     deps += [ "//media/base/android:media_jni_headers" ]
179   }
181   if (is_openbsd) {
182     sources += [
183       "openbsd/audio_manager_openbsd.cc",
184       "openbsd/audio_manager_openbsd.h",
185     ]
186   }
188   if (is_linux) {
189     sources += [ "linux/audio_manager_linux.cc" ]
190   }
192   if (use_alsa) {
193     libs += [ "asound" ]
194     defines = [ "USE_ALSA" ]
195     sources += [
196       "alsa/alsa_input.cc",
197       "alsa/alsa_input.h",
198       "alsa/alsa_output.cc",
199       "alsa/alsa_output.h",
200       "alsa/alsa_util.cc",
201       "alsa/alsa_util.h",
202       "alsa/alsa_wrapper.cc",
203       "alsa/alsa_wrapper.h",
204       "alsa/audio_manager_alsa.cc",
205       "alsa/audio_manager_alsa.h",
206     ]
207   }
209   if (use_cras) {
210     sources += [
211       "cras/audio_manager_cras.cc",
212       "cras/audio_manager_cras.h",
213       "cras/cras_input.cc",
214       "cras/cras_input.h",
215       "cras/cras_unified.cc",
216       "cras/cras_unified.h",
217     ]
219     pkg_config("libcras") {
220       packages = [ "libcras" ]
221     }
222     configs += [ ":libcras" ]
223     deps += [ "//chromeos:chromeos" ]
224   }
226   if (use_pulseaudio) {
227     sources += [
228       "pulse/audio_manager_pulse.cc",
229       "pulse/audio_manager_pulse.h",
230       "pulse/pulse_input.cc",
231       "pulse/pulse_input.h",
232       "pulse/pulse_output.cc",
233       "pulse/pulse_output.h",
234       "pulse/pulse_util.cc",
235       "pulse/pulse_util.h",
236     ]
238     if (link_pulseaudio) {
239       pkg_config("libpulse") {
240         packages = [ "libpulse" ]
241       }
242       configs += [ ":libpulse" ]
243     } else {
244       # TODO(ajwong): Technically, this dl should go in the action.
245       libs += [ "dl" ]
246       deps += [ ":pulse_generate_stubs" ]
247       sources += get_target_outputs(":pulse_generate_stubs")
248     }
249   }
251   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
254 source_set("test_support") {
255   testonly = true
256   sources = [
257     "audio_unittest_util.cc",
258     "audio_unittest_util.h",
259     "mock_audio_manager.cc",
260     "mock_audio_manager.h",
261     "mock_audio_source_callback.cc",
262     "mock_audio_source_callback.h",
263     "test_audio_input_controller_factory.cc",
264     "test_audio_input_controller_factory.h",
265   ]
266   deps = [
267     "//testing/gmock",
268   ]
269   configs += [ "//media:media_config" ]
272 source_set("unittests") {
273   testonly = true
274   sources = [
275     "audio_input_controller_unittest.cc",
276     "audio_input_unittest.cc",
277     "audio_manager_factory_unittest.cc",
278     "audio_manager_unittest.cc",
279     "audio_output_controller_unittest.cc",
280     "audio_output_device_unittest.cc",
281     "audio_output_proxy_unittest.cc",
282     "audio_parameters_unittest.cc",
283     "audio_power_monitor_unittest.cc",
284     "fake_audio_worker_unittest.cc",
285     "simple_sources_unittest.cc",
286     "virtual_audio_input_stream_unittest.cc",
287     "virtual_audio_output_stream_unittest.cc",
288   ]
289   deps = [
290     ":test_support",
291     "//media/base:test_support",
292     "//testing/gmock",
293     "//testing/gtest",
294     "//url",
295   ]
297   configs += [
298     "//build/config/compiler:no_size_t_to_int_warning",
299     "//media:media_config",
300   ]
302   if (is_android) {
303     sources += [ "android/audio_android_unittest.cc" ]
304     deps += [ "//ui/gl" ]
305   } else {
306     sources += [ "audio_input_volume_unittest.cc" ]
307   }
309   if (is_mac) {
310     sources += [
311       "mac/audio_auhal_mac_unittest.cc",
312       "mac/audio_device_listener_mac_unittest.cc",
313       "mac/audio_low_latency_input_mac_unittest.cc",
314     ]
315   }
317   if (is_chromeos) {
318     sources += [
319       "sounds/audio_stream_handler_unittest.cc",
320       "sounds/sounds_manager_unittest.cc",
321       "sounds/test_data.cc",
322       "sounds/test_data.h",
323       "sounds/wav_audio_handler_unittest.cc",
324     ]
326     if (use_cras) {
327       sources += [
328         "cras/cras_input_unittest.cc",
329         "cras/cras_unified_unittest.cc",
330       ]
331     }
332   }
334   if (is_win) {
335     sources += [
336       "win/audio_device_listener_win_unittest.cc",
337       "win/audio_low_latency_input_win_unittest.cc",
338       "win/audio_low_latency_output_win_unittest.cc",
339       "win/audio_output_win_unittest.cc",
340       "win/core_audio_util_win_unittest.cc",
341     ]
342   }
344   if (use_alsa) {
345     sources += [
346       "alsa/alsa_output_unittest.cc",
347       "audio_low_latency_input_output_unittest.cc",
348     ]
349   }