• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
18 #define ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
19 
20 #include <android/hardware/audio/2.0/IDevice.h>
21 #include <android/hardware/audio/2.0/IPrimaryDevice.h>
22 #include <media/audiohal/DeviceHalInterface.h>
23 
24 #include "ConversionHelperHidl.h"
25 
26 using ::android::hardware::audio::V2_0::IDevice;
27 using ::android::hardware::audio::V2_0::IPrimaryDevice;
28 using ::android::hardware::Return;
29 
30 namespace android {
31 
32 class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl
33 {
34   public:
35     // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
36     virtual status_t getSupportedDevices(uint32_t *devices);
37 
38     // Check to see if the audio hardware interface has been initialized.
39     virtual status_t initCheck();
40 
41     // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
42     virtual status_t setVoiceVolume(float volume);
43 
44     // Set the audio volume for all audio activities other than voice call.
45     virtual status_t setMasterVolume(float volume);
46 
47     // Get the current master volume value for the HAL.
48     virtual status_t getMasterVolume(float *volume);
49 
50     // Called when the audio mode changes.
51     virtual status_t setMode(audio_mode_t mode);
52 
53     // Muting control.
54     virtual status_t setMicMute(bool state);
55     virtual status_t getMicMute(bool *state);
56     virtual status_t setMasterMute(bool state);
57     virtual status_t getMasterMute(bool *state);
58 
59     // Set global audio parameters.
60     virtual status_t setParameters(const String8& kvPairs);
61 
62     // Get global audio parameters.
63     virtual status_t getParameters(const String8& keys, String8 *values);
64 
65     // Returns audio input buffer size according to parameters passed.
66     virtual status_t getInputBufferSize(const struct audio_config *config,
67             size_t *size);
68 
69     // Creates and opens the audio hardware output stream. The stream is closed
70     // by releasing all references to the returned object.
71     virtual status_t openOutputStream(
72             audio_io_handle_t handle,
73             audio_devices_t devices,
74             audio_output_flags_t flags,
75             struct audio_config *config,
76             const char *address,
77             sp<StreamOutHalInterface> *outStream);
78 
79     // Creates and opens the audio hardware input stream. The stream is closed
80     // by releasing all references to the returned object.
81     virtual status_t openInputStream(
82             audio_io_handle_t handle,
83             audio_devices_t devices,
84             struct audio_config *config,
85             audio_input_flags_t flags,
86             const char *address,
87             audio_source_t source,
88             sp<StreamInHalInterface> *inStream);
89 
90     // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
91     virtual status_t supportsAudioPatches(bool *supportsPatches);
92 
93     // Creates an audio patch between several source and sink ports.
94     virtual status_t createAudioPatch(
95             unsigned int num_sources,
96             const struct audio_port_config *sources,
97             unsigned int num_sinks,
98             const struct audio_port_config *sinks,
99             audio_patch_handle_t *patch);
100 
101     // Releases an audio patch.
102     virtual status_t releaseAudioPatch(audio_patch_handle_t patch);
103 
104     // Fills the list of supported attributes for a given audio port.
105     virtual status_t getAudioPort(struct audio_port *port);
106 
107     // Set audio port configuration.
108     virtual status_t setAudioPortConfig(const struct audio_port_config *config);
109 
110     virtual status_t dump(int fd);
111 
112   private:
113     friend class DevicesFactoryHalHidl;
114     sp<IDevice> mDevice;
115     sp<IPrimaryDevice> mPrimaryDevice;  // Null if it's not a primary device.
116 
117     // Can not be constructed directly by clients.
118     explicit DeviceHalHidl(const sp<IDevice>& device);
119 
120     // The destructor automatically closes the device.
121     virtual ~DeviceHalHidl();
122 };
123 
124 } // namespace android
125 
126 #endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
127