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