New audio HAL not working with Nexus player

0

Android opens my Audio HAL's input stream and then immediately closes it. Please help me figure out what's missing.

Background

This is in continuation to work on Nexus 7 tablet discussed in a previous question here I was able to successfully load vloop audio hal into Nexus 7 and read and write audio to it.

Info on current issue:

On boot, or on connecting inbuilt mic (by calling setDeviceConnectionState) I observe that input stream is opened, some parameters are read, and then inpuit stream is promptly closed.

Google/Youtube are not able to read audio from my HAL after this.

Following are my trace logs:

11-07 14:05:10.321 277-1263/? E/ATVAudioPolicyManager: setDeviceConnectionState 80000004 1 0
11-07 14:05:10.321 277-1263/? D/audio_vloop: adev_open_input_stream(): 1546
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_sample_rate(): 1008
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_sample_rate(): samprate: 48000
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_channels(): 1047
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_channels: 0x0000000C
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_format(): 1059
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_format: 0x00000001
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_format(): 1059
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_format: 0x00000001
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_channels(): 1047
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_channels: 0x0000000C
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_buffer_size(): 1035
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_buffer_size: 4800
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_buffer_size(): 1035
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_buffer_size: 4800
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_format(): 1059
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_format: 0x00000001
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_sample_rate(): 1008
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_sample_rate(): samprate: 48000
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_channels(): 1047
11-07 14:05:10.322 277-1263/? D/audio_vloop: in_get_channels: 0x0000000C
11-07 14:05:10.323 277-2820/? I/AudioFlinger: AudioFlinger's thread 0xf314f008 ready to run
11-07 14:05:10.323 277-2820/? D/audio_vloop: in_standby(): 1089
11-07 14:05:10.323 277-2819/? D/audio_vloop: looper_in_thread(): 218: Entered
11-07 14:05:10.324 277-2820/? D/audio_vloop: in_standby(): 1089
11-07 14:05:10.325 277-2820/? D/audio_vloop: in_set_parameters(): 1150: [0]
11-07 14:05:10.325 277-369/? D/audio_vloop: adev_set_parameters(): [0=;connect=-2147483644]
11-07 14:05:10.327 277-1263/? D/audio_vloop: adev_close_input_stream(): 1638
11-07 14:05:10.327 2781-2781/? D/AudioPlayer: ConnectLineIn(): 0

These are just trace logs that tell what was called, and in some cases, what I returned. I return success for all these functions to Android.

In audio_policy.conf, I added this:

global_configuration {
  attached_output_devices AUDIO_DEVICE_OUT_SPEAKER
  default_output_device AUDIO_DEVICE_OUT_SPEAKER
  attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX
}

and

  vloop {
    inputs {
      vloop {
        sampling_rates 48000
        channel_masks AUDIO_CHANNEL_IN_STEREO
        formats AUDIO_FORMAT_PCM_16_BIT
        devices AUDIO_DEVICE_IN_BUILTIN_MIC
      }
    }
    outputs {
      vloop {
        sampling_rates 48000
        channel_masks AUDIO_CHANNEL_OUT_STEREO
        formats AUDIO_FORMAT_PCM_16_BIT
        devices AUDIO_DEVICE_OUT_LINE
      }
    }
  }
android
audio
android-source
hal
asked on Stack Overflow Nov 7, 2016 by GPS • edited May 23, 2017 by Community

1 Answer

1

I realized this was an issue outside my code/conf, so primary suspect was Audio Policy Manager (APM).

I went thorough APM code, and found no unusual issues there.. then I realized I actually got confused by USE_CUSTOM_AUDIO_POLICY flag in device.mk in fugu folder. This flag disables default APM and enables Qualcomm APM. (searching trough the source)

Took some time to realize that fugu's APM is not Qualcomm APM, but it sits in /device/asus/fugu/libaudio/

Modified ATVAudioPolicyManager.cpp here to fix the issue.

Modification is as follows:

in function

audio_devices_t ATVAudioPolicyManager::getDeviceForInputSource(audio_source_t inputSource)

Add following to condition:

else if (availableDeviceTypes & AUDIO_DEVICE_IN_BUILTIN_MIC) {
          ALOGV("Use Builtin mic input");
          device = AUDIO_DEVICE_IN_BUILTIN_MIC;
}
answered on Stack Overflow Dec 12, 2016 by GPS

User contributions licensed under CC BY-SA 3.0