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 #pragma once
18 
19 #include <android/media/audio/common/AudioHalEngineConfig.h>
20 #include <android/media/SurroundSoundConfig.h>
21 #include <media/audiohal/DeviceHalInterface.h>
22 #include <utils/Errors.h>
23 #include <utils/RefBase.h>
24 #include <vector>
25 
26 #include "AudioHalVersionInfo.h"
27 
28 namespace android {
29 
30 class DevicesFactoryHalCallback : public RefBase
31 {
32   public:
33     virtual void onNewDevicesAvailable() = 0;
34 };
35 
36 class DevicesFactoryHalInterface : public RefBase
37 {
38   public:
39     virtual status_t getDeviceNames(std::vector<std::string> *names) = 0;
40 
41     // Opens a device with the specified name. To close the device, it is
42     // necessary to release references to the returned object.
43     virtual status_t openDevice(const char *name, sp<DeviceHalInterface> *device) = 0;
44 
45     // Sets a DevicesFactoryHalCallback to notify the client.
46     // The callback can be only set once.
47     virtual status_t setCallbackOnce(sp<DevicesFactoryHalCallback> callback) = 0;
48 
49     virtual android::detail::AudioHalVersionInfo getHalVersion() const = 0;
50 
51     virtual status_t getSurroundSoundConfig(media::SurroundSoundConfig *config) = 0;
52 
53     virtual status_t getEngineConfig(media::audio::common::AudioHalEngineConfig *config) = 0;
54 
55     static sp<DevicesFactoryHalInterface> create();
56 
57   protected:
58     // Subclasses can not be constructed directly by clients.
DevicesFactoryHalInterface()59     DevicesFactoryHalInterface() {}
60 
~DevicesFactoryHalInterface()61     virtual ~DevicesFactoryHalInterface() {}
62 };
63 
64 } // namespace android
65