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 | |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 19 | #include <hidl/HidlTransportSupport.h> |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 20 | #include <hidl/LegacySupport.h> |
| 21 | #include <android/hardware/audio/2.0/IDevicesFactory.h> |
| 22 | #include <android/hardware/audio/effect/2.0/IEffectsFactory.h> |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 23 | #include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h> |
Eric Laurent | a174588 | 2016-11-21 10:41:22 -0800 | [diff] [blame] | 24 | #include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h> |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 25 | #include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h> |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 26 | |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 27 | using android::hardware::configureRpcThreadpool; |
| 28 | using android::hardware::joinRpcThreadpool; |
| 29 | using android::hardware::registerPassthroughServiceImplementation; |
| 30 | |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 31 | using android::hardware::audio::effect::V2_0::IEffectsFactory; |
| 32 | using android::hardware::audio::V2_0::IDevicesFactory; |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 33 | using android::hardware::soundtrigger::V2_0::ISoundTriggerHw; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 34 | using android::hardware::registerPassthroughServiceImplementation; |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 35 | namespace broadcastradio = android::hardware::broadcastradio; |
| 36 | |
| 37 | #ifdef TARGET_USES_BCRADIO_FUTURE_FEATURES |
| 38 | static const bool useBroadcastRadioFutureFeatures = true; |
| 39 | #else |
| 40 | static const bool useBroadcastRadioFutureFeatures = false; |
| 41 | #endif |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 42 | |
Mikhail Naganov | 3c25646 | 2017-02-08 16:34:22 -0800 | [diff] [blame] | 43 | using android::OK; |
| 44 | |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 45 | int main(int /* argc */, char* /* argv */ []) { |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 46 | configureRpcThreadpool(16, true /*callerWillJoin*/); |
Mikhail Naganov | 3c25646 | 2017-02-08 16:34:22 -0800 | [diff] [blame] | 47 | android::status_t status; |
Yifan Hong | 55f7247 | 2017-02-16 15:03:53 -0800 | [diff] [blame] | 48 | status = registerPassthroughServiceImplementation<IDevicesFactory>(); |
Mikhail Naganov | 3c25646 | 2017-02-08 16:34:22 -0800 | [diff] [blame] | 49 | LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status); |
Chris Phoenix | 549ca2b | 2017-01-24 13:45:10 -0800 | [diff] [blame] | 50 | status = registerPassthroughServiceImplementation<IEffectsFactory>(); |
Mikhail Naganov | 3c25646 | 2017-02-08 16:34:22 -0800 | [diff] [blame] | 51 | LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status); |
| 52 | // Soundtrigger and FM radio might be not present. |
Mikhail Naganov | 3acaa66 | 2017-04-13 11:00:11 -0700 | [diff] [blame] | 53 | status = registerPassthroughServiceImplementation<ISoundTriggerHw>(); |
Mikhail Naganov | 3c25646 | 2017-02-08 16:34:22 -0800 | [diff] [blame] | 54 | ALOGE_IF(status != OK, "Error while registering soundtrigger service: %d", status); |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 55 | if (useBroadcastRadioFutureFeatures) { |
| 56 | status = registerPassthroughServiceImplementation< |
| 57 | broadcastradio::V1_1::IBroadcastRadioFactory>(); |
| 58 | } else { |
| 59 | status = registerPassthroughServiceImplementation< |
| 60 | broadcastradio::V1_0::IBroadcastRadioFactory>(); |
| 61 | } |
Mikhail Naganov | 3c25646 | 2017-02-08 16:34:22 -0800 | [diff] [blame] | 62 | ALOGE_IF(status != OK, "Error while registering fm radio service: %d", status); |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 63 | joinRpcThreadpool(); |
Mikhail Naganov | 3c25646 | 2017-02-08 16:34:22 -0800 | [diff] [blame] | 64 | return status; |
Eric Laurent | 27ef4d8 | 2016-10-14 15:46:06 -0700 | [diff] [blame] | 65 | } |