blob: d342d4aaab5f822d22103564ea0582e200f5e5b1 [file] [log] [blame]
Mikhail Naganovf558e022016-11-14 17:45:17 -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
17#ifndef ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
18#define ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
19
Kevin Rocard95213bf2018-11-08 17:16:57 -080020#include PATH(android/hardware/audio/FILE_VERSION/IDevice.h)
21#include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h)
Mikhail Naganovf558e022016-11-14 17:45:17 -080022#include <media/audiohal/DeviceHalInterface.h>
23
24#include "ConversionHelperHidl.h"
25
Kevin Rocard070e7512018-05-22 09:29:13 -070026using ::android::hardware::audio::CPP_VERSION::IDevice;
27using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice;
Mikhail Naganovf558e022016-11-14 17:45:17 -080028using ::android::hardware::Return;
29
30namespace android {
Kevin Rocard070e7512018-05-22 09:29:13 -070031namespace CPP_VERSION {
Mikhail Naganovf558e022016-11-14 17:45:17 -080032
33class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl
34{
35 public:
36 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
37 virtual status_t getSupportedDevices(uint32_t *devices);
38
39 // Check to see if the audio hardware interface has been initialized.
40 virtual status_t initCheck();
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);
44
45 // Set the audio volume for all audio activities other than voice call.
46 virtual status_t setMasterVolume(float volume);
47
48 // Get the current master volume value for the HAL.
49 virtual status_t getMasterVolume(float *volume);
50
51 // Called when the audio mode changes.
52 virtual status_t setMode(audio_mode_t mode);
53
54 // Muting control.
55 virtual status_t setMicMute(bool state);
56 virtual status_t getMicMute(bool *state);
57 virtual status_t setMasterMute(bool state);
58 virtual status_t getMasterMute(bool *state);
59
60 // Set global audio parameters.
61 virtual status_t setParameters(const String8& kvPairs);
62
63 // Get global audio parameters.
64 virtual status_t getParameters(const String8& keys, String8 *values);
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);
69
70 // Creates and opens the audio hardware output stream. The stream is closed
71 // by releasing all references to the returned object.
72 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);
79
80 // Creates and opens the audio hardware input stream. The stream is closed
81 // by releasing all references to the returned object.
82 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,
Mikhail Naganovb4e037e2019-01-14 15:56:33 -080089 audio_devices_t outputDevice,
90 const char *outputDeviceAddress,
Mikhail Naganovf558e022016-11-14 17:45:17 -080091 sp<StreamInHalInterface> *inStream);
92
93 // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
94 virtual status_t supportsAudioPatches(bool *supportsPatches);
95
96 // Creates an audio patch between several source and sink ports.
97 virtual status_t createAudioPatch(
98 unsigned int num_sources,
99 const struct audio_port_config *sources,
100 unsigned int num_sinks,
101 const struct audio_port_config *sinks,
102 audio_patch_handle_t *patch);
103
104 // Releases an audio patch.
105 virtual status_t releaseAudioPatch(audio_patch_handle_t patch);
106
107 // Fills the list of supported attributes for a given audio port.
108 virtual status_t getAudioPort(struct audio_port *port);
109
110 // Set audio port configuration.
111 virtual status_t setAudioPortConfig(const struct audio_port_config *config);
112
jiabin9ff780e2018-03-19 18:19:52 -0700113 // List microphones
114 virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones);
115
Eric Laurentb82e6b72019-11-22 17:25:04 -0800116 status_t addDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
117 status_t removeDeviceEffect(audio_port_handle_t device, sp<EffectHalInterface> effect) override;
118
Mikhail Naganovf558e022016-11-14 17:45:17 -0800119 virtual status_t dump(int fd);
120
121 private:
122 friend class DevicesFactoryHalHidl;
123 sp<IDevice> mDevice;
Mikhail Naganov9063fa72017-06-30 15:33:51 -0700124 sp<IPrimaryDevice> mPrimaryDevice; // Null if it's not a primary device.
Mikhail Naganovf558e022016-11-14 17:45:17 -0800125
126 // Can not be constructed directly by clients.
127 explicit DeviceHalHidl(const sp<IDevice>& device);
128
129 // The destructor automatically closes the device.
130 virtual ~DeviceHalHidl();
131};
132
Kevin Rocard070e7512018-05-22 09:29:13 -0700133} // namespace CPP_VERSION
Mikhail Naganovf558e022016-11-14 17:45:17 -0800134} // namespace android
135
136#endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_H