av2kk
Posts: 21
Joined: Tue Jul 17, 2012 11:01 am

usb audio works only after reinserting after boot

Tue Aug 28, 2012 7:37 am

Hello,
I am using a generic USB sound card (Quantum). The card is detected correctly on boot and aplay -l shows it.
But when I try to play a .wav file
aplay -D plughw:1,0 WELCOME.wav
it takes a while and prints out a lot of data about the file and one of the lines is
aplay: set_params:1145: unable to install hw params:
and there is no sound from the usb sound card.

Now if I remove the USB sound card and reinsert it, everything works OK.
This is a problem as the application has to work from power on unattended.

What could be wrong?

My OS Debian Wheezy 16-7-2012 .
I tried
apt-get update
apt-get install alsa-utils -> this says everything is uptodate

Thanks for any help.

av2kk
Posts: 21
Joined: Tue Jul 17, 2012 11:01 am

Re: usb audio works only after reinserting after boot

Fri Sep 14, 2012 9:32 am

Update:
After help from another thread (ALSA on Raspbian) I figured out that the USB sound card works OK with only the keyboard connected. It does not work at boot time if a USB hub to which a keyboard and mouse are connected. Problem seems to be with the usb stack of the OS or something to do with loading of the 5V supply.

NielsMayer
Posts: 13
Joined: Mon Aug 13, 2012 4:25 am

Re: usb audio works only after reinserting after boot

Mon Sep 24, 2012 12:46 am

I started seeing this issue after rpi-updating to the recent overclock-friendly setup w/ the 'turbo' and 'high' modes.... e.g.

Code: Select all

rpi3-11-~> vcgencmd version
Sep 23 2012 14:52:55 
Copyright (c) 2012 Broadcom
version 338882 (release)
rpi3-12-~> uname -a
Linux rpi3 3.2.27+ #168 PREEMPT Sat Sep 22 19:26:13 BST 2012 armv6l GNU/Linux
The fix for plugging and unplugging the PS3 Eye camera did indeed enable audio. If using the system after a fresh boot w/ same webcam plugged in, you get

Code: Select all

arecord: pcm_read:1801: read error: Input/output error
After unplug/plug, I can successfully watch the audio level using:

Code: Select all

arecord -vv /dev/null -r 16000 -f S16_LE -c 4 -D iec958:CARD=CameraB409241,DEV=0 /dev/null < /dev/null
And even better after setting up ~/.asoundrc,

Code: Select all

## Suggested by http://julius.sourceforge.jp/forum/viewtopic.php?f=9&t=66
pcm.array {
  type hw
  card 1
}

pcm.array_gain {
  type softvol
  slave {
    pcm "array"
  }
  control {
    name "Mic Gain"
    count 2
  }
  min_dB -10.0
  max_dB 5.0
}

pcm.cap {
  type plug
  slave {
    pcm "array_gain"
    channels 4
  }
  route_policy sum
}
I can just record a single channel that is summed via alsa's softvol plugin

Code: Select all

## see 'pcm.cap' defined in .asoundrc which sums 4 channels from Sony PS3 Eye camera into one
arecord -vv /dev/null -D cap -r 16000 /dev/null < /dev/null
Which shows the ALSA plugins a summin' (as to whether this is more or less efficient than not summing and just recording 4 channels, TBD):

Code: Select all

Recording WAVE '/dev/null' : Unsigned 8 bit, Rate 16000 Hz, Mono
Plug PCM: Route conversion PCM (sformat=S16_LE)
  Transformation table:
    0 <- 0*0.25 + 1*0.25 + 2*0.25 + 3*0.25
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : U8
  subformat    : STD
  channels     : 1
  rate         : 16000
  exact rate   : 16000 (16000/1)
  msbits       : 8
  buffer_size  : 8000
  period_size  : 2000
  period_time  : 125000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 2000
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 8000
  silence_threshold: 0
  silence_size : 0
  boundary     : 2097152000
Slave: Soft volume PCM
Control: Mic Gain
min_dB: -10
max_dB: 5
resolution: 256
Its setup is:
  stream       : CAPTURE
  access       : MMAP_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 4
  rate         : 16000
  exact rate   : 16000 (16000/1)
  msbits       : 16
  buffer_size  : 8000
  period_size  : 2000
  period_time  : 125000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 2000
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 8000
  silence_threshold: 0
  silence_size : 0
  boundary     : 2097152000
Slave: Hardware PCM card 1 'USB Camera-B4.09.24.1' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : MMAP_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 4
  rate         : 16000
  exact rate   : 16000 (16000/1)
  msbits       : 16
  buffer_size  : 8000
  period_size  : 2000
  period_time  : 125000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 2000
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 8000
  silence_threshold: 0
  silence_size : 0
  boundary     : 2097152000
  appl_ptr     : 0
  hw_ptr       : 0
##+                                                | 02%

NielsMayer
Posts: 13
Joined: Mon Aug 13, 2012 4:25 am

Re: usb audio works only after reinserting after boot

Mon Sep 24, 2012 12:53 am

When using the arecord-based 'levelmeter' above for the PS3 Eye webcam, the kernel outputs much spew related to recording from device:

Code: Select all

rpi3-14-~> arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: CameraB409241 [USB Camera-B4.09.24.1], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
From /var/log/kern.log

Code: Select all

Sep 23 17:42:14 rpi3 kernel: [13004.461067] retire_capture_urb: 12 callbacks suppressed
Sep 23 17:42:38 rpi3 kernel: [13028.705949] retire_capture_urb: 8 callbacks suppressed
Sep 23 17:42:49 rpi3 kernel: [13040.109209] retire_capture_urb: 9 callbacks suppressed
Sep 23 17:47:08 rpi3 kernel: [13298.822208] retire_capture_urb: 6 callbacks suppressed
Sep 23 17:47:14 rpi3 kernel: [13304.380002] retire_capture_urb: 14 callbacks suppressed
Sep 23 17:47:19 rpi3 kernel: [13309.849672] retire_capture_urb: 4 callbacks suppressed
Sep 23 17:47:25 rpi3 kernel: [13315.359351] retire_capture_urb: 9 callbacks suppressed
Sep 23 17:47:30 rpi3 kernel: [13320.979042] retire_capture_urb: 1 callbacks suppressed
Sep 23 17:47:38 rpi3 kernel: [13328.582980] retire_capture_urb: 8 callbacks suppressed
Sep 23 17:47:44 rpi3 kernel: [13334.661729] retire_capture_urb: 7 callbacks suppressed
Sep 23 17:48:29 rpi3 kernel: [13379.712274] retire_capture_urb: 16 callbacks suppressed
Sep 23 17:48:34 rpi3 kernel: [13384.997928] retire_capture_urb: 4 callbacks suppressed
Sep 23 17:48:40 rpi3 kernel: [13390.761634] retire_capture_urb: 18 callbacks suppressed

NielsMayer
Posts: 13
Joined: Mon Aug 13, 2012 4:25 am

Re: usb audio works only after reinserting after boot

Mon Sep 24, 2012 12:58 am

Is the issue perhaps because the USB webcam soundcard ALSA initialization happens before the main ALSA initialization:

Code: Select all

[    3.529184] usb 1-1.3: new high-speed USB device number 5 using dwc_otg
[    3.652336] usb 1-1.3: New USB device found, idVendor=1415, idProduct=2000
[    3.668947] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    3.678678] usb 1-1.3: Product: USB Camera-B4.09.24.1
[    3.704962] usb 1-1.3: Manufacturer: OmniVision Technologies, Inc.
[    3.872892] udevd[137]: starting version 175
[    5.676431] Linux video capture interface: v2.00
[    5.961164] gspca_main: v2.14.0 registered
[    5.971003] gspca_main: ov534-2.14.0 probing 1415:2000
[    6.508209] usbcore: registered new interface driver ov534
[    6.927957] usbcore: registered new interface driver rtl8192cu
[    7.300727] usbcore: registered new interface driver snd-usb-audio
[    9.797805] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   10.350296] bcm2835 ALSA card created!
[   10.356376] bcm2835 ALSA chip created!
[   10.375779] bcm2835 ALSA chip created!
[   10.386350] bcm2835 ALSA chip created!
[   10.394391] bcm2835 ALSA chip created!
[   10.402380] bcm2835 ALSA chip created!
[   10.410214] bcm2835 ALSA chip created!
[   10.417829] bcm2835 ALSA chip created!

squark
Posts: 1
Joined: Sun Sep 23, 2012 3:47 am

Re: usb audio works only after reinserting after boot

Mon Dec 10, 2012 6:12 am

I have a similar problem capturing audio with my USB PS3 Eye camera. The camera works fine, but the audio doesn't record unless I unplug the usb connector and plug it back in. Then it magically works.

To be more specific, after a reboot,
arecord -vv -f dat -D plughw:1,0 test.wav makes a 44 byte file every time. No recoding. The -vv option is supposed to dump a lot of info and then shows a little level meter. The info appears, but the level meter never does.

After unplugging and re-plugging in the usb cable, the same command above works great. Level meter appears and works. The dumped info is identical to what I get with the command before the unplug/replug.

I've tried mucking with /etc/modules, /etc/asound.conf, resetting the USB from software, and lots more stuff all to no avail. I can't figure out how to avoid pulling the USB plug and putting it back in again.

Has anyone overcome this problem? Thanks!

jjeffus
Posts: 1
Joined: Sun Nov 10, 2013 12:57 am

Re: usb audio works only after reinserting after boot

Sun Nov 10, 2013 1:06 am

Hey guys! I'm brand new to the Pi scene and just created my account for this specific issue. I'm using a Pi to monitor noise levels using a Samson C01U microphone. I wrote a Perl script that records a second of audio using arecord then uses sox to analyze it for maximum amplitude and stores that into a SQLite database. I'm experiencing this exact issue. Namely, if I boot the device with the microphone attached then I get the error listed by other users. If I unplug/replug it then it suddenly works - but not reliably. After reading from it a few hundred times it suddenly does it again.

Code: Select all

pi@raspberrypi ~ $ arecord -d 1 -D hw:1 -c 1 -vvvv -f cd --file-type wav > file.wav
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
arecord: set_params:1145: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 44100
PERIOD_TIME: (125011 125012)
PERIOD_SIZE: 5513
PERIOD_BYTES: 22052
PERIODS: (3 4)
BUFFER_TIME: 500000
BUFFER_SIZE: 22050
BUFFER_BYTES: 88200
TICK_TIME: 0
Clearly this is a system wide issue, there are very much different audio devices. I wonder what the common ground is between these?

AndiCui
Posts: 11
Joined: Mon Jun 22, 2015 4:37 am

Re: usb audio works only after reinserting after boot

Sat May 13, 2017 5:19 pm

Four years later, this bug still exists. I am trying to make a CCTV cam with sound from usb. I sill have to reinsert to make it work.

rensa
Posts: 2
Joined: Sun Jul 02, 2017 9:41 am

Re: usb audio works only after reinserting after boot

Sun Jul 02, 2017 9:51 am

I'm having this problem with a PlayStation Eye camera as well (with a Raspberry Pi Zero W running Jessie). The mic works fine if plugged in after boot or if plugged in on boot from power off, but if I reboot the Pi with the mic plugged in, it fails (arecord never stops recording, even if a duration is specified) until I unplug and replug it. The mic is reported by alsa as an available device even when it isn't working.

I've tried resetting the USB device using https://gist.github.com/x2q/5124616, but no dice: it reports a successful reset but the mic still doesn't work. I'm tried forcing alsa to reload, but that also doesn't seem to work. Not sure where to go from here :/

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: No registered users and 11 guests