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