blob: fb5e7e730264924e7b3649361425f06de5948a09 [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
20#include <android/hardware/audio/2.0/IDevice.h>
Kevin Rocard070e7512018-05-22 09:29:13 -070021#include <android/hardware/audio/4.0/IDevice.h>
Mikhail Naganov9063fa72017-06-30 15:33:51 -070022#include <android/hardware/audio/2.0/IPrimaryDevice.h>
Kevin Rocard070e7512018-05-22 09:29:13 -070023#include <android/hardware/audio/4.0/IPrimaryDevice.h>
Mikhail Naganovf558e022016-11-14 17:45:17 -080024#include <media/audiohal/DeviceHalInterface.h>
25
26#include "ConversionHelperHidl.h"
27
Kevin Rocard070e7512018-05-22 09:29:13 -070028using ::android::hardware::audio::CPP_VERSION::IDevice;
29using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice;
Mikhail Naganovf558e022016-11-14 17:45:17 -080030using ::android::hardware::Return;
31
32namespace android {
Kevin Rocard070e7512018-05-22 09:29:13 -070033namespace CPP_VERSION {
Mikhail Naganovf558e022016-11-14 17:45:17 -080034
35class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl
36{
37 public:
38 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
39 virtual status_t getSupportedDevices(uint32_t *devices);
40
41 // Check to see if the audio hardware interface has been initialized.
42 virtual status_t initCheck();
43
44 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
45 virtual status_t setVoiceVolume(float volume);
46
47 // Set the audio volume for all audio activities other than voice call.
48 virtual status_t setMasterVolume(float volume);
49
50 // Get the current master volume value for the HAL.
51 virtual status_t getMasterVolume(float *volume);
52
53 // Called when the audio mode changes.
54 virtual status_t setMode(audio_mode_t mode);
55
56 // Muting control.
57 virtual status_t setMicMute(bool state);
58 virtual status_t getMicMute(bool *state);
59 virtual status_t setMasterMute(bool state);
60 virtual status_t getMasterMute(bool *state);
61
62 // Set global audio parameters.
63 virtual status_t setParameters(const String8& kvPairs);
64
65 // Get global audio parameters.
66 virtual status_t getParameters(const String8& keys, String8 *values);
67
68 // Returns audio input buffer size according to parameters passed.
69 virtual status_t getInputBufferSize(const struct audio_config *config,
70 size_t *size);
71
72 // Creates and opens the audio hardware output stream. The stream is closed
73 // by releasing all references to the returned object.
74 virtual status_t openOutputStream(
75 audio_io_handle_t handle,
76 audio_devices_t devices,
77 audio_output_flags_t flags,
78 struct audio_config *config,
79 const char *address,
80 sp<StreamOutHalInterface> *outStream);
81
82 // Creates and opens the audio hardware input stream. The stream is closed
83 // by releasing all references to the returned object.
84 virtual status_t openInputStream(
85 audio_io_handle_t handle,
86 audio_devices_t devices,
87 struct audio_config *config,
88 audio_input_flags_t flags,
89 const char *address,
90 audio_source_t source,
91 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
Mikhail Naganovf558e022016-11-14 17:45:17 -0800116 virtual status_t dump(int fd);
117
118 private:
119 friend class DevicesFactoryHalHidl;
120 sp<IDevice> mDevice;
Mikhail Naganov9063fa72017-06-30 15:33:51 -0700121 sp<IPrimaryDevice> mPrimaryDevice; // Null if it's not a primary device.
Mikhail Naganovf558e022016-11-14 17:45:17 -0800122
123 // Can not be constructed directly by clients.
124 explicit DeviceHalHidl(const sp<IDevice>& device);
125
126 // The destructor automatically closes the device.
127 virtual ~DeviceHalHidl();
128};
129
Kevin Rocard070e7512018-05-22 09:29:13 -0700130} // namespace CPP_VERSION
Mikhail Naganovf558e022016-11-14 17:45:17 -0800131} // namespace android
132
133#endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_H