blob: eba360c81d319208bbeeaacdb75a067a6099d396 [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 {
24
25class DeviceHalLocal : public DeviceHalInterface
26{
27 public:
Mikhail Naganove4f1f632016-08-31 11:35:10 -070028 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
29 virtual status_t getSupportedDevices(uint32_t *devices);
30
31 // Get the hardware module version.
32 virtual status_t getVersion(uint32_t *version);
33
34 // Check to see if the audio hardware interface has been initialized.
35 virtual status_t initCheck();
36
37 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
38 virtual status_t setVoiceVolume(float volume);
39
40 // Set the audio volume for all audio activities other than voice call.
41 virtual status_t setMasterVolume(float volume);
42
43 // Get the current master volume value for the HAL.
44 virtual status_t getMasterVolume(float *volume);
45
46 // Called when the audio mode changes.
47 virtual status_t setMode(audio_mode_t mode);
48
49 // Muting control.
50 virtual status_t setMicMute(bool state);
51 virtual status_t getMicMute(bool *state);
52 virtual status_t setMasterMute(bool state);
53 virtual status_t getMasterMute(bool *state);
54
55 // Set global audio parameters.
56 virtual status_t setParameters(const String8& kvPairs);
57
58 // Get global audio parameters.
59 virtual status_t getParameters(const String8& keys, String8 *values);
60
61 // Returns audio input buffer size according to parameters passed.
62 virtual status_t getInputBufferSize(const struct audio_config *config,
63 size_t *size);
64
65 // Creates and opens the audio hardware output stream. The stream is closed
66 // by releasing all references to the returned object.
Mikhail Naganov1dc98672016-08-18 17:50:29 -070067 virtual status_t openOutputStream(
68 audio_io_handle_t handle,
69 audio_devices_t devices,
70 audio_output_flags_t flags,
71 struct audio_config *config,
72 const char *address,
73 sp<StreamOutHalInterface> *outStream);
Mikhail Naganove4f1f632016-08-31 11:35:10 -070074
75 // Creates and opens the audio hardware input stream. The stream is closed
76 // by releasing all references to the returned object.
Mikhail Naganov1dc98672016-08-18 17:50:29 -070077 virtual status_t openInputStream(
78 audio_io_handle_t handle,
79 audio_devices_t devices,
80 struct audio_config *config,
81 audio_input_flags_t flags,
82 const char *address,
83 audio_source_t source,
84 sp<StreamInHalInterface> *inStream);
Mikhail Naganove4f1f632016-08-31 11:35:10 -070085
86 // Creates an audio patch between several source and sink ports.
87 virtual status_t createAudioPatch(
88 unsigned int num_sources,
89 const struct audio_port_config *sources,
90 unsigned int num_sinks,
91 const struct audio_port_config *sinks,
92 audio_patch_handle_t *patch);
93
94 // Releases an audio patch.
95 virtual status_t releaseAudioPatch(audio_patch_handle_t patch);
96
97 // Fills the list of supported attributes for a given audio port.
98 virtual status_t getAudioPort(struct audio_port *port);
99
100 // Set audio port configuration.
101 virtual status_t setAudioPortConfig(const struct audio_port_config *config);
102
103 virtual status_t dump(int fd);
104
Mikhail Naganov1dc98672016-08-18 17:50:29 -0700105 void closeOutputStream(struct audio_stream_out *stream_out);
106 void closeInputStream(struct audio_stream_in *stream_in);
Mikhail Naganove4f1f632016-08-31 11:35:10 -0700107
108 private:
109 audio_hw_device_t *mDev;
110
111 friend class DevicesFactoryHalLocal;
112
113 // Can not be constructed directly by clients.
114 explicit DeviceHalLocal(audio_hw_device_t *dev);
Mikhail Naganov1dc98672016-08-18 17:50:29 -0700115
116 // The destructor automatically closes the device.
117 virtual ~DeviceHalLocal();
Mikhail Naganove4f1f632016-08-31 11:35:10 -0700118};
119
120} // namespace android
121
122#endif // ANDROID_HARDWARE_DEVICE_HAL_LOCAL_H