• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #define LOG_TAG "audiohalservice"
18 
19 #include <android/hardware/audio/2.0/IDevicesFactory.h>
20 #include <android/hardware/audio/4.0/IDevicesFactory.h>
21 #include <android/hardware/audio/5.0/IDevicesFactory.h>
22 #include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
23 #include <android/hardware/audio/effect/4.0/IEffectsFactory.h>
24 #include <android/hardware/audio/effect/5.0/IEffectsFactory.h>
25 #include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h>
26 #include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.h>
27 #include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
28 #include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
29 #include <android/hardware/soundtrigger/2.2/ISoundTriggerHw.h>
30 #include <binder/ProcessState.h>
31 #include <cutils/properties.h>
32 #include <hidl/HidlTransportSupport.h>
33 #include <hidl/LegacySupport.h>
34 #include <hwbinder/ProcessState.h>
35 
36 using namespace android::hardware;
37 using android::OK;
38 
main(int,char * [])39 int main(int /* argc */, char* /* argv */ []) {
40     ::android::ProcessState::initWithDriver("/dev/vndbinder");
41     // start a threadpool for vndbinder interactions
42     ::android::ProcessState::self()->startThreadPool();
43 
44     const int32_t defaultValue = -1;
45     int32_t value =
46         property_get_int32("persist.vendor.audio.service.hwbinder.size_kbyte", defaultValue);
47     if (value != defaultValue) {
48         ALOGD("Configuring hwbinder with mmap size %d KBytes", value);
49         ProcessState::initWithMmapSize(static_cast<size_t>(value) * 1024);
50     }
51     configureRpcThreadpool(16, true /*callerWillJoin*/);
52 
53     bool fail = registerPassthroughServiceImplementation<audio::V5_0::IDevicesFactory>() != OK &&
54                 registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK &&
55                 registerPassthroughServiceImplementation<audio::V2_0::IDevicesFactory>() != OK;
56     LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2, 4 nor 5");
57 
58     fail = registerPassthroughServiceImplementation<audio::effect::V5_0::IEffectsFactory>() != OK &&
59            registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK &&
60            registerPassthroughServiceImplementation<audio::effect::V2_0::IEffectsFactory>() != OK,
61     LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2, 4 nor 5");
62 
63     fail = registerPassthroughServiceImplementation<soundtrigger::V2_2::ISoundTriggerHw>() != OK &&
64            registerPassthroughServiceImplementation<soundtrigger::V2_1::ISoundTriggerHw>() != OK &&
65            registerPassthroughServiceImplementation<soundtrigger::V2_0::ISoundTriggerHw>() != OK,
66     ALOGW_IF(fail, "Could not register soundtrigger API 2.0, 2.1 nor 2.2");
67 
68     fail = registerPassthroughServiceImplementation<
69                    bluetooth::audio::V2_0::IBluetoothAudioProvidersFactory>() != OK;
70     ALOGW_IF(fail, "Could not register Bluetooth Audio API 2.0");
71 
72     // remove the old HIDL when Bluetooth Audio Hal V2 has offloading supported
73     fail =
74         registerPassthroughServiceImplementation<bluetooth::a2dp::V1_0::IBluetoothAudioOffload>() !=
75         OK;
76     ALOGW_IF(fail, "Could not register Bluetooth audio offload 1.0");
77 
78     joinRpcThreadpool();
79 }
80