blob: 7f28d7df849eb79d81ce36ee8a555842815fd36d [file] [log] [blame]
Eric Laurent27ef4d82016-10-14 15:46:06 -07001/*
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 Naganov10548292016-10-31 10:39:47 -070017#define LOG_TAG "audiohalservice"
Eric Laurent27ef4d82016-10-14 15:46:06 -070018
Martijn Coenen02822372016-12-29 14:03:41 +010019#include <hidl/HidlTransportSupport.h>
Mikhail Naganov10548292016-10-31 10:39:47 -070020#include <hidl/LegacySupport.h>
21#include <android/hardware/audio/2.0/IDevicesFactory.h>
22#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
Eric Laurent27ef4d82016-10-14 15:46:06 -070023#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
Eric Laurenta1745882016-11-21 10:41:22 -080024#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080025#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
Eric Laurent27ef4d82016-10-14 15:46:06 -070026
Martijn Coenen02822372016-12-29 14:03:41 +010027using android::hardware::configureRpcThreadpool;
28using android::hardware::joinRpcThreadpool;
29using android::hardware::registerPassthroughServiceImplementation;
30
Mikhail Naganov10548292016-10-31 10:39:47 -070031using android::hardware::audio::effect::V2_0::IEffectsFactory;
32using android::hardware::audio::V2_0::IDevicesFactory;
Eric Laurent27ef4d82016-10-14 15:46:06 -070033using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
Mikhail Naganov10548292016-10-31 10:39:47 -070034using android::hardware::registerPassthroughServiceImplementation;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080035namespace broadcastradio = android::hardware::broadcastradio;
36
37#ifdef TARGET_USES_BCRADIO_FUTURE_FEATURES
38static const bool useBroadcastRadioFutureFeatures = true;
39#else
40static const bool useBroadcastRadioFutureFeatures = false;
41#endif
Eric Laurent27ef4d82016-10-14 15:46:06 -070042
Mikhail Naganov3c256462017-02-08 16:34:22 -080043using android::OK;
44
Eric Laurent27ef4d82016-10-14 15:46:06 -070045int main(int /* argc */, char* /* argv */ []) {
Martijn Coenen02822372016-12-29 14:03:41 +010046 configureRpcThreadpool(16, true /*callerWillJoin*/);
Mikhail Naganov3c256462017-02-08 16:34:22 -080047 android::status_t status;
Yifan Hong55f72472017-02-16 15:03:53 -080048 status = registerPassthroughServiceImplementation<IDevicesFactory>();
Mikhail Naganov3c256462017-02-08 16:34:22 -080049 LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status);
Chris Phoenix549ca2b2017-01-24 13:45:10 -080050 status = registerPassthroughServiceImplementation<IEffectsFactory>();
Mikhail Naganov3c256462017-02-08 16:34:22 -080051 LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status);
52 // Soundtrigger and FM radio might be not present.
Mikhail Naganov3acaa662017-04-13 11:00:11 -070053 status = registerPassthroughServiceImplementation<ISoundTriggerHw>();
Mikhail Naganov3c256462017-02-08 16:34:22 -080054 ALOGE_IF(status != OK, "Error while registering soundtrigger service: %d", status);
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080055 if (useBroadcastRadioFutureFeatures) {
56 status = registerPassthroughServiceImplementation<
57 broadcastradio::V1_1::IBroadcastRadioFactory>();
58 } else {
59 status = registerPassthroughServiceImplementation<
60 broadcastradio::V1_0::IBroadcastRadioFactory>();
61 }
Mikhail Naganov3c256462017-02-08 16:34:22 -080062 ALOGE_IF(status != OK, "Error while registering fm radio service: %d", status);
Martijn Coenen02822372016-12-29 14:03:41 +010063 joinRpcThreadpool();
Mikhail Naganov3c256462017-02-08 16:34:22 -080064 return status;
Eric Laurent27ef4d82016-10-14 15:46:06 -070065}