Delete unused downloads page asset.
[chromium-blink-merge.git] / media / audio / BUILD.gn
blob24ef1efefcef2ce815c724881d09a94305dbf175
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 config("platform_config") {
48   if (use_alsa) {
49     defines = [ "USE_ALSA" ]
50   }
53 source_set("audio") {
54   visibility = [ "//media/*" ]
55   sources = [
56     "agc_audio_stream.h",
57     "audio_device_name.cc",
58     "audio_device_name.h",
59     "audio_device_thread.cc",
60     "audio_device_thread.h",
61     "audio_input_controller.cc",
62     "audio_input_controller.h",
63     "audio_input_device.cc",
64     "audio_input_device.h",
65     "audio_input_ipc.cc",
66     "audio_input_ipc.h",
67     "audio_io.h",
68     "audio_manager.cc",
69     "audio_manager.h",
70     "audio_manager_base.cc",
71     "audio_manager_base.h",
72     "audio_output_controller.cc",
73     "audio_output_controller.h",
74     "audio_output_device.cc",
75     "audio_output_device.h",
76     "audio_output_dispatcher.cc",
77     "audio_output_dispatcher.h",
78     "audio_output_dispatcher_impl.cc",
79     "audio_output_dispatcher_impl.h",
80     "audio_output_ipc.cc",
81     "audio_output_ipc.h",
82     "audio_output_proxy.cc",
83     "audio_output_proxy.h",
84     "audio_output_resampler.cc",
85     "audio_output_resampler.h",
86     "audio_output_stream_sink.cc",
87     "audio_output_stream_sink.h",
88     "audio_power_monitor.cc",
89     "audio_power_monitor.h",
90     "audio_source_diverter.h",
91     "clockless_audio_sink.cc",
92     "clockless_audio_sink.h",
93     "fake_audio_input_stream.cc",
94     "fake_audio_input_stream.h",
95     "fake_audio_log_factory.cc",
96     "fake_audio_log_factory.h",
97     "fake_audio_manager.cc",
98     "fake_audio_manager.h",
99     "fake_audio_output_stream.cc",
100     "fake_audio_output_stream.h",
101     "fake_audio_worker.cc",
102     "fake_audio_worker.h",
103     "null_audio_sink.cc",
104     "null_audio_sink.h",
105     "sample_rates.cc",
106     "sample_rates.h",
107     "scoped_task_runner_observer.cc",
108     "scoped_task_runner_observer.h",
109     "simple_sources.cc",
110     "simple_sources.h",
111     "sounds/audio_stream_handler.cc",
112     "sounds/audio_stream_handler.h",
113     "sounds/sounds_manager.cc",
114     "sounds/sounds_manager.h",
115     "sounds/wav_audio_handler.cc",
116     "sounds/wav_audio_handler.h",
117     "virtual_audio_input_stream.cc",
118     "virtual_audio_input_stream.h",
119     "virtual_audio_output_stream.cc",
120     "virtual_audio_output_stream.h",
121   ]
122   deps = []
123   libs = []
124   configs += [
125     ":platform_config",
126     "//media:media_config",
127     "//media:media_implementation",
128   ]
130   if (is_mac) {
131     sources += [
132       "mac/audio_auhal_mac.cc",
133       "mac/audio_auhal_mac.h",
134       "mac/audio_device_listener_mac.cc",
135       "mac/audio_device_listener_mac.h",
136       "mac/audio_input_mac.cc",
137       "mac/audio_input_mac.h",
138       "mac/audio_low_latency_input_mac.cc",
139       "mac/audio_low_latency_input_mac.h",
140       "mac/audio_manager_mac.cc",
141       "mac/audio_manager_mac.h",
142     ]
143     libs += [
144       "AudioToolbox.framework",
145       "AudioUnit.framework",
146       "CoreAudio.framework",
147     ]
148   }
150   if (is_win) {
151     sources += [
152       "win/audio_device_listener_win.cc",
153       "win/audio_device_listener_win.h",
154       "win/audio_low_latency_input_win.cc",
155       "win/audio_low_latency_input_win.h",
156       "win/audio_low_latency_output_win.cc",
157       "win/audio_low_latency_output_win.h",
158       "win/audio_manager_win.cc",
159       "win/audio_manager_win.h",
160       "win/avrt_wrapper_win.cc",
161       "win/avrt_wrapper_win.h",
162       "win/core_audio_util_win.cc",
163       "win/core_audio_util_win.h",
164       "win/device_enumeration_win.cc",
165       "win/device_enumeration_win.h",
166       "win/wavein_input_win.cc",
167       "win/wavein_input_win.h",
168       "win/waveout_output_win.cc",
169       "win/waveout_output_win.h",
170     ]
171   }
173   if (is_android) {
174     sources += [
175       "android/audio_manager_android.cc",
176       "android/audio_manager_android.h",
177       "android/audio_record_input.cc",
178       "android/audio_record_input.h",
179       "android/opensles_input.cc",
180       "android/opensles_input.h",
181       "android/opensles_output.cc",
182       "android/opensles_output.h",
183       "android/opensles_wrapper.cc",
184     ]
185     deps += [ "//media/base/android:media_jni_headers" ]
186   }
188   if (is_openbsd) {
189     sources += [
190       "openbsd/audio_manager_openbsd.cc",
191       "openbsd/audio_manager_openbsd.h",
192     ]
193   }
195   if (is_linux) {
196     sources += [ "linux/audio_manager_linux.cc" ]
197   }
199   if (use_alsa) {
200     libs += [ "asound" ]
201     sources += [
202       "alsa/alsa_input.cc",
203       "alsa/alsa_input.h",
204       "alsa/alsa_output.cc",
205       "alsa/alsa_output.h",
206       "alsa/alsa_util.cc",
207       "alsa/alsa_util.h",
208       "alsa/alsa_wrapper.cc",
209       "alsa/alsa_wrapper.h",
210       "alsa/audio_manager_alsa.cc",
211       "alsa/audio_manager_alsa.h",
212     ]
213   }
215   if (use_cras) {
216     sources += [
217       "cras/audio_manager_cras.cc",
218       "cras/audio_manager_cras.h",
219       "cras/cras_input.cc",
220       "cras/cras_input.h",
221       "cras/cras_unified.cc",
222       "cras/cras_unified.h",
223     ]
225     pkg_config("libcras") {
226       packages = [ "libcras" ]
227     }
228     configs += [ ":libcras" ]
229     deps += [ "//chromeos:chromeos" ]
230   }
232   if (use_pulseaudio) {
233     sources += [
234       "pulse/audio_manager_pulse.cc",
235       "pulse/audio_manager_pulse.h",
236       "pulse/pulse_input.cc",
237       "pulse/pulse_input.h",
238       "pulse/pulse_output.cc",
239       "pulse/pulse_output.h",
240       "pulse/pulse_util.cc",
241       "pulse/pulse_util.h",
242     ]
244     if (link_pulseaudio) {
245       pkg_config("libpulse") {
246         packages = [ "libpulse" ]
247       }
248       configs += [ ":libpulse" ]
249     } else {
250       # TODO(ajwong): Technically, this dl should go in the action.
251       libs += [ "dl" ]
252       deps += [ ":pulse_generate_stubs" ]
253       sources += get_target_outputs(":pulse_generate_stubs")
254     }
255   }
257   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
260 source_set("test_support") {
261   testonly = true
262   sources = [
263     "audio_unittest_util.cc",
264     "audio_unittest_util.h",
265     "mock_audio_manager.cc",
266     "mock_audio_manager.h",
267     "mock_audio_source_callback.cc",
268     "mock_audio_source_callback.h",
269     "test_audio_input_controller_factory.cc",
270     "test_audio_input_controller_factory.h",
271   ]
272   configs += [ ":platform_config" ]
273   deps = [
274     "//testing/gmock",
275   ]
276   configs += [ "//media:media_config" ]
279 source_set("unittests") {
280   testonly = true
281   sources = [
282     "audio_input_controller_unittest.cc",
283     "audio_input_unittest.cc",
284     "audio_manager_factory_unittest.cc",
285     "audio_manager_unittest.cc",
286     "audio_output_controller_unittest.cc",
287     "audio_output_device_unittest.cc",
288     "audio_output_proxy_unittest.cc",
289     "audio_parameters_unittest.cc",
290     "audio_power_monitor_unittest.cc",
291     "fake_audio_worker_unittest.cc",
292     "simple_sources_unittest.cc",
293     "virtual_audio_input_stream_unittest.cc",
294     "virtual_audio_output_stream_unittest.cc",
295   ]
296   deps = [
297     ":test_support",
298     "//media/base:test_support",
299     "//testing/gmock",
300     "//testing/gtest",
301     "//url",
302   ]
304   configs += [
305     ":platform_config",
306     "//build/config/compiler:no_size_t_to_int_warning",
307     "//media:media_config",
308   ]
310   if (is_android) {
311     sources += [ "android/audio_android_unittest.cc" ]
312     deps += [ "//ui/gl" ]
313   } else {
314     sources += [ "audio_input_volume_unittest.cc" ]
315   }
317   if (is_mac) {
318     sources += [
319       "mac/audio_auhal_mac_unittest.cc",
320       "mac/audio_device_listener_mac_unittest.cc",
321       "mac/audio_low_latency_input_mac_unittest.cc",
322     ]
323   }
325   if (is_chromeos) {
326     sources += [
327       "sounds/audio_stream_handler_unittest.cc",
328       "sounds/sounds_manager_unittest.cc",
329       "sounds/test_data.cc",
330       "sounds/test_data.h",
331       "sounds/wav_audio_handler_unittest.cc",
332     ]
334     if (use_cras) {
335       sources += [
336         "cras/cras_input_unittest.cc",
337         "cras/cras_unified_unittest.cc",
338       ]
339     }
340   }
342   if (is_win) {
343     sources += [
344       "win/audio_device_listener_win_unittest.cc",
345       "win/audio_low_latency_input_win_unittest.cc",
346       "win/audio_low_latency_output_win_unittest.cc",
347       "win/audio_output_win_unittest.cc",
348       "win/core_audio_util_win_unittest.cc",
349     ]
350   }
352   if (use_alsa) {
353     sources += [
354       "alsa/alsa_output_unittest.cc",
355       "audio_low_latency_input_output_unittest.cc",
356     ]
357   }