blob: d5544812919c82595020ddfcc4c77f22be3057a6 [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
Mikhail Naganov10548292016-10-31 10:39:47 -070019#include <android/hardware/audio/2.0/IDevicesFactory.h>
20#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
Mikhail Naganovce8d65b2018-01-22 13:25:09 -080021#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
Mikhail Naganov5697a9b2017-12-28 13:29:59 -080022#include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
Haynes Mathew Georgea57f41d2018-02-21 14:45:20 -080023#include <binder/ProcessState.h>
Mikhail Naganov5697a9b2017-12-28 13:29:59 -080024#include <hidl/HidlTransportSupport.h>
25#include <hidl/LegacySupport.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;
Mikhail Naganovce8d65b2018-01-22 13:25:09 -080033using V2_0_ISoundTriggerHw = android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
34using V2_1_ISoundTriggerHw = android::hardware::soundtrigger::V2_1::ISoundTriggerHw;
Mikhail Naganov10548292016-10-31 10:39:47 -070035using android::hardware::registerPassthroughServiceImplementation;
Eric Laurent27ef4d82016-10-14 15:46:06 -070036
Mikhail Naganov3c256462017-02-08 16:34:22 -080037using android::OK;
38
Eric Laurent27ef4d82016-10-14 15:46:06 -070039int main(int /* argc */, char* /* argv */ []) {
Haynes Mathew Georgea57f41d2018-02-21 14:45:20 -080040 android::ProcessState::initWithDriver("/dev/vndbinder");
41 // start a threadpool for vndbinder interactions
42 android::ProcessState::self()->startThreadPool();
Martijn Coenen02822372016-12-29 14:03:41 +010043 configureRpcThreadpool(16, true /*callerWillJoin*/);
Mikhail Naganov3c256462017-02-08 16:34:22 -080044 android::status_t status;
Yifan Hong55f72472017-02-16 15:03:53 -080045 status = registerPassthroughServiceImplementation<IDevicesFactory>();
Mikhail Naganov3c256462017-02-08 16:34:22 -080046 LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status);
Chris Phoenix549ca2b2017-01-24 13:45:10 -080047 status = registerPassthroughServiceImplementation<IEffectsFactory>();
Mikhail Naganov3c256462017-02-08 16:34:22 -080048 LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status);
Tomasz Wasilczykf4bae952017-08-07 17:05:14 -070049 // Soundtrigger might be not present.
Mikhail Naganovce8d65b2018-01-22 13:25:09 -080050 status = registerPassthroughServiceImplementation<V2_1_ISoundTriggerHw>();
51 ALOGW_IF(status != OK, "Registering soundtrigger V2.1 service was unsuccessful: %d", status);
52 status = registerPassthroughServiceImplementation<V2_0_ISoundTriggerHw>();
53 ALOGW_IF(status != OK, "Registering soundtrigger V2.0 service was unsuccessful: %d", status);
Martijn Coenen02822372016-12-29 14:03:41 +010054 joinRpcThreadpool();
Mikhail Naganov3c256462017-02-08 16:34:22 -080055 return status;
Eric Laurent27ef4d82016-10-14 15:46:06 -070056}