blob: 99e28d81e334bd4f689ae378b9f5f82f82691e52 [file] [log] [blame]
Shunkai Yao51202502022-12-12 06:11:46 +00001/*
2 * Copyright (C) 2022 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
Mikhail Naganov31d46652023-01-10 18:29:25 +000019#include <aidl/android/hardware/audio/core/BpModule.h>
Shunkai Yao51202502022-12-12 06:11:46 +000020#include <media/audiohal/DeviceHalInterface.h>
21#include <media/audiohal/EffectHalInterface.h>
22
Mikhail Naganov31d46652023-01-10 18:29:25 +000023#include "ConversionHelperAidl.h"
Shunkai Yao51202502022-12-12 06:11:46 +000024
25namespace android {
26
Mikhail Naganov31d46652023-01-10 18:29:25 +000027class DeviceHalAidl : public DeviceHalInterface, public ConversionHelperAidl {
Shunkai Yao51202502022-12-12 06:11:46 +000028 public:
29 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
30 status_t getSupportedDevices(uint32_t *devices) override;
31
32 // Check to see if the audio hardware interface has been initialized.
33 status_t initCheck() override;
34
35 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
36 status_t setVoiceVolume(float volume) override;
37
38 // Set the audio volume for all audio activities other than voice call.
39 status_t setMasterVolume(float volume) override;
40
41 // Get the current master volume value for the HAL.
42 status_t getMasterVolume(float *volume) override;
43
44 // Called when the audio mode changes.
45 status_t setMode(audio_mode_t mode) override;
46
47 // Muting control.
48 status_t setMicMute(bool state) override;
49
50 status_t getMicMute(bool* state) override;
51
52 status_t setMasterMute(bool state) override;
53
54 status_t getMasterMute(bool *state) override;
55
56 // Set global audio parameters.
57 status_t setParameters(const String8& kvPairs) override;
58
59 // Get global audio parameters.
60 status_t getParameters(const String8& keys, String8 *values) override;
61
62 // Returns audio input buffer size according to parameters passed.
63 status_t getInputBufferSize(const struct audio_config* config, size_t* size) override;
64
65 // Creates and opens the audio hardware output stream. The stream is closed
66 // by releasing all references to the returned object.
67 status_t openOutputStream(audio_io_handle_t handle, audio_devices_t devices,
68 audio_output_flags_t flags, struct audio_config* config,
69 const char* address, sp<StreamOutHalInterface>* outStream) override;
70
71 // Creates and opens the audio hardware input stream. The stream is closed
72 // by releasing all references to the returned object.
73 status_t openInputStream(audio_io_handle_t handle, audio_devices_t devices,
74 struct audio_config* config, audio_input_flags_t flags,
75 const char* address, audio_source_t source,
76 audio_devices_t outputDevice, const char* outputDeviceAddress,
77 sp<StreamInHalInterface>* inStream) override;
78
79 // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
80 status_t supportsAudioPatches(bool* supportsPatches) override;
81
82 // Creates an audio patch between several source and sink ports.
83 status_t createAudioPatch(unsigned int num_sources, const struct audio_port_config* sources,
84 unsigned int num_sinks, const struct audio_port_config* sinks,
85 audio_patch_handle_t* patch) override;
86
87 // Releases an audio patch.
88 status_t releaseAudioPatch(audio_patch_handle_t patch) override;
89
Mikhail Naganov31d46652023-01-10 18:29:25 +000090 // Fills the list of supported attributes for a given audio port.
91 status_t getAudioPort(struct audio_port* port) override;
92
93 // Fills the list of supported attributes for a given audio port.
94 status_t getAudioPort(struct audio_port_v7 *port) override;
95
Shunkai Yao51202502022-12-12 06:11:46 +000096 // Set audio port configuration.
97 status_t setAudioPortConfig(const struct audio_port_config* config) override;
98
99 // List microphones
100 status_t getMicrophones(std::vector<audio_microphone_characteristic_t>* microphones);
101
102 status_t addDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
103
104 status_t removeDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
105
106 status_t getMmapPolicyInfos(media::audio::common::AudioMMapPolicyType policyType __unused,
107 std::vector<media::audio::common::AudioMMapPolicyInfo>* policyInfos
108 __unused) override;
109
110 int32_t getAAudioMixerBurstCount() override;
111
112 int32_t getAAudioHardwareBurstMinUsec() override;
113
114 error::Result<audio_hw_sync_t> getHwAvSync() override;
115
116 status_t dump(int __unused, const Vector<String16>& __unused) override;
117
118 int32_t supportsBluetoothVariableLatency(bool* supports __unused) override;
119
120 private:
Mikhail Naganov31d46652023-01-10 18:29:25 +0000121 friend class sp<DeviceHalAidl>;
122
123 const std::shared_ptr<::aidl::android::hardware::audio::core::IModule> mModule;
Shunkai Yao51202502022-12-12 06:11:46 +0000124
125 // Can not be constructed directly by clients.
126 explicit DeviceHalAidl(
Mikhail Naganov31d46652023-01-10 18:29:25 +0000127 const std::shared_ptr<::aidl::android::hardware::audio::core::IModule>& module)
128 : ConversionHelperAidl("DeviceHalAidl"), mModule(module) {}
Shunkai Yao51202502022-12-12 06:11:46 +0000129
Mikhail Naganov31d46652023-01-10 18:29:25 +0000130 ~DeviceHalAidl() override = default;
Shunkai Yao51202502022-12-12 06:11:46 +0000131};
132
133} // namespace android