blob: 3e586cf27a1f48288899bcb54d50029820f693f1 [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 {
24
25class DeviceHalLocal : public DeviceHalInterface
26{
27 public:
28 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
29 virtual status_t getSupportedDevices(uint32_t *devices);
30
31 // Check to see if the audio hardware interface has been initialized.
32 virtual status_t initCheck();
33
34 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
35 virtual status_t setVoiceVolume(float volume);
36
37 // Set the audio volume for all audio activities other than voice call.
38 virtual status_t setMasterVolume(float volume);
39
40 // Get the current master volume value for the HAL.
41 virtual status_t getMasterVolume(float *volume);
42
43 // Called when the audio mode changes.
44 virtual status_t setMode(audio_mode_t mode);
45
46 // Muting control.
47 virtual status_t setMicMute(bool state);
48 virtual status_t getMicMute(bool *state);
49 virtual status_t setMasterMute(bool state);
50 virtual status_t getMasterMute(bool *state);
51
52 // Set global audio parameters.
53 virtual status_t setParameters(const String8& kvPairs);
54
55 // Get global audio parameters.
56 virtual status_t getParameters(const String8& keys, String8 *values);
57
58 // Returns audio input buffer size according to parameters passed.
59 virtual status_t getInputBufferSize(const struct audio_config *config,
60 size_t *size);
61
62 // Creates and opens the audio hardware output stream. The stream is closed
63 // by releasing all references to the returned object.
64 virtual status_t openOutputStream(
65 audio_io_handle_t handle,
66 audio_devices_t devices,
67 audio_output_flags_t flags,
68 struct audio_config *config,
69 const char *address,
70 sp<StreamOutHalInterface> *outStream);
71
72 // Creates and opens the audio hardware input stream. The stream is closed
73 // by releasing all references to the returned object.
74 virtual status_t openInputStream(
75 audio_io_handle_t handle,
76 audio_devices_t devices,
77 struct audio_config *config,
78 audio_input_flags_t flags,
79 const char *address,
80 audio_source_t source,
Mikhail Naganovb4e037e2019-01-14 15:56:33 -080081 audio_devices_t outputDevice,
82 const char *outputDeviceAddress,
Kevin Rocard4bcd67f2018-02-28 14:33:38 -080083 sp<StreamInHalInterface> *inStream);
84
85 // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
86 virtual status_t supportsAudioPatches(bool *supportsPatches);
87
88 // Creates an audio patch between several source and sink ports.
89 virtual status_t createAudioPatch(
90 unsigned int num_sources,
91 const struct audio_port_config *sources,
92 unsigned int num_sinks,
93 const struct audio_port_config *sinks,
94 audio_patch_handle_t *patch);
95
96 // Releases an audio patch.
97 virtual status_t releaseAudioPatch(audio_patch_handle_t patch);
98
99 // Fills the list of supported attributes for a given audio port.
100 virtual status_t getAudioPort(struct audio_port *port);
101
jiabinb4fed192020-09-22 14:45:40 -0700102 // Fills the list of supported attributes for a given audio port.
103 virtual status_t getAudioPort(struct audio_port_v7 *port);
104
Kevin Rocard4bcd67f2018-02-28 14:33:38 -0800105 // Set audio port configuration.
106 virtual status_t setAudioPortConfig(const struct audio_port_config *config);
107
jiabin9ff780e2018-03-19 18:19:52 -0700108 // List microphones
109 virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones);
110
Eric Laurentb82e6b72019-11-22 17:25:04 -0800111 status_t addDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
112 status_t removeDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
113
Jiabin Huangebe64102021-09-07 20:01:07 +0000114 status_t getMmapPolicyInfos(
jiabine99d0882021-09-17 05:21:25 +0000115 media::audio::common::AudioMMapPolicyType policyType __unused,
116 std::vector<media::audio::common::AudioMMapPolicyInfo> *policyInfos __unused) override {
Jiabin Huangebe64102021-09-07 20:01:07 +0000117 // This function will only be available on AIDL HAL.
118 return INVALID_OPERATION;
119 }
120
jiabine504e7b2021-09-18 00:27:08 +0000121 int32_t getAAudioMixerBurstCount() override {
122 // This function will only be available on AIDL HAL.
123 return INVALID_OPERATION;
124 }
125
126 int32_t getAAudioHardwareBurstMinUsec() override {
127 // This function will only be available on AIDL HAL.
128 return INVALID_OPERATION;
129 }
130
Mikhail Naganov516d3982022-02-01 23:53:59 +0000131 status_t setConnectedState(const struct audio_port_v7 *port, bool connected) override;
132
Andy Hung61589a42021-06-16 09:37:53 -0700133 status_t dump(int fd, const Vector<String16>& args) override;
Kevin Rocard4bcd67f2018-02-28 14:33:38 -0800134
135 void closeOutputStream(struct audio_stream_out *stream_out);
136 void closeInputStream(struct audio_stream_in *stream_in);
137
Eric Laurent94579172020-11-20 18:41:04 +0100138 uint32_t version() const { return mDev->common.version; }
139
Kevin Rocard4bcd67f2018-02-28 14:33:38 -0800140 private:
141 audio_hw_device_t *mDev;
142
143 friend class DevicesFactoryHalLocal;
144
145 // Can not be constructed directly by clients.
146 explicit DeviceHalLocal(audio_hw_device_t *dev);
147
148 // The destructor automatically closes the device.
149 virtual ~DeviceHalLocal();
Kevin Rocard4bcd67f2018-02-28 14:33:38 -0800150};
151
152} // namespace android
153
Kevin Rocarddf9b4202018-05-10 19:56:08 -0700154#endif // ANDROID_HARDWARE_DEVICE_HAL_LOCAL_H