[alsa-devel] Getting pcm_usb_stream plugin to know its limits.

Michaël Cadilhac michael at cadilhac.name
Wed Dec 30 18:48:22 CET 2009


Hi there everyone,

I've been fighting for a few hours with a USB sound device (namely,
Tascam US-144), to get it to work with Audacity (this not being the
relevant part).

At first, Audacity died in a painful segfault, without any explanation,
when associated with the usb_stream plugin[1]. 

Audacity uses PortAudio, which checks for a few possible parameters of
audio rate to find the list of accepted ones.  It tries to set a
parameter (snd_pcm_hw_params), and if it fails, closes the device, and
continues its way.

Suppose the `prepare` act of the usb_stream is aborted because of wrong
parameters.  Then, PortAudio tries to close the device, by calling
snd_pcm_close.  This in turn calls snd_pcm_drop, which calls the fast_op
drop (that of ioplug), which is snd_pcm_ioplug_drop, which then calls
the *stop* callback of the usb_stream (snd_pcm_us_stop).  The stream not
being properly initialized, us->uus->write_area is nil, and the memset
fails.

This is the modification I did for that purpose :

-------------- next part --------------
A non-text attachment was scrubbed...
Name: memset.patch
Type: text/x-patch
Size: 392 bytes
Desc: not available
Url : http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20091230/3d58a7a3/attachment.patch 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: period_size.patch
Type: text/x-patch
Size: 511 bytes
Desc: not available
Url : http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20091230/3d58a7a3/attachment-0001.patch 
-------------- next part --------------


Well, that's all folks.  Happy new year to everyone.

Footnotes: 
[1]  Configured as
pcm.!usb_stream {
	type usb_stream
	card "1"
}
which works with a fine-tuned aplay.


[2]  linux/sound/usb/usx2y/us122l.c

-- 
Michaël `Micha' Cadilhac (LITQ, U. de Montréal) -- http://michael.cadilhac.name
	|| La culture, c'est comme l'amour.
	||  Faut y aller à petits coups au début pour bien en jouir plus tard.
	||         -- Pierre Desproges


More information about the Alsa-devel mailing list