Home | History | Annotate | Download | only in service
      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/effect/2.0/IEffectsFactory.h>
     22 #include <android/hardware/audio/effect/4.0/IEffectsFactory.h>
     23 #include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h>
     24 #include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
     25 #include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
     26 #include <binder/ProcessState.h>
     27 #include <hidl/HidlTransportSupport.h>
     28 #include <hidl/LegacySupport.h>
     29 
     30 using namespace android::hardware;
     31 using android::OK;
     32 
     33 int main(int /* argc */, char* /* argv */ []) {
     34     android::ProcessState::initWithDriver("/dev/vndbinder");
     35     // start a threadpool for vndbinder interactions
     36     android::ProcessState::self()->startThreadPool();
     37     configureRpcThreadpool(16, true /*callerWillJoin*/);
     38 
     39     bool fail = registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK &&
     40                 registerPassthroughServiceImplementation<audio::V2_0::IDevicesFactory>() != OK;
     41     LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2.0 nor 4.0");
     42 
     43     fail = registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK &&
     44            registerPassthroughServiceImplementation<audio::effect::V2_0::IEffectsFactory>() != OK,
     45     LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2.0 nor 4.0");
     46 
     47     fail = registerPassthroughServiceImplementation<soundtrigger::V2_1::ISoundTriggerHw>() != OK &&
     48            registerPassthroughServiceImplementation<soundtrigger::V2_0::ISoundTriggerHw>() != OK,
     49     ALOGW_IF(fail, "Could not register soundtrigger API 2.0 nor 2.1");
     50 
     51     fail =
     52         registerPassthroughServiceImplementation<bluetooth::a2dp::V1_0::IBluetoothAudioOffload>() !=
     53         OK;
     54     ALOGW_IF(fail, "Could not register Bluetooth audio offload 1.0");
     55 
     56     joinRpcThreadpool();
     57 }
     58