1 // Copyright (C) 2020 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 // clang-format off 18 #include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h) 19 // clang-format on 20 21 #include "DeviceImpl.h" 22 #include "ServiceConfig.h" 23 24 namespace audio_proxy { 25 namespace service { 26 27 using android::hardware::Return; 28 29 #if MAJOR_VERSION == 7 && MINOR_VERSION == 1 30 using android::hardware::audio::V7_1::IDevicesFactory; 31 #else 32 using android::hardware::audio::CPP_VERSION::IDevicesFactory; 33 #endif 34 35 class BusStreamProvider; 36 37 class DevicesFactoryImpl : public IDevicesFactory { 38 public: 39 DevicesFactoryImpl(BusStreamProvider& busDeviceProvider, 40 const ServiceConfig& config); 41 42 // Methods from android::hardware::audio::V5_0::IDevicesFactory follow. 43 Return<void> openDevice(const hidl_string& device, 44 openDevice_cb _hidl_cb) override; 45 Return<void> openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) override; 46 47 #if MAJOR_VERSION == 7 && MINOR_VERSION == 1 48 Return<void> openDevice_7_1(const hidl_string& device, 49 openDevice_7_1_cb _hidl_cb) override; 50 Return<void> openPrimaryDevice_7_1( 51 openPrimaryDevice_7_1_cb _hidl_cb) override; 52 #endif 53 54 private: 55 BusStreamProvider& mBusStreamProvider; 56 const ServiceConfig& mConfig; 57 }; 58 59 } // namespace service 60 } // namespace audio_proxy 61