2

I am using Android 4.2.2 on Qualcomm APQ8064 Chip set. I want to enable audio output to the USB headset. I tried using aplay command but no luck. The driver for usb-audio is already there in the code. Everything is integrated but i don't get any output on the usb-headset. Any flags that need to be set?? Any lead will be of great help.

@Micheal:Following are the logs for the same, I just noticed that below logs from AudioUsbALSA can also be seen when the USB headset is not connected.

3502:I/InputReader(  676): Device added: id=8, name='Logitech Inc. Logitech USB Headset H340', sources=0x00000501
3504:D/StatusBar.NetworkController(  769): refreshViews: Data not connected!! Set no data type icon / Roaming
3505:D/StatusBar.NetworkController(  769): refreshViews connected={ } level=?? combinedSignalIconId=0x7f02013d/com.android.systemui:drawable/stat_sys_signal_null combinedActivityIconId=0x0 mobileLabel=No Internet connection wifiLabel= emergencyOnly=false combinedLabel=No Internet connection mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f02013d mQSPhoneSignalIconId=0x7f020073 mDataDirectionIconId=0x0 mDataSignalIconId=0x7f02013d mDataTypeIconId=0x0 mQSDataTypeIconId=0x0 mNoSimIconId=0x0 mWifiIconId=0x0 mQSWifiIconId=0x0 mBluetoothTetherIconId=0x1080563
3600:V/PhoneStatusBar(  769): setLightsOn(true)
3627:V/AudioHardwareALSA(  272): closeUsbPlaybackIfNothingActive, musbPlaybackState: 0
3628:D/AudioUsbALSA(  272): exitPlaybackThread, mproxypfdPlayback: -1
3629:D/AudioUsbALSA(  272): closeDevice handle 0x0
3630:D/AudioUsbALSA(  272): closeDevice handle 0x0
3710:V/PhoneStatusBar(  769): setLightsOn(true)
3730:V/AudioHardwareALSA(  272): closeUsbPlaybackIfNothingActive, musbPlaybackState: 0
3731:D/AudioUsbALSA(  272): exitPlaybackThread, mproxypfdPlayback: -1
3732:D/AudioUsbALSA(  272): closeDevice handle 0x0
3733:D/AudioUsbALSA(  272): closeDevice handle 0x0
Nirmal
  • 41
  • 1
  • 8
  • Which code base are you building from? Something from the CodeAurora Forums? Qualcomm uses `DEVICE_OUT_ANLG_DOCK_HEADSET` for device-mode USB headsets IIRC. Have you checked if you get a `setDeviceConnectionState` for that device in `AudioPolicyManagerALSA` ? – Michael Mar 24 '14 at 08:50
  • Is `QCOM_USBAUDIO_ENABLED` set when you build the audio.primary module (i.e. does the code in `AudioUsbALSA` ever run)? Have you tried manipulating the volume for the USB ALSA card? (sometimes the default volume is really low; I've run into this myself). – Michael Mar 24 '14 at 13:26
  • @Micheal: I am using code from CodeAurora Forums. Yes when I plug in the USB Headset I get the following logs : E/AudioPolicyManagerALSA(287):setDeviceConnectionState() device: 800,state 1,address E/AudioPolicyManagerALSA(287):setDeviceConnectionState() connecting device 800 W/AudioPolicyManagerALSA(287):checkOutputsForDevice() could not open output for device 800 – Nirmal Mar 24 '14 at 13:26
  • W/AudioPolicyManagerALSA(287):checkOutputsForDevice() could not open output for device 800 W/AudioPolicyManagerALSA(287):checkOutputsForDevice() could not open output for device 800 E/AudioPolicyManagerALSA(287):setDeviceConnectionState() checkOutputsForDevice() returned 2 outputs – Nirmal Mar 24 '14 at 13:27
  • 1
    Is `AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET` enabled for any output in your `audio_policy.conf` file? – Michael Mar 24 '14 at 13:30
  • @Micheal: Will try putting some logs in AudioUsbALSA and check if the file is actually executed during run-time or not. Yes QCOM_USBAUDIO_ENABLED and AudioUsbALSA are included in the .mk file. How do I manipulate the volume for USB ALSA card. Thanks for the guidance. – Nirmal Mar 24 '14 at 13:36
  • You should be able to list the available ALSA controls and write to them using the `alsa_mixer` utility (you may have to build alsa_mixer yourself). I don't remember the exact syntax off the top of my head since it's been a while since I worked with this stuff. – Michael Mar 24 '14 at 13:41
  • @Micheal:Yes AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET as well as AUDIO_DEVICE_OUT_ALL_USB is there in audio_policy.conf. – Nirmal Mar 24 '14 at 13:43
  • @Michael:I just checked the usb mixer settings and following is the observation: /proc/asound/card0/usbmixer USB Mixer: usb_id=0x046d0a38, ctrlif=0, ctlerr=0 Card: Logitech Inc. Logitech USB Headset H340 at usb-msm_ehci_host.1-1.1, full speed Unit: 5 Control: name="PCM Playback Volume", index=0 Info: id=5, control=2, cmask=0x3, channels=2, type="S16" Volume: min=-10496, max=768, dBmin=-4100, dBmax=300 Unit: 5 Control: name="PCM Playback Switch", index=0 Info: id=5, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN" Volume: min=0, max=1, dBmin=0, dBmax=0 – Nirmal Mar 25 '14 at 04:52
  • I am using the following command: 'aplay -D hw:0,0 -V -C1 -R44100 -FS16_LE /data/test_mono_44100Hz_16bit_PCM.wav' Result: Aplay:aplay: cannot open '/data/test_mono_44100Hz_16bit' 'cat /proc/asound/card0/stream0 Logitech Inc. Logitech USB Headset H340 at usb-msm_ehci_host.1-1.1, full speed : USB Audio Playback: Status: Stop Interface 1 Altset 1 Format: S16_LE Channels: 2 Endpoint: 1 OUT (ASYNC) Rates: 44100 Capture: Status: Stop Interface 2 Altset 1 Format: S16_LE Channels: 2 Endpoint: 1 IN (ASYNC) Rates: 44100' – Nirmal Mar 25 '14 at 09:36
  • `aplay` apparently can't find the audio file: _"aplay: cannot open '/data/test_mono_44100Hz_16bit' "_ – Michael Mar 25 '14 at 09:40
  • @Michael:Yes that's what is bugging me, the file is very much present and I have played it through UI and it plays fine on the HDMI. – Nirmal Mar 25 '14 at 09:49
  • Apparently Qualcomm's `aplay` has a 30-character limit for the filename(!) (see https://www.codeaurora.org/cgit/quic/la/platform/hardware/qcom/audio/tree/libalsa-intf/aplay.c?h=jb_mr1#n918). So you'll have to use a shorter name. – Michael Mar 25 '14 at 09:52
  • @Michael: I was successful in playing a wave file using the following command: "'aplay -D hw:1,0 -V -C2 -R44100 -FS16_LE /data/t_st_44100Hz_16bit_.wav'" But what I understand, by using aplay command I am bypassing stagefright(android) and directly playing from ALSA, now i want to implement usb output in my code so that instead of output coming from speaker it comes through the USB HeadSet. I am trying to explore on this, but any help from your end would be really great. – Nirmal Mar 26 '14 at 03:21
  • The first step would probably be to add some logs in `AudioUsbALSA`, `AudioHardwareALSA` and `AlsaDevice` to make sure that the USB playback code is running, that the correct ALSA UCM file has been loaded, etc. – Michael Mar 26 '14 at 07:07
  • @Michael:Sorry for such a late reply... I have put logs in the files you specified, I am able to see these files in the logcat as well. – Nirmal Apr 04 '14 at 03:59

0 Answers0