Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "legacy_audio_policy_hal" |
| 18 | //#define LOG_NDEBUG 0 |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | #include <hardware/hardware.h> |
Dima Zavin | 4a0748b | 2011-05-11 14:16:14 -0700 | [diff] [blame] | 23 | #include <system/audio.h> |
Dima Zavin | d17f66f | 2011-06-13 18:18:55 -0700 | [diff] [blame] | 24 | #include <system/audio_policy.h> |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 25 | #include <hardware/audio_policy.h> |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 26 | |
| 27 | #include <hardware_legacy/AudioPolicyInterface.h> |
| 28 | #include <hardware_legacy/AudioSystemLegacy.h> |
| 29 | |
| 30 | #include "AudioPolicyCompatClient.h" |
| 31 | |
| 32 | namespace android_audio_legacy { |
| 33 | |
| 34 | extern "C" { |
| 35 | |
| 36 | struct legacy_ap_module { |
| 37 | struct audio_policy_module module; |
| 38 | }; |
| 39 | |
| 40 | struct legacy_ap_device { |
| 41 | struct audio_policy_device device; |
| 42 | }; |
| 43 | |
| 44 | struct legacy_audio_policy { |
| 45 | struct audio_policy policy; |
| 46 | |
| 47 | void *service; |
| 48 | struct audio_policy_service_ops *aps_ops; |
| 49 | AudioPolicyCompatClient *service_client; |
| 50 | AudioPolicyInterface *apm; |
| 51 | }; |
| 52 | |
| 53 | static inline struct legacy_audio_policy * to_lap(struct audio_policy *pol) |
| 54 | { |
| 55 | return reinterpret_cast<struct legacy_audio_policy *>(pol); |
| 56 | } |
| 57 | |
| 58 | static inline const struct legacy_audio_policy * to_clap(const struct audio_policy *pol) |
| 59 | { |
| 60 | return reinterpret_cast<const struct legacy_audio_policy *>(pol); |
| 61 | } |
| 62 | |
| 63 | |
| 64 | static int ap_set_device_connection_state(struct audio_policy *pol, |
| 65 | audio_devices_t device, |
| 66 | audio_policy_dev_state_t state, |
| 67 | const char *device_address) |
| 68 | { |
| 69 | struct legacy_audio_policy *lap = to_lap(pol); |
| 70 | return lap->apm->setDeviceConnectionState( |
| 71 | (AudioSystem::audio_devices)device, |
| 72 | (AudioSystem::device_connection_state)state, |
| 73 | device_address); |
| 74 | } |
| 75 | |
| 76 | static audio_policy_dev_state_t ap_get_device_connection_state( |
| 77 | const struct audio_policy *pol, |
| 78 | audio_devices_t device, |
| 79 | const char *device_address) |
| 80 | { |
| 81 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 82 | return (audio_policy_dev_state_t)lap->apm->getDeviceConnectionState( |
| 83 | (AudioSystem::audio_devices)device, |
| 84 | device_address); |
| 85 | } |
| 86 | |
Glenn Kasten | 5c1ebdc | 2012-01-09 10:41:59 -0800 | [diff] [blame] | 87 | static void ap_set_phone_state(struct audio_policy *pol, audio_mode_t state) |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 88 | { |
| 89 | struct legacy_audio_policy *lap = to_lap(pol); |
Glenn Kasten | 5c1ebdc | 2012-01-09 10:41:59 -0800 | [diff] [blame] | 90 | // as this is the legacy API, don't change it to use audio_mode_t instead of int |
| 91 | lap->apm->setPhoneState((int) state); |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | /* indicate a change in ringer mode */ |
| 95 | static void ap_set_ringer_mode(struct audio_policy *pol, uint32_t mode, |
| 96 | uint32_t mask) |
| 97 | { |
Glenn Kasten | ca0657a | 2012-01-18 15:24:50 -0800 | [diff] [blame] | 98 | // deprecated, never called |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /* force using a specific device category for the specified usage */ |
| 102 | static void ap_set_force_use(struct audio_policy *pol, |
| 103 | audio_policy_force_use_t usage, |
| 104 | audio_policy_forced_cfg_t config) |
| 105 | { |
| 106 | struct legacy_audio_policy *lap = to_lap(pol); |
| 107 | lap->apm->setForceUse((AudioSystem::force_use)usage, |
| 108 | (AudioSystem::forced_config)config); |
| 109 | } |
| 110 | |
| 111 | /* retreive current device category forced for a given usage */ |
| 112 | static audio_policy_forced_cfg_t ap_get_force_use( |
| 113 | const struct audio_policy *pol, |
| 114 | audio_policy_force_use_t usage) |
| 115 | { |
| 116 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 117 | return (audio_policy_forced_cfg_t)lap->apm->getForceUse( |
| 118 | (AudioSystem::force_use)usage); |
| 119 | } |
| 120 | |
| 121 | /* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE |
| 122 | * can still be muted. */ |
| 123 | static void ap_set_can_mute_enforced_audible(struct audio_policy *pol, |
| 124 | bool can_mute) |
| 125 | { |
| 126 | struct legacy_audio_policy *lap = to_lap(pol); |
| 127 | lap->apm->setSystemProperty("ro.camera.sound.forced", can_mute ? "0" : "1"); |
| 128 | } |
| 129 | |
| 130 | static int ap_init_check(const struct audio_policy *pol) |
| 131 | { |
| 132 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 133 | return lap->apm->initCheck(); |
| 134 | } |
| 135 | |
| 136 | static audio_io_handle_t ap_get_output(struct audio_policy *pol, |
| 137 | audio_stream_type_t stream, |
| 138 | uint32_t sampling_rate, |
Glenn Kasten | 53e2cfa | 2012-01-12 15:01:42 -0800 | [diff] [blame] | 139 | audio_format_t format, |
Glenn Kasten | 551b6a3 | 2012-06-19 12:29:39 -0700 | [diff] [blame] | 140 | audio_channel_mask_t channelMask, |
Eric Laurent | 0977cf5 | 2012-04-18 09:28:52 -0700 | [diff] [blame] | 141 | audio_output_flags_t flags) |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 142 | { |
| 143 | struct legacy_audio_policy *lap = to_lap(pol); |
| 144 | |
Steve Block | 6a70518 | 2011-10-20 11:56:19 +0100 | [diff] [blame] | 145 | ALOGV("%s: tid %d", __func__, gettid()); |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 146 | return lap->apm->getOutput((AudioSystem::stream_type)stream, |
Glenn Kasten | 551b6a3 | 2012-06-19 12:29:39 -0700 | [diff] [blame] | 147 | sampling_rate, (int) format, channelMask, |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 148 | (AudioSystem::output_flags)flags); |
| 149 | } |
| 150 | |
| 151 | static int ap_start_output(struct audio_policy *pol, audio_io_handle_t output, |
| 152 | audio_stream_type_t stream, int session) |
| 153 | { |
| 154 | struct legacy_audio_policy *lap = to_lap(pol); |
| 155 | return lap->apm->startOutput(output, (AudioSystem::stream_type)stream, |
| 156 | session); |
| 157 | } |
| 158 | |
| 159 | static int ap_stop_output(struct audio_policy *pol, audio_io_handle_t output, |
| 160 | audio_stream_type_t stream, int session) |
| 161 | { |
| 162 | struct legacy_audio_policy *lap = to_lap(pol); |
| 163 | return lap->apm->stopOutput(output, (AudioSystem::stream_type)stream, |
| 164 | session); |
| 165 | } |
| 166 | |
| 167 | static void ap_release_output(struct audio_policy *pol, |
| 168 | audio_io_handle_t output) |
| 169 | { |
| 170 | struct legacy_audio_policy *lap = to_lap(pol); |
| 171 | lap->apm->releaseOutput(output); |
| 172 | } |
| 173 | |
Glenn Kasten | f3b5a07 | 2012-01-26 16:46:31 -0800 | [diff] [blame] | 174 | static audio_io_handle_t ap_get_input(struct audio_policy *pol, audio_source_t inputSource, |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 175 | uint32_t sampling_rate, |
Glenn Kasten | 53e2cfa | 2012-01-12 15:01:42 -0800 | [diff] [blame] | 176 | audio_format_t format, |
Glenn Kasten | 551b6a3 | 2012-06-19 12:29:39 -0700 | [diff] [blame] | 177 | audio_channel_mask_t channelMask, |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 178 | audio_in_acoustics_t acoustics) |
| 179 | { |
| 180 | struct legacy_audio_policy *lap = to_lap(pol); |
Glenn Kasten | 551b6a3 | 2012-06-19 12:29:39 -0700 | [diff] [blame] | 181 | return lap->apm->getInput((int) inputSource, sampling_rate, (int) format, channelMask, |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 182 | (AudioSystem::audio_in_acoustics)acoustics); |
| 183 | } |
| 184 | |
| 185 | static int ap_start_input(struct audio_policy *pol, audio_io_handle_t input) |
| 186 | { |
| 187 | struct legacy_audio_policy *lap = to_lap(pol); |
| 188 | return lap->apm->startInput(input); |
| 189 | } |
| 190 | |
| 191 | static int ap_stop_input(struct audio_policy *pol, audio_io_handle_t input) |
| 192 | { |
| 193 | struct legacy_audio_policy *lap = to_lap(pol); |
| 194 | return lap->apm->stopInput(input); |
| 195 | } |
| 196 | |
| 197 | static void ap_release_input(struct audio_policy *pol, audio_io_handle_t input) |
| 198 | { |
| 199 | struct legacy_audio_policy *lap = to_lap(pol); |
| 200 | lap->apm->releaseInput(input); |
| 201 | } |
| 202 | |
| 203 | static void ap_init_stream_volume(struct audio_policy *pol, |
| 204 | audio_stream_type_t stream, int index_min, |
| 205 | int index_max) |
| 206 | { |
| 207 | struct legacy_audio_policy *lap = to_lap(pol); |
| 208 | lap->apm->initStreamVolume((AudioSystem::stream_type)stream, index_min, |
| 209 | index_max); |
| 210 | } |
| 211 | |
| 212 | static int ap_set_stream_volume_index(struct audio_policy *pol, |
| 213 | audio_stream_type_t stream, |
| 214 | int index) |
| 215 | { |
| 216 | struct legacy_audio_policy *lap = to_lap(pol); |
| 217 | return lap->apm->setStreamVolumeIndex((AudioSystem::stream_type)stream, |
Eric Laurent | c6f331b | 2011-12-14 18:18:36 -0800 | [diff] [blame] | 218 | index, |
| 219 | AUDIO_DEVICE_OUT_DEFAULT); |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | static int ap_get_stream_volume_index(const struct audio_policy *pol, |
| 223 | audio_stream_type_t stream, |
| 224 | int *index) |
| 225 | { |
| 226 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 227 | return lap->apm->getStreamVolumeIndex((AudioSystem::stream_type)stream, |
Eric Laurent | c6f331b | 2011-12-14 18:18:36 -0800 | [diff] [blame] | 228 | index, |
| 229 | AUDIO_DEVICE_OUT_DEFAULT); |
| 230 | } |
| 231 | |
| 232 | static int ap_set_stream_volume_index_for_device(struct audio_policy *pol, |
| 233 | audio_stream_type_t stream, |
| 234 | int index, |
| 235 | audio_devices_t device) |
| 236 | { |
| 237 | struct legacy_audio_policy *lap = to_lap(pol); |
| 238 | return lap->apm->setStreamVolumeIndex((AudioSystem::stream_type)stream, |
| 239 | index, |
| 240 | device); |
| 241 | } |
| 242 | |
| 243 | static int ap_get_stream_volume_index_for_device(const struct audio_policy *pol, |
| 244 | audio_stream_type_t stream, |
| 245 | int *index, |
| 246 | audio_devices_t device) |
| 247 | { |
| 248 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 249 | return lap->apm->getStreamVolumeIndex((AudioSystem::stream_type)stream, |
| 250 | index, |
| 251 | device); |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | static uint32_t ap_get_strategy_for_stream(const struct audio_policy *pol, |
| 255 | audio_stream_type_t stream) |
| 256 | { |
| 257 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 258 | return lap->apm->getStrategyForStream((AudioSystem::stream_type)stream); |
| 259 | } |
| 260 | |
Eric Laurent | f9a4e2e | 2012-03-08 13:39:13 -0800 | [diff] [blame] | 261 | static audio_devices_t ap_get_devices_for_stream(const struct audio_policy *pol, |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 262 | audio_stream_type_t stream) |
| 263 | { |
| 264 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 265 | return lap->apm->getDevicesForStream((AudioSystem::stream_type)stream); |
| 266 | } |
| 267 | |
| 268 | static audio_io_handle_t ap_get_output_for_effect(struct audio_policy *pol, |
Glenn Kasten | c94dccc | 2012-07-24 07:51:26 -0700 | [diff] [blame] | 269 | const struct effect_descriptor_s *desc) |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 270 | { |
| 271 | struct legacy_audio_policy *lap = to_lap(pol); |
| 272 | return lap->apm->getOutputForEffect(desc); |
| 273 | } |
| 274 | |
| 275 | static int ap_register_effect(struct audio_policy *pol, |
Glenn Kasten | c94dccc | 2012-07-24 07:51:26 -0700 | [diff] [blame] | 276 | const struct effect_descriptor_s *desc, |
Eric Laurent | 1c65a49 | 2011-06-17 21:51:11 -0700 | [diff] [blame] | 277 | audio_io_handle_t io, |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 278 | uint32_t strategy, |
| 279 | int session, |
| 280 | int id) |
| 281 | { |
| 282 | struct legacy_audio_policy *lap = to_lap(pol); |
Eric Laurent | 1c65a49 | 2011-06-17 21:51:11 -0700 | [diff] [blame] | 283 | return lap->apm->registerEffect(desc, io, strategy, session, id); |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | static int ap_unregister_effect(struct audio_policy *pol, int id) |
| 287 | { |
| 288 | struct legacy_audio_policy *lap = to_lap(pol); |
| 289 | return lap->apm->unregisterEffect(id); |
| 290 | } |
| 291 | |
Eric Laurent | 582a157 | 2011-08-10 20:16:23 -0700 | [diff] [blame] | 292 | static int ap_set_effect_enabled(struct audio_policy *pol, int id, bool enabled) |
| 293 | { |
| 294 | struct legacy_audio_policy *lap = to_lap(pol); |
| 295 | return lap->apm->setEffectEnabled(id, enabled); |
| 296 | } |
| 297 | |
Glenn Kasten | d97809b | 2012-01-12 11:12:59 -0800 | [diff] [blame] | 298 | static bool ap_is_stream_active(const struct audio_policy *pol, audio_stream_type_t stream, |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 299 | uint32_t in_past_ms) |
| 300 | { |
| 301 | const struct legacy_audio_policy *lap = to_clap(pol); |
Glenn Kasten | d97809b | 2012-01-12 11:12:59 -0800 | [diff] [blame] | 302 | return lap->apm->isStreamActive((int) stream, in_past_ms); |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Jean-Michel Trivi | abc55c6 | 2012-10-10 12:39:04 -0700 | [diff] [blame] | 305 | static bool ap_is_source_active(const struct audio_policy *pol, audio_source_t source) |
| 306 | { |
| 307 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 308 | return lap->apm->isSourceActive(source); |
| 309 | } |
| 310 | |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 311 | static int ap_dump(const struct audio_policy *pol, int fd) |
| 312 | { |
| 313 | const struct legacy_audio_policy *lap = to_clap(pol); |
| 314 | return lap->apm->dump(fd); |
| 315 | } |
| 316 | |
| 317 | static int create_legacy_ap(const struct audio_policy_device *device, |
| 318 | struct audio_policy_service_ops *aps_ops, |
| 319 | void *service, |
| 320 | struct audio_policy **ap) |
| 321 | { |
| 322 | struct legacy_audio_policy *lap; |
| 323 | int ret; |
| 324 | |
| 325 | if (!service || !aps_ops) |
| 326 | return -EINVAL; |
| 327 | |
| 328 | lap = (struct legacy_audio_policy *)calloc(1, sizeof(*lap)); |
| 329 | if (!lap) |
| 330 | return -ENOMEM; |
| 331 | |
| 332 | lap->policy.set_device_connection_state = ap_set_device_connection_state; |
| 333 | lap->policy.get_device_connection_state = ap_get_device_connection_state; |
| 334 | lap->policy.set_phone_state = ap_set_phone_state; |
| 335 | lap->policy.set_ringer_mode = ap_set_ringer_mode; |
| 336 | lap->policy.set_force_use = ap_set_force_use; |
| 337 | lap->policy.get_force_use = ap_get_force_use; |
| 338 | lap->policy.set_can_mute_enforced_audible = |
| 339 | ap_set_can_mute_enforced_audible; |
| 340 | lap->policy.init_check = ap_init_check; |
| 341 | lap->policy.get_output = ap_get_output; |
| 342 | lap->policy.start_output = ap_start_output; |
| 343 | lap->policy.stop_output = ap_stop_output; |
| 344 | lap->policy.release_output = ap_release_output; |
| 345 | lap->policy.get_input = ap_get_input; |
| 346 | lap->policy.start_input = ap_start_input; |
| 347 | lap->policy.stop_input = ap_stop_input; |
| 348 | lap->policy.release_input = ap_release_input; |
| 349 | lap->policy.init_stream_volume = ap_init_stream_volume; |
| 350 | lap->policy.set_stream_volume_index = ap_set_stream_volume_index; |
| 351 | lap->policy.get_stream_volume_index = ap_get_stream_volume_index; |
Eric Laurent | c6f331b | 2011-12-14 18:18:36 -0800 | [diff] [blame] | 352 | lap->policy.set_stream_volume_index_for_device = ap_set_stream_volume_index_for_device; |
| 353 | lap->policy.get_stream_volume_index_for_device = ap_get_stream_volume_index_for_device; |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 354 | lap->policy.get_strategy_for_stream = ap_get_strategy_for_stream; |
| 355 | lap->policy.get_devices_for_stream = ap_get_devices_for_stream; |
| 356 | lap->policy.get_output_for_effect = ap_get_output_for_effect; |
| 357 | lap->policy.register_effect = ap_register_effect; |
| 358 | lap->policy.unregister_effect = ap_unregister_effect; |
Eric Laurent | 582a157 | 2011-08-10 20:16:23 -0700 | [diff] [blame] | 359 | lap->policy.set_effect_enabled = ap_set_effect_enabled; |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 360 | lap->policy.is_stream_active = ap_is_stream_active; |
Jean-Michel Trivi | abc55c6 | 2012-10-10 12:39:04 -0700 | [diff] [blame] | 361 | lap->policy.is_source_active = ap_is_source_active; |
Dima Zavin | e81531e | 2011-04-19 16:53:42 -0700 | [diff] [blame] | 362 | lap->policy.dump = ap_dump; |
| 363 | |
| 364 | lap->service = service; |
| 365 | lap->aps_ops = aps_ops; |
| 366 | lap->service_client = |
| 367 | new AudioPolicyCompatClient(aps_ops, service); |
| 368 | if (!lap->service_client) { |
| 369 | ret = -ENOMEM; |
| 370 | goto err_new_compat_client; |
| 371 | } |
| 372 | |
| 373 | lap->apm = createAudioPolicyManager(lap->service_client); |
| 374 | if (!lap->apm) { |
| 375 | ret = -ENOMEM; |
| 376 | goto err_create_apm; |
| 377 | } |
| 378 | |
| 379 | *ap = &lap->policy; |
| 380 | return 0; |
| 381 | |
| 382 | err_create_apm: |
| 383 | delete lap->service_client; |
| 384 | err_new_compat_client: |
| 385 | free(lap); |
| 386 | *ap = NULL; |
| 387 | return ret; |
| 388 | } |
| 389 | |
| 390 | static int destroy_legacy_ap(const struct audio_policy_device *ap_dev, |
| 391 | struct audio_policy *ap) |
| 392 | { |
| 393 | struct legacy_audio_policy *lap = to_lap(ap); |
| 394 | |
| 395 | if (!lap) |
| 396 | return 0; |
| 397 | |
| 398 | if (lap->apm) |
| 399 | destroyAudioPolicyManager(lap->apm); |
| 400 | if (lap->service_client) |
| 401 | delete lap->service_client; |
| 402 | free(lap); |
| 403 | return 0; |
| 404 | } |
| 405 | |
| 406 | static int legacy_ap_dev_close(hw_device_t* device) |
| 407 | { |
| 408 | if (device) |
| 409 | free(device); |
| 410 | return 0; |
| 411 | } |
| 412 | |
| 413 | static int legacy_ap_dev_open(const hw_module_t* module, const char* name, |
| 414 | hw_device_t** device) |
| 415 | { |
| 416 | struct legacy_ap_device *dev; |
| 417 | |
| 418 | if (strcmp(name, AUDIO_POLICY_INTERFACE) != 0) |
| 419 | return -EINVAL; |
| 420 | |
| 421 | dev = (struct legacy_ap_device *)calloc(1, sizeof(*dev)); |
| 422 | if (!dev) |
| 423 | return -ENOMEM; |
| 424 | |
| 425 | dev->device.common.tag = HARDWARE_DEVICE_TAG; |
| 426 | dev->device.common.version = 0; |
| 427 | dev->device.common.module = const_cast<hw_module_t*>(module); |
| 428 | dev->device.common.close = legacy_ap_dev_close; |
| 429 | dev->device.create_audio_policy = create_legacy_ap; |
| 430 | dev->device.destroy_audio_policy = destroy_legacy_ap; |
| 431 | |
| 432 | *device = &dev->device.common; |
| 433 | |
| 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | static struct hw_module_methods_t legacy_ap_module_methods = { |
| 438 | open: legacy_ap_dev_open |
| 439 | }; |
| 440 | |
| 441 | struct legacy_ap_module HAL_MODULE_INFO_SYM = { |
| 442 | module: { |
| 443 | common: { |
| 444 | tag: HARDWARE_MODULE_TAG, |
| 445 | version_major: 1, |
| 446 | version_minor: 0, |
| 447 | id: AUDIO_POLICY_HARDWARE_MODULE_ID, |
| 448 | name: "LEGACY Audio Policy HAL", |
| 449 | author: "The Android Open Source Project", |
| 450 | methods: &legacy_ap_module_methods, |
| 451 | dso : NULL, |
| 452 | reserved : {0}, |
| 453 | }, |
| 454 | }, |
| 455 | }; |
| 456 | |
| 457 | }; // extern "C" |
| 458 | |
| 459 | }; // namespace android_audio_legacy |