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