blob: 2f7ed3acf1c08a10f94a399941a19dbacbe92835 [file] [log] [blame]
Mikhail Naganove4f1f632016-08-31 11:35:10 -07001/*
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_INTERFACE_H
18#define ANDROID_HARDWARE_DEVICE_HAL_INTERFACE_H
19
Mikhail Naganovcbc8f612016-10-11 18:05:13 -070020#include <system/audio.h>
Mikhail Naganove4f1f632016-08-31 11:35:10 -070021#include <utils/Errors.h>
22#include <utils/RefBase.h>
23#include <utils/String8.h>
24
25namespace android {
26
Mikhail Naganov1dc98672016-08-18 17:50:29 -070027class StreamInHalInterface;
28class StreamOutHalInterface;
29
Mikhail Naganove4f1f632016-08-31 11:35:10 -070030class DeviceHalInterface : public RefBase
31{
32 public:
Mikhail Naganove4f1f632016-08-31 11:35:10 -070033 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
34 virtual status_t getSupportedDevices(uint32_t *devices) = 0;
35
36 // Get the hardware module version.
37 virtual status_t getVersion(uint32_t *version) = 0;
38
39 // Check to see if the audio hardware interface has been initialized.
40 virtual status_t initCheck() = 0;
41
42 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
43 virtual status_t setVoiceVolume(float volume) = 0;
44
45 // Set the audio volume for all audio activities other than voice call.
46 virtual status_t setMasterVolume(float volume) = 0;
47
48 // Get the current master volume value for the HAL.
49 virtual status_t getMasterVolume(float *volume) = 0;
50
51 // Called when the audio mode changes.
52 virtual status_t setMode(audio_mode_t mode) = 0;
53
54 // Muting control.
55 virtual status_t setMicMute(bool state) = 0;
56 virtual status_t getMicMute(bool *state) = 0;
57 virtual status_t setMasterMute(bool state) = 0;
58 virtual status_t getMasterMute(bool *state) = 0;
59
60 // Set global audio parameters.
61 virtual status_t setParameters(const String8& kvPairs) = 0;
62
63 // Get global audio parameters.
64 virtual status_t getParameters(const String8& keys, String8 *values) = 0;
65
66 // Returns audio input buffer size according to parameters passed.
67 virtual status_t getInputBufferSize(const struct audio_config *config,
68 size_t *size) = 0;
69
70 // Creates and opens the audio hardware output stream. The stream is closed
71 // by releasing all references to the returned object.
Mikhail Naganov1dc98672016-08-18 17:50:29 -070072 virtual status_t openOutputStream(
73 audio_io_handle_t handle,
74 audio_devices_t devices,
75 audio_output_flags_t flags,
76 struct audio_config *config,
77 const char *address,
78 sp<StreamOutHalInterface> *outStream) = 0;
Mikhail Naganove4f1f632016-08-31 11:35:10 -070079
80 // Creates and opens the audio hardware input stream. The stream is closed
81 // by releasing all references to the returned object.
Mikhail Naganov1dc98672016-08-18 17:50:29 -070082 virtual status_t openInputStream(
83 audio_io_handle_t handle,
84 audio_devices_t devices,
85 struct audio_config *config,
86 audio_input_flags_t flags,
87 const char *address,
88 audio_source_t source,
89 sp<StreamInHalInterface> *inStream) = 0;
Mikhail Naganove4f1f632016-08-31 11:35:10 -070090
91 // Creates an audio patch between several source and sink ports.
92 virtual status_t createAudioPatch(
93 unsigned int num_sources,
94 const struct audio_port_config *sources,
95 unsigned int num_sinks,
96 const struct audio_port_config *sinks,
97 audio_patch_handle_t *patch) = 0;
98
99 // Releases an audio patch.
100 virtual status_t releaseAudioPatch(audio_patch_handle_t patch) = 0;
101
102 // Fills the list of supported attributes for a given audio port.
103 virtual status_t getAudioPort(struct audio_port *port) = 0;
104
105 // Set audio port configuration.
106 virtual status_t setAudioPortConfig(const struct audio_port_config *config) = 0;
107
108 virtual status_t dump(int fd) = 0;
109
110 protected:
111 // Subclasses can not be constructed directly by clients.
112 DeviceHalInterface() {}
Mikhail Naganov1dc98672016-08-18 17:50:29 -0700113
114 // The destructor automatically closes the device.
115 virtual ~DeviceHalInterface() {}
Mikhail Naganove4f1f632016-08-31 11:35:10 -0700116};
117
118} // namespace android
119
120#endif // ANDROID_HARDWARE_DEVICE_HAL_INTERFACE_H