1 /* 2 * Copyright (C) 2018 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 #ifndef ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H 18 #define ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H 19 20 #include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h) 21 22 #include <hardware/audio.h> 23 24 #include <hidl/Status.h> 25 26 #include <hidl/MQDescriptor.h> 27 namespace android { 28 namespace hardware { 29 namespace audio { 30 namespace CPP_VERSION { 31 namespace implementation { 32 33 using ::android::sp; 34 using ::android::hardware::hidl_string; 35 using ::android::hardware::hidl_vec; 36 using ::android::hardware::Return; 37 using ::android::hardware::Void; 38 using namespace ::android::hardware::audio::CPP_VERSION; 39 40 struct DevicesFactory : public IDevicesFactory { 41 #if MAJOR_VERSION == 2 42 Return<void> openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) override; 43 #elif MAJOR_VERSION >= 4 44 Return<void> openDevice(const hidl_string& device, openDevice_cb _hidl_cb) override; 45 Return<void> openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) override; 46 #endif 47 48 private: 49 template <class DeviceShim, class Callback> 50 Return<void> openDevice(const char* moduleName, Callback _hidl_cb); 51 Return<void> openDevice(const char* moduleName, openDevice_cb _hidl_cb); 52 53 static int loadAudioInterface(const char* if_name, audio_hw_device_t** dev); 54 }; 55 56 extern "C" IDevicesFactory* HIDL_FETCH_IDevicesFactory(const char* name); 57 58 } // namespace implementation 59 } // namespace CPP_VERSION 60 } // namespace audio 61 } // namespace hardware 62 } // namespace android 63 64 #endif // ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H 65