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_INTERFACE_H |
| 18 | #define ANDROID_HARDWARE_DEVICE_HAL_INTERFACE_H |
| 19 | |
| 20 | #include <hardware/audio.h> |
| 21 | #include <utils/Errors.h> |
| 22 | #include <utils/RefBase.h> |
| 23 | #include <utils/String8.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | class DeviceHalInterface : public RefBase |
| 28 | { |
| 29 | public: |
| 30 | // The destructor automatically closes the device. |
| 31 | virtual ~DeviceHalInterface() {} |
| 32 | |
| 33 | // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t. |
| 34 | virtual status_t getSupportedDevices(uint32_t *devices) = 0; |
| 35 | |
| 36 | // Get the hardware module version. |
| 37 | virtual status_t getVersion(uint32_t *version) = 0; |
| 38 | |
| 39 | // Check to see if the audio hardware interface has been initialized. |
| 40 | virtual status_t initCheck() = 0; |
| 41 | |
| 42 | // Set the audio volume of a voice call. Range is between 0.0 and 1.0. |
| 43 | virtual status_t setVoiceVolume(float volume) = 0; |
| 44 | |
| 45 | // Set the audio volume for all audio activities other than voice call. |
| 46 | virtual status_t setMasterVolume(float volume) = 0; |
| 47 | |
| 48 | // Get the current master volume value for the HAL. |
| 49 | virtual status_t getMasterVolume(float *volume) = 0; |
| 50 | |
| 51 | // Called when the audio mode changes. |
| 52 | virtual status_t setMode(audio_mode_t mode) = 0; |
| 53 | |
| 54 | // Muting control. |
| 55 | virtual status_t setMicMute(bool state) = 0; |
| 56 | virtual status_t getMicMute(bool *state) = 0; |
| 57 | virtual status_t setMasterMute(bool state) = 0; |
| 58 | virtual status_t getMasterMute(bool *state) = 0; |
| 59 | |
| 60 | // Set global audio parameters. |
| 61 | virtual status_t setParameters(const String8& kvPairs) = 0; |
| 62 | |
| 63 | // Get global audio parameters. |
| 64 | virtual status_t getParameters(const String8& keys, String8 *values) = 0; |
| 65 | |
| 66 | // Returns audio input buffer size according to parameters passed. |
| 67 | virtual status_t getInputBufferSize(const struct audio_config *config, |
| 68 | size_t *size) = 0; |
| 69 | |
| 70 | // Creates and opens the audio hardware output stream. The stream is closed |
| 71 | // by releasing all references to the returned object. |
| 72 | // FIXME: Enable when StreamOutHalInterface is introduced. |
| 73 | // virtual status_t openOutputStream( |
| 74 | // audio_io_handle_t handle, |
| 75 | // audio_devices_t devices, |
| 76 | // audio_output_flags_t flags, |
| 77 | // struct audio_config *config, |
| 78 | // const char *address, |
| 79 | // sp<StreamOutHalInterface> *outStream) = 0; |
| 80 | |
| 81 | // Creates and opens the audio hardware input stream. The stream is closed |
| 82 | // by releasing all references to the returned object. |
| 83 | // FIXME: Enable when StreamInHalInterface is introduced. |
| 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) = 0; |
| 92 | |
| 93 | // Creates an audio patch between several source and sink ports. |
| 94 | virtual status_t createAudioPatch( |
| 95 | unsigned int num_sources, |
| 96 | const struct audio_port_config *sources, |
| 97 | unsigned int num_sinks, |
| 98 | const struct audio_port_config *sinks, |
| 99 | audio_patch_handle_t *patch) = 0; |
| 100 | |
| 101 | // Releases an audio patch. |
| 102 | virtual status_t releaseAudioPatch(audio_patch_handle_t patch) = 0; |
| 103 | |
| 104 | // Fills the list of supported attributes for a given audio port. |
| 105 | virtual status_t getAudioPort(struct audio_port *port) = 0; |
| 106 | |
| 107 | // Set audio port configuration. |
| 108 | virtual status_t setAudioPortConfig(const struct audio_port_config *config) = 0; |
| 109 | |
| 110 | virtual status_t dump(int fd) = 0; |
| 111 | |
| 112 | protected: |
| 113 | // Subclasses can not be constructed directly by clients. |
| 114 | DeviceHalInterface() {} |
| 115 | }; |
| 116 | |
| 117 | } // namespace android |
| 118 | |
| 119 | #endif // ANDROID_HARDWARE_DEVICE_HAL_INTERFACE_H |