blob: 195204bec4ae4c0fc11536d5365ef0cdc27b8326 [file] [log] [blame]
Kevin Rocard4bcd67f2018-02-28 14:33:38 -08001/*
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
Kevin Rocarddf9b4202018-05-10 19:56:08 -070017#ifndef ANDROID_HARDWARE_DEVICE_HAL_LOCAL_H
18#define ANDROID_HARDWARE_DEVICE_HAL_LOCAL_H
Kevin Rocard4bcd67f2018-02-28 14:33:38 -080019
20#include <hardware/audio.h>
21#include <media/audiohal/DeviceHalInterface.h>
22
23namespace android {
Kevin Rocard070e7512018-05-22 09:29:13 -070024namespace CPP_VERSION {
Kevin Rocard4bcd67f2018-02-28 14:33:38 -080025
26class DeviceHalLocal : public DeviceHalInterface
27{
28 public:
29 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
30 virtual status_t getSupportedDevices(uint32_t *devices);
31
32 // Check to see if the audio hardware interface has been initialized.
33 virtual status_t initCheck();
34
35 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
36 virtual status_t setVoiceVolume(float volume);
37
38 // Set the audio volume for all audio activities other than voice call.
39 virtual status_t setMasterVolume(float volume);
40
41 // Get the current master volume value for the HAL.
42 virtual status_t getMasterVolume(float *volume);
43
44 // Called when the audio mode changes.
45 virtual status_t setMode(audio_mode_t mode);
46
47 // Muting control.
48 virtual status_t setMicMute(bool state);
49 virtual status_t getMicMute(bool *state);
50 virtual status_t setMasterMute(bool state);
51 virtual status_t getMasterMute(bool *state);
52
53 // Set global audio parameters.
54 virtual status_t setParameters(const String8& kvPairs);
55
56 // Get global audio parameters.
57 virtual status_t getParameters(const String8& keys, String8 *values);
58
59 // Returns audio input buffer size according to parameters passed.
60 virtual status_t getInputBufferSize(const struct audio_config *config,
61 size_t *size);
62
63 // Creates and opens the audio hardware output stream. The stream is closed
64 // by releasing all references to the returned object.
65 virtual status_t openOutputStream(
66 audio_io_handle_t handle,
67 audio_devices_t devices,
68 audio_output_flags_t flags,
69 struct audio_config *config,
70 const char *address,
71 sp<StreamOutHalInterface> *outStream);
72
73 // Creates and opens the audio hardware input stream. The stream is closed
74 // by releasing all references to the returned object.
75 virtual status_t openInputStream(
76 audio_io_handle_t handle,
77 audio_devices_t devices,
78 struct audio_config *config,
79 audio_input_flags_t flags,
80 const char *address,
81 audio_source_t source,
Mikhail Naganovb4e037e2019-01-14 15:56:33 -080082 audio_devices_t outputDevice,
83 const char *outputDeviceAddress,
Kevin Rocard4bcd67f2018-02-28 14:33:38 -080084 sp<StreamInHalInterface> *inStream);
85
86 // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
87 virtual status_t supportsAudioPatches(bool *supportsPatches);
88
89 // Creates an audio patch between several source and sink ports.
90 virtual status_t createAudioPatch(
91 unsigned int num_sources,
92 const struct audio_port_config *sources,
93 unsigned int num_sinks,
94 const struct audio_port_config *sinks,
95 audio_patch_handle_t *patch);
96
97 // Releases an audio patch.
98 virtual status_t releaseAudioPatch(audio_patch_handle_t patch);
99
100 // Fills the list of supported attributes for a given audio port.
101 virtual status_t getAudioPort(struct audio_port *port);
102
jiabinb4fed192020-09-22 14:45:40 -0700103 // Fills the list of supported attributes for a given audio port.
104 virtual status_t getAudioPort(struct audio_port_v7 *port);
105
Kevin Rocard4bcd67f2018-02-28 14:33:38 -0800106 // Set audio port configuration.
107 virtual status_t setAudioPortConfig(const struct audio_port_config *config);
108
jiabin9ff780e2018-03-19 18:19:52 -0700109 // List microphones
110 virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones);
111
Eric Laurentb82e6b72019-11-22 17:25:04 -0800112 status_t addDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
113 status_t removeDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
114
Kevin Rocard4bcd67f2018-02-28 14:33:38 -0800115 virtual status_t dump(int fd);
116
117 void closeOutputStream(struct audio_stream_out *stream_out);
118 void closeInputStream(struct audio_stream_in *stream_in);
119
120 private:
121 audio_hw_device_t *mDev;
122
123 friend class DevicesFactoryHalLocal;
124
125 // Can not be constructed directly by clients.
126 explicit DeviceHalLocal(audio_hw_device_t *dev);
127
128 // The destructor automatically closes the device.
129 virtual ~DeviceHalLocal();
130
131 uint32_t version() const { return mDev->common.version; }
132};
133
Kevin Rocard070e7512018-05-22 09:29:13 -0700134} // namespace CPP_VERSION
Kevin Rocard4bcd67f2018-02-28 14:33:38 -0800135} // namespace android
136
Kevin Rocarddf9b4202018-05-10 19:56:08 -0700137#endif // ANDROID_HARDWARE_DEVICE_HAL_LOCAL_H