Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 1 | /* |
| 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 Naganov | cbc8f61 | 2016-10-11 18:05:13 -0700 | [diff] [blame] | 20 | #include <hardware/audio.h> |
Mikhail Naganov | a0c9133 | 2016-09-19 10:01:12 -0700 | [diff] [blame] | 21 | #include <media/audiohal/DeviceHalInterface.h> |
Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | class DeviceHalLocal : public DeviceHalInterface |
| 26 | { |
| 27 | public: |
Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 28 | // 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 Naganov | 1dc9867 | 2016-08-18 17:50:29 -0700 | [diff] [blame] | 67 | 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 Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 74 | |
| 75 | // Creates and opens the audio hardware input stream. The stream is closed |
| 76 | // by releasing all references to the returned object. |
Mikhail Naganov | 1dc9867 | 2016-08-18 17:50:29 -0700 | [diff] [blame] | 77 | 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 Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 85 | |
| 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 Naganov | 1dc9867 | 2016-08-18 17:50:29 -0700 | [diff] [blame] | 105 | void closeOutputStream(struct audio_stream_out *stream_out); |
| 106 | void closeInputStream(struct audio_stream_in *stream_in); |
Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 107 | |
| 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 Naganov | 1dc9867 | 2016-08-18 17:50:29 -0700 | [diff] [blame] | 115 | |
| 116 | // The destructor automatically closes the device. |
| 117 | virtual ~DeviceHalLocal(); |
Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | } // namespace android |
| 121 | |
| 122 | #endif // ANDROID_HARDWARE_DEVICE_HAL_LOCAL_H |