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