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_HIDL_H 18#define ANDROID_HARDWARE_DEVICE_HAL_HIDL_H 19 20#include <android/hardware/audio/2.0/IDevice.h> 21#include <media/audiohal/DeviceHalInterface.h> 22 23#include "ConversionHelperHidl.h" 24 25using ::android::hardware::audio::V2_0::IDevice; 26using ::android::hardware::Return; 27 28namespace android { 29 30class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl 31{ 32 public: 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); 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 virtual status_t openOutputStream( 70 audio_io_handle_t handle, 71 audio_devices_t devices, 72 audio_output_flags_t flags, 73 struct audio_config *config, 74 const char *address, 75 sp<StreamOutHalInterface> *outStream); 76 77 // Creates and opens the audio hardware input stream. The stream is closed 78 // by releasing all references to the returned object. 79 virtual status_t openInputStream( 80 audio_io_handle_t handle, 81 audio_devices_t devices, 82 struct audio_config *config, 83 audio_input_flags_t flags, 84 const char *address, 85 audio_source_t source, 86 sp<StreamInHalInterface> *inStream); 87 88 // Returns whether createAudioPatch and releaseAudioPatch operations are supported. 89 virtual status_t supportsAudioPatches(bool *supportsPatches); 90 91 // Creates an audio patch between several source and sink ports. 92 virtual status_t createAudioPatch( 93 unsigned int num_sources, 94 const struct audio_port_config *sources, 95 unsigned int num_sinks, 96 const struct audio_port_config *sinks, 97 audio_patch_handle_t *patch); 98 99 // Releases an audio patch. 100 virtual status_t releaseAudioPatch(audio_patch_handle_t patch); 101 102 // Fills the list of supported attributes for a given audio port. 103 virtual status_t getAudioPort(struct audio_port *port); 104 105 // Set audio port configuration. 106 virtual status_t setAudioPortConfig(const struct audio_port_config *config); 107 108 virtual status_t dump(int fd); 109 110 private: 111 friend class DevicesFactoryHalHidl; 112 sp<IDevice> mDevice; 113 114 // Can not be constructed directly by clients. 115 explicit DeviceHalHidl(const sp<IDevice>& device); 116 117 // The destructor automatically closes the device. 118 virtual ~DeviceHalHidl(); 119}; 120 121} // namespace android 122 123#endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_H 124