blob: 11e063acdea8deaa814862136b411088bb2e73e5 [file] [log] [blame]
Mikhail Naganove4f1f632016-08-31 11:35:10 -07001/*
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_LOCAL_H
18#define ANDROID_HARDWARE_DEVICE_HAL_LOCAL_H
19
Mikhail Naganovcbc8f612016-10-11 18:05:13 -070020#include <hardware/audio.h>
Mikhail Naganova0c91332016-09-19 10:01:12 -070021#include <media/audiohal/DeviceHalInterface.h>
Mikhail Naganove4f1f632016-08-31 11:35:10 -070022
23namespace android {
Kevin Rocarddf9b4202018-05-10 19:56:08 -070024namespace V2_0 {
Mikhail Naganove4f1f632016-08-31 11:35:10 -070025
26class DeviceHalLocal : public DeviceHalInterface
27{
28 public:
Mikhail Naganove4f1f632016-08-31 11:35:10 -070029 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
30 virtual status_t getSupportedDevices(uint32_t *devices);
31
Mikhail Naganove4f1f632016-08-31 11:35:10 -070032 // Check to see if the audio hardware interface has been initialized.
33 virtual status_t initCheck();
34
35 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
36 virtual status_t setVoiceVolume(float volume);
37
38 // Set the audio volume for all audio activities other than voice call.
39 virtual status_t setMasterVolume(float volume);
40
41 // Get the current master volume value for the HAL.
42 virtual status_t getMasterVolume(float *volume);
43
44 // Called when the audio mode changes.
45 virtual status_t setMode(audio_mode_t mode);
46
47 // Muting control.
48 virtual status_t setMicMute(bool state);
49 virtual status_t getMicMute(bool *state);
50 virtual status_t setMasterMute(bool state);
51 virtual status_t getMasterMute(bool *state);
52
53 // Set global audio parameters.
54 virtual status_t setParameters(const String8& kvPairs);
55
56 // Get global audio parameters.
57 virtual status_t getParameters(const String8& keys, String8 *values);
58
59 // Returns audio input buffer size according to parameters passed.
60 virtual status_t getInputBufferSize(const struct audio_config *config,
61 size_t *size);
62
63 // Creates and opens the audio hardware output stream. The stream is closed
64 // by releasing all references to the returned object.
Mikhail Naganov1dc98672016-08-18 17:50:29 -070065 virtual status_t openOutputStream(
66 audio_io_handle_t handle,
67 audio_devices_t devices,
68 audio_output_flags_t flags,
69 struct audio_config *config,
70 const char *address,
71 sp<StreamOutHalInterface> *outStream);
Mikhail Naganove4f1f632016-08-31 11:35:10 -070072
73 // Creates and opens the audio hardware input stream. The stream is closed
74 // by releasing all references to the returned object.
Mikhail Naganov1dc98672016-08-18 17:50:29 -070075 virtual status_t openInputStream(
76 audio_io_handle_t handle,
77 audio_devices_t devices,
78 struct audio_config *config,
79 audio_input_flags_t flags,
80 const char *address,
81 audio_source_t source,
82 sp<StreamInHalInterface> *inStream);
Mikhail Naganove4f1f632016-08-31 11:35:10 -070083
Mikhail Naganov9ee05402016-10-13 15:58:17 -070084 // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
85 virtual status_t supportsAudioPatches(bool *supportsPatches);
86
Mikhail Naganove4f1f632016-08-31 11:35:10 -070087 // Creates an audio patch between several source and sink ports.
88 virtual status_t createAudioPatch(
89 unsigned int num_sources,
90 const struct audio_port_config *sources,
91 unsigned int num_sinks,
92 const struct audio_port_config *sinks,
93 audio_patch_handle_t *patch);
94
95 // Releases an audio patch.
96 virtual status_t releaseAudioPatch(audio_patch_handle_t patch);
97
98 // Fills the list of supported attributes for a given audio port.
99 virtual status_t getAudioPort(struct audio_port *port);
100
101 // Set audio port configuration.
102 virtual status_t setAudioPortConfig(const struct audio_port_config *config);
103
jiabin9ff780e2018-03-19 18:19:52 -0700104 // List microphones
105 virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones);
106
Mikhail Naganove4f1f632016-08-31 11:35:10 -0700107 virtual status_t dump(int fd);
108
Mikhail Naganov1dc98672016-08-18 17:50:29 -0700109 void closeOutputStream(struct audio_stream_out *stream_out);
110 void closeInputStream(struct audio_stream_in *stream_in);
Mikhail Naganove4f1f632016-08-31 11:35:10 -0700111
112 private:
113 audio_hw_device_t *mDev;
114
115 friend class DevicesFactoryHalLocal;
116
117 // Can not be constructed directly by clients.
118 explicit DeviceHalLocal(audio_hw_device_t *dev);
Mikhail Naganov1dc98672016-08-18 17:50:29 -0700119
120 // The destructor automatically closes the device.
121 virtual ~DeviceHalLocal();
Mikhail Naganov9ee05402016-10-13 15:58:17 -0700122
123 uint32_t version() const { return mDev->common.version; }
Mikhail Naganove4f1f632016-08-31 11:35:10 -0700124};
125
Kevin Rocarddf9b4202018-05-10 19:56:08 -0700126} // namespace V2_0
Mikhail Naganove4f1f632016-08-31 11:35:10 -0700127} // namespace android
128
129#endif // ANDROID_HARDWARE_DEVICE_HAL_LOCAL_H