Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 17 | #define LOG_TAG "audiohalservice" |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 18 | |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 19 | #include <android/hardware/audio/2.0/IDevicesFactory.h> |
Kevin Rocard | 91a73b4 | 2018-03-01 18:56:58 -0800 | [diff] [blame] | 20 | #include <android/hardware/audio/4.0/IDevicesFactory.h> |
Kevin Rocard | 20614ba | 2018-11-10 07:20:17 -0800 | [diff] [blame] | 21 | #include <android/hardware/audio/5.0/IDevicesFactory.h> |
Kevin Rocard | 2a515e1 | 2019-09-30 19:53:00 +0100 | [diff] [blame] | 22 | #include <android/hardware/audio/6.0/IDevicesFactory.h> |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 23 | #include <android/hardware/audio/effect/2.0/IEffectsFactory.h> |
Kevin Rocard | 91a73b4 | 2018-03-01 18:56:58 -0800 | [diff] [blame] | 24 | #include <android/hardware/audio/effect/4.0/IEffectsFactory.h> |
Kevin Rocard | 20614ba | 2018-11-10 07:20:17 -0800 | [diff] [blame] | 25 | #include <android/hardware/audio/effect/5.0/IEffectsFactory.h> |
Kevin Rocard | 2a515e1 | 2019-09-30 19:53:00 +0100 | [diff] [blame] | 26 | #include <android/hardware/audio/effect/6.0/IEffectsFactory.h> |
Aniket Kumar Lata | c5a5203 | 2018-01-31 20:17:30 -0800 | [diff] [blame] | 27 | #include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h> |
Cheney Ni | 4f6882f | 2018-11-27 16:23:27 +0800 | [diff] [blame] | 28 | #include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.h> |
Mikhail Naganov | ce8d65b | 2018-01-22 13:25:09 -0800 | [diff] [blame] | 29 | #include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h> |
Mikhail Naganov | 5697a9b | 2017-12-28 13:29:59 -0800 | [diff] [blame] | 30 | #include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h> |
mike dooley | 2f0da26 | 2018-12-18 19:59:14 +0100 | [diff] [blame] | 31 | #include <android/hardware/soundtrigger/2.2/ISoundTriggerHw.h> |
Haynes Mathew George | a57f41d | 2018-02-21 14:45:20 -0800 | [diff] [blame] | 32 | #include <binder/ProcessState.h> |
Mikhail Naganov | 317a9ed | 2018-09-20 14:25:01 -0700 | [diff] [blame] | 33 | #include <cutils/properties.h> |
Mikhail Naganov | 5697a9b | 2017-12-28 13:29:59 -0800 | [diff] [blame] | 34 | #include <hidl/HidlTransportSupport.h> |
| 35 | #include <hidl/LegacySupport.h> |
Mikhail Naganov | 317a9ed | 2018-09-20 14:25:01 -0700 | [diff] [blame] | 36 | #include <hwbinder/ProcessState.h> |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 37 | |
Kevin Rocard | 91a73b4 | 2018-03-01 18:56:58 -0800 | [diff] [blame] | 38 | using namespace android::hardware; |
Mikhail Naganov | 3c25646 | 2017-02-08 16:34:22 -0800 | [diff] [blame] | 39 | using android::OK; |
| 40 | |
Kevin Rocard | 350ce29 | 2019-06-18 12:40:48 -0700 | [diff] [blame] | 41 | /** Try to register the provided factories in the provided order. |
| 42 | * If any registers successfully, do not register any other and return true. |
| 43 | * If all fail, return false. |
| 44 | */ |
| 45 | template <class... Factories> |
| 46 | bool registerPassthroughServiceImplementations() { |
| 47 | return ((registerPassthroughServiceImplementation<Factories>() != OK) && ...); |
| 48 | } |
| 49 | |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 50 | int main(int /* argc */, char* /* argv */ []) { |
Mikhail Naganov | 317a9ed | 2018-09-20 14:25:01 -0700 | [diff] [blame] | 51 | ::android::ProcessState::initWithDriver("/dev/vndbinder"); |
Haynes Mathew George | a57f41d | 2018-02-21 14:45:20 -0800 | [diff] [blame] | 52 | // start a threadpool for vndbinder interactions |
Mikhail Naganov | 317a9ed | 2018-09-20 14:25:01 -0700 | [diff] [blame] | 53 | ::android::ProcessState::self()->startThreadPool(); |
| 54 | |
| 55 | const int32_t defaultValue = -1; |
| 56 | int32_t value = |
| 57 | property_get_int32("persist.vendor.audio.service.hwbinder.size_kbyte", defaultValue); |
| 58 | if (value != defaultValue) { |
| 59 | ALOGD("Configuring hwbinder with mmap size %d KBytes", value); |
| 60 | ProcessState::initWithMmapSize(static_cast<size_t>(value) * 1024); |
| 61 | } |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 62 | configureRpcThreadpool(16, true /*callerWillJoin*/); |
Kevin Rocard | 91a73b4 | 2018-03-01 18:56:58 -0800 | [diff] [blame] | 63 | |
Kevin Rocard | 55a4518 | 2019-06-18 15:39:17 -0700 | [diff] [blame] | 64 | // Keep versions on a separate line for easier parsing |
| 65 | // clang-format off |
| 66 | LOG_ALWAYS_FATAL_IF((registerPassthroughServiceImplementations< |
Kevin Rocard | 2a515e1 | 2019-09-30 19:53:00 +0100 | [diff] [blame] | 67 | audio::V6_0::IDevicesFactory, |
Kevin Rocard | 55a4518 | 2019-06-18 15:39:17 -0700 | [diff] [blame] | 68 | audio::V5_0::IDevicesFactory, |
| 69 | audio::V4_0::IDevicesFactory, |
| 70 | audio::V2_0::IDevicesFactory>()), |
Kevin Rocard | 350ce29 | 2019-06-18 12:40:48 -0700 | [diff] [blame] | 71 | "Could not register audio core API"); |
Kevin Rocard | 91a73b4 | 2018-03-01 18:56:58 -0800 | [diff] [blame] | 72 | |
Kevin Rocard | 55a4518 | 2019-06-18 15:39:17 -0700 | [diff] [blame] | 73 | LOG_ALWAYS_FATAL_IF((registerPassthroughServiceImplementations< |
Kevin Rocard | 2a515e1 | 2019-09-30 19:53:00 +0100 | [diff] [blame] | 74 | audio::effect::V6_0::IEffectsFactory, |
Kevin Rocard | 55a4518 | 2019-06-18 15:39:17 -0700 | [diff] [blame] | 75 | audio::effect::V5_0::IEffectsFactory, |
| 76 | audio::effect::V4_0::IEffectsFactory, |
| 77 | audio::effect::V2_0::IEffectsFactory>()), |
| 78 | "Could not register audio effect API"); |
| 79 | // clang-format on |
Kevin Rocard | 91a73b4 | 2018-03-01 18:56:58 -0800 | [diff] [blame] | 80 | |
Kevin Rocard | 350ce29 | 2019-06-18 12:40:48 -0700 | [diff] [blame] | 81 | ALOGW_IF((registerPassthroughServiceImplementations<soundtrigger::V2_2::ISoundTriggerHw, |
| 82 | soundtrigger::V2_1::ISoundTriggerHw, |
| 83 | soundtrigger::V2_0::ISoundTriggerHw>()), |
| 84 | "Could not register soundtrigger API"); |
Kevin Rocard | 91a73b4 | 2018-03-01 18:56:58 -0800 | [diff] [blame] | 85 | |
Kevin Rocard | 350ce29 | 2019-06-18 12:40:48 -0700 | [diff] [blame] | 86 | ALOGW_IF(registerPassthroughServiceImplementations< |
| 87 | bluetooth::audio::V2_0::IBluetoothAudioProvidersFactory>(), |
| 88 | "Could not register Bluetooth audio API"); |
Cheney Ni | 4f6882f | 2018-11-27 16:23:27 +0800 | [diff] [blame] | 89 | |
| 90 | // remove the old HIDL when Bluetooth Audio Hal V2 has offloading supported |
Kevin Rocard | 350ce29 | 2019-06-18 12:40:48 -0700 | [diff] [blame] | 91 | ALOGW_IF(registerPassthroughServiceImplementations< |
| 92 | bluetooth::a2dp::V1_0::IBluetoothAudioOffload>(), |
| 93 | "Could not register Bluetooth audio offload API"); |
Aniket Kumar Lata | c5a5203 | 2018-01-31 20:17:30 -0800 | [diff] [blame] | 94 | |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 95 | joinRpcThreadpool(); |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 96 | } |