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 #include "DevicesFactoryImpl.h"
16
17 #include <utils/Log.h>
18
19 #undef LOG_TAG
20 #define LOG_TAG "AudioProxyDevicesManagerImpl"
21
22 using namespace ::android::hardware::audio::CPP_VERSION;
23
24 namespace audio_proxy {
25 namespace service {
26
DevicesFactoryImpl(BusDeviceProvider & busDeviceProvider)27 DevicesFactoryImpl::DevicesFactoryImpl(BusDeviceProvider& busDeviceProvider)
28 : mBusDeviceProvider(busDeviceProvider) {}
29
30 // Methods from ::android::hardware::audio::V5_0::IDevicesFactory follow.
openDevice(const hidl_string & device,openDevice_cb _hidl_cb)31 Return<void> DevicesFactoryImpl::openDevice(const hidl_string& device,
32 openDevice_cb _hidl_cb) {
33 ALOGE("openDevice");
34 if (device == "audio_proxy") {
35 ALOGE("Audio Device was opened: %s", device.c_str());
36 _hidl_cb(Result::OK, new DeviceImpl(mBusDeviceProvider));
37 } else {
38 _hidl_cb(Result::INVALID_ARGUMENTS, nullptr);
39 }
40
41 return Void();
42 }
43
openPrimaryDevice(openPrimaryDevice_cb _hidl_cb)44 Return<void> DevicesFactoryImpl::openPrimaryDevice(
45 openPrimaryDevice_cb _hidl_cb) {
46 // The AudioProxy HAL does not support a primary device.
47 _hidl_cb(Result::NOT_SUPPORTED, nullptr);
48 return Void();
49 }
50
51 } // namespace service
52 } // namespace audio_proxy
53