Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
         
       
     
  
  
  
  
  
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  audio_hw_device Struct Reference
 
  
   #include <
   
    audio.h
   
   >
  
 
 
  
   |  | 
  
   | struct
    
     hw_device_t | common | 
  
   |  | 
  
   | uint32_t(* | get_supported_devices
    
    )(const struct
    
     audio_hw_device
    
    *dev) | 
  
   |  | 
  
   | int(* | init_check
    
    )(const struct
    
     audio_hw_device
    
    *dev) | 
  
   |  | 
  
   | int(* | set_voice_volume
    
    )(struct
    
     audio_hw_device
    
    *dev, float volume) | 
  
   |  | 
  
   | int(* | set_master_volume
    
    )(struct
    
     audio_hw_device
    
    *dev, float volume) | 
  
   |  | 
  
   | int(* | get_master_volume
    
    )(struct
    
     audio_hw_device
    
    *dev, float *volume) | 
  
   |  | 
  
   | int(* | set_mode
    
    )(struct
    
     audio_hw_device
    
    *dev, audio_mode_t mode) | 
  
   |  | 
  
   | int(* | set_mic_mute
    
    )(struct
    
     audio_hw_device
    
    *dev, bool state) | 
  
   |  | 
  
   | int(* | get_mic_mute
    
    )(const struct
    
     audio_hw_device
    
    *dev, bool *state) | 
  
   |  | 
  
   | int(* | set_parameters
    
    )(struct
    
     audio_hw_device
    
    *dev, const char *kv_pairs) | 
  
   |  | 
  
   | char *(* | get_parameters
    
    )(const struct
    
     audio_hw_device
    
    *dev, const char *keys) | 
  
   |  | 
  
   | size_t(* | get_input_buffer_size
    
    )(const struct
    
     audio_hw_device
    
    *dev, const struct audio_config *config) | 
  
   |  | 
  
   | int(* | open_output_stream
    
    )(struct
    
     audio_hw_device
    
    *dev, audio_io_handle_t handle, audio_devices_t devices, audio_output_flags_t flags, struct audio_config *config, struct
    
     audio_stream_out
    
    **stream_out, const char *address) | 
  
   |  | 
  
   | void(* | close_output_stream
    
    )(struct
    
     audio_hw_device
    
    *dev, struct
    
     audio_stream_out
    
    *stream_out) | 
  
   |  | 
  
   | int(* | open_input_stream
    
    )(struct
    
     audio_hw_device
    
    *dev, audio_io_handle_t handle, audio_devices_t devices, struct audio_config *config, struct
    
     audio_stream_in
    
    **stream_in, audio_input_flags_t flags, const char *address, audio_source_t source) | 
  
   |  | 
  
   | void(* | close_input_stream
    
    )(struct
    
     audio_hw_device
    
    *dev, struct
    
     audio_stream_in
    
    *stream_in) | 
  
   |  | 
  
   | int(* | dump
    
    )(const struct
    
     audio_hw_device
    
    *dev, int fd) | 
  
   |  | 
  
   | int(* | set_master_mute
    
    )(struct
    
     audio_hw_device
    
    *dev, bool mute) | 
  
   |  | 
  
   | int(* | get_master_mute
    
    )(struct
    
     audio_hw_device
    
    *dev, bool *mute) | 
  
   |  | 
  
   | int(* | create_audio_patch
    
    )(struct
    
     audio_hw_device
    
    *dev, unsigned int num_sources, const struct audio_port_config *sources, unsigned int num_sinks, const struct audio_port_config *sinks, audio_patch_handle_t *handle) | 
  
   |  | 
  
   | int(* | release_audio_patch
    
    )(struct
    
     audio_hw_device
    
    *dev, audio_patch_handle_t handle) | 
  
   |  | 
  
   | int(* | get_audio_port
    
    )(struct
    
     audio_hw_device
    
    *dev, struct audio_port *port) | 
  
   |  | 
  
   | int(* | set_audio_port_config
    
    )(struct
    
     audio_hw_device
    
    *dev, const struct audio_port_config *config) | 
  
   |  | 
 
 
 
 
 
  
   Definition at line
   
    516
   
   of file
   
    audio.h
   
   .
  
  
 
 
 
 
 
 
 
 
 
 
 
 
 
  
   
    
     | int(* create_audio_patch)(struct
      
       audio_hw_device
      
      *dev, unsigned int num_sources, const struct audio_port_config *sources, unsigned int num_sinks, const struct audio_port_config *sinks, audio_patch_handle_t *handle) | 
   
   
  
   
    Routing control
   
   
    Definition at line
    
     648
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
  
  
   
    This method dumps the state of the audio hardware
   
   
    Definition at line
    
     624
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
  
   
    
     | int(* get_audio_port)(struct
      
       audio_hw_device
      
      *dev, struct audio_port *port) | 
   
   
  
  
 
 
 
  
   
    
     | size_t(* get_input_buffer_size)(const struct
      
       audio_hw_device
      
      *dev, const struct audio_config *config) | 
   
   
  
  
 
 
 
  
  
   
    Get the current master mute status for the HAL, if the HAL supports master mute control. AudioFlinger will query this value from the primary audio HAL when the service starts and use the value for setting the initial master mute across all HALs. HALs which do not support this method may leave it set to NULL.
   
   
    Definition at line
    
     639
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
  
  
   
    Get the current master volume value for the HAL, if the HAL supports master volume control. AudioFlinger will query this value from the primary audio HAL when the service starts and use the value for setting the initial master volume across all HALs. HALs which do not support this method may leave it set to NULL.
   
   
    Definition at line
    
     561
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
 
 
 
  
   
    
     | char*(* get_parameters)(const struct
      
       audio_hw_device
      
      *dev, const char *keys) | 
   
   
  
  
 
 
 
  
  
   
    used by audio flinger to enumerate what devices are supported by each
    
     audio_hw_device
    
    implementation.
   
   
    Return value is a bitmask of 1 or more values of audio_devices_t
   
   
    NOTE: audio HAL implementations starting with AUDIO_DEVICE_API_VERSION_2_0 do not implement this function. All supported devices should be listed in audio_policy.conf file and the audio policy manager must choose the appropriate audio module based on information in this file.
   
   
    Definition at line
    
     536
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
  
  
   
    check to see if the audio hardware interface has been initialized. returns 0 on success, -ENODEV on failure.
   
   
    Definition at line
    
     542
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
  
   
    
     | int(* open_input_stream)(struct
      
       audio_hw_device
      
      *dev, audio_io_handle_t handle, audio_devices_t devices, struct audio_config *config, struct
      
       audio_stream_in
      
      **stream_in, audio_input_flags_t flags, const char *address, audio_source_t source) | 
   
   
  
   
    This method creates and opens the audio hardware input stream
   
   
    Definition at line
    
     611
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
  
   
    
     | int(* open_output_stream)(struct
      
       audio_hw_device
      
      *dev, audio_io_handle_t handle, audio_devices_t devices, audio_output_flags_t flags, struct audio_config *config, struct
      
       audio_stream_out
      
      **stream_out, const char *address) | 
   
   
  
   
    This method creates and opens the audio hardware output stream. The "address" parameter qualifies the "devices" audio device type if needed. The format format depends on the device type:
   
   
    - 
     Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC"
    
- 
     USB devices use the ALSA card and device numbers in the form "card=X;device=Y"
    
- 
     Other devices may use a number or any other string.
    
    Definition at line
    
     599
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
  
   
    
     | int(* release_audio_patch)(struct
      
       audio_hw_device
      
      *dev, audio_patch_handle_t handle) | 
   
   
  
  
 
 
 
  
   
    
     | int(* set_audio_port_config)(struct
      
       audio_hw_device
      
      *dev, const struct audio_port_config *config) | 
   
   
  
  
 
 
 
  
  
   
    set the audio mute status for all audio activities. If any value other than 0 is returned, the software mixer will emulate this capability.
   
   
    Definition at line
    
     630
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
  
  
   
    set the audio volume for all audio activities other than voice call. Range between 0.0 and 1.0. If any value other than 0 is returned, the software mixer will emulate this capability.
   
   
    Definition at line
    
     552
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
 
 
 
  
  
   
    set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is playing, and AUDIO_MODE_IN_CALL when a call is in progress.
   
   
    Definition at line
    
     568
    
    of file
    
     audio.h
    
    .
   
   
  
 
 
 
 
 
 
  
  
   
    set the audio volume of a voice call. Range is between 0.0 and 1.0
   
   
    Definition at line
    
     545
    
    of file
    
     audio.h
    
    .
   
   
  
 
 The documentation for this struct was generated from the following file:
 
  - 
   hardware/libhardware/include/hardware/
   
    audio.h
   
  
 
 
  
  
 
  
    
    
      
    
    
  
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2019-10-02 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2019-10-02 UTC."],[],[]]