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 <hidl/HidlTransportSupport.h> 20#include <hidl/LegacySupport.h> 21#include <android/hardware/audio/2.0/IDevicesFactory.h> 22#include <android/hardware/audio/effect/2.0/IEffectsFactory.h> 23#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h> 24#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h> 25#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h> 26 27using android::hardware::configureRpcThreadpool; 28using android::hardware::joinRpcThreadpool; 29using android::hardware::registerPassthroughServiceImplementation; 30 31using android::hardware::audio::effect::V2_0::IEffectsFactory; 32using android::hardware::audio::V2_0::IDevicesFactory; 33using android::hardware::soundtrigger::V2_0::ISoundTriggerHw; 34using android::hardware::registerPassthroughServiceImplementation; 35namespace 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 42 43using android::OK; 44 45int main(int /* argc */, char* /* argv */ []) { 46 configureRpcThreadpool(16, true /*callerWillJoin*/); 47 android::status_t status; 48 status = registerPassthroughServiceImplementation<IDevicesFactory>(); 49 LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status); 50 status = registerPassthroughServiceImplementation<IEffectsFactory>(); 51 LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status); 52 // Soundtrigger and FM radio might be not present. 53 status = registerPassthroughServiceImplementation<ISoundTriggerHw>(); 54 ALOGE_IF(status != OK, "Error while registering soundtrigger service: %d", status); 55 if (useBroadcastRadioFutureFeatures) { 56 status = registerPassthroughServiceImplementation< 57 broadcastradio::V1_1::IBroadcastRadioFactory>(); 58 } else { 59 status = registerPassthroughServiceImplementation< 60 broadcastradio::V1_0::IBroadcastRadioFactory>(); 61 } 62 ALOGE_IF(status != OK, "Error while registering fm radio service: %d", status); 63 joinRpcThreadpool(); 64 return status; 65} 66