©2003 Kåre Sjölander and Jonas Beskow
Introduction Download Documentation Links Forum
WaveSurfer user forum

FAQ  FAQ
Search  Search
Memberlist  Memberlist
Register  Register
Profile  Profile
Login  Login

ALSA support in Snack ... (where to be discussed?)

 
Post new topic   Reply to topic    www.speech.kth.se/wavesurfer Forum Index -> WaveSurfer
View previous topic :: View next topic  
Author Message
ManuK



Joined: 08 Oct 2003
Posts: 5
Location: IMS, Uni Stuttgart, Germany

PostPosted: Wed Aug 04, 2004 2:34 pm    Post subject: ALSA support in Snack ... (where to be discussed?) Reply with quote

This is somewhat a double question... first, I wanted to know if it is o.k. to post questions on libSnack here, or if there are any mailinglists or forums on Snack somewhere where this should go.

ALSA support in Snack is, as the documentation itself says, still incomplete, but to me it seems to have reached a good state now. There is still a problem in Snack2.2.7, with playing on default/plughw:0 producing no sound and the playing itself not stopping. Is this already known? Someone else running into this problem?
Back to top
View users profile Send private message
kare



Joined: 16 Aug 2002
Posts: 371
Location: KTH, Centre for Speech Technology

PostPosted: Wed Aug 04, 2004 7:28 pm    Post subject: Reply with quote

It's fine to post questions on Snack here. You could also try comp.lang.tcl but I could miss it there. Both maybe is the best.

The problem with ALSA support is that my sysadm guys don't want to install it yet (I'm not allowed to tinker with my own machine.) The current version I made using a machine at home that no longer exists. Naturally, ALSA will eventually become the standard and once it's installed on my work machine I will immediately get it to work as intended. Unless somebody beats me to it icon_wink.gif

Kåre
Back to top
View users profile Send private message Visit posters website
ManuK



Joined: 08 Oct 2003
Posts: 5
Location: IMS, Uni Stuttgart, Germany

PostPosted: Wed Aug 04, 2004 7:59 pm    Post subject: Beating the beast Reply with quote

...ALSA, not you, Kare.

In fact, I am currently about to try to beat myself to get snack's ALSA support working (I also had a Q&D ALSA patch for snack up to, well, 2.2.1 or so, comsuming 100% CPU for 10 seconds when enumerating devices icon_cool.gif, that's why I never came up with that). I think it's only a small thing remaining to be fixed; my old patch was made up of code stolen from aplay, so I think that comparing jkAudIO_alsa.c with aplay should reveal it (cross your fingers).

And, well, in fact I am beaten to do so... the situation here is the other way around: after an update to FC2 and kernel 2.6 we are now somewhat forced to use ALSA (it works, while OSS does not, that's it). Especially on our recording lab computer, where people should be able to control what they just recorded...
Back to top
View users profile Send private message
ManuK



Joined: 08 Oct 2003
Posts: 5
Location: IMS, Uni Stuttgart, Germany

PostPosted: Tue Aug 10, 2004 8:48 pm    Post subject: Half the way up: problem with buffer sizes Reply with quote

ok, this time a bit more useful:

I got snack not to play "stuttering" sounds any more and by that way stopping at the end of a selection, when playing on ALSA. It was a problem with XRUNs; the default buffer size is 2K samples, which is far too small (at least for an envy24; someone wrote that it always expects 10 channels stereo * 32 bits interleaved data, try to find the link).

The solution is to get a maximum buffer size from ALSA with snd_pcm_hw_params_set_buffer_size_max(... 8Meg... ) and use the value returned in the buffer size variable in a call to snd_pcm_hw_params_set_buffer_size(), all in jkAudIO_alsa.c:SnackAudioOpen().

Wanna see code? I'm going to prepare a patch.

One problem remains: although e.g. WaveSurfer starts correctly at the end of a selection on first shot, it starts playing from some random position after there when another play command is issued. Only if playing is stopped by hand, the next play command works correctly, otherwise we go through a series of XRUNs again. To me it seems that jkSoundEngine.c:playCommand does not correctly flush and close down the PCM after playing, but I'm still on the way trying to understand things.

BTW: could someone please have a look at handling of debug flags, or at least at the documentation? I tried to set a debug level of 5 in WaveSurfer, but it seems not to work. I'm not quite firm in TCL, which might be the problem here ...
Back to top
View users profile Send private message
ManuK



Joined: 08 Oct 2003
Posts: 5
Location: IMS, Uni Stuttgart, Germany

PostPosted: Wed Aug 11, 2004 6:47 pm    Post subject: too long between two runs of PlayCallback / patches Reply with quote

The 'random position phantom playback' problem remaining seems to be due to too much time elapsing between two invocations of PlayCallback().

Did I get that right?
- At the end of a selection PlayCallback() fills the buffer using SnackAudioPost(), in order to avoid buffer underruns; before that, it checks if the sound card is still playing.
- If the sound card was no longer playing (more samples played than written), the audio hardware gets closed down, otherwise PlayCallback() leaves it playing and exits. It is expected that during the next run of PlayCallback() sound buffers will drain, so that the hardware can safely be closed down (maybe having played rubbish appended by SnackAudioPost()).

Now I think that the time elapsing in between these two runs is too long; the buffer drains, and as a result SnackAudioWriteable() gets an EPIPE aka XRUN in snd_pcm_avail_update(). PlayCallback() does not detect this as an end-of-buffer condition and runs forever (until a stop command is issued), successive play commands jumping onto the running train at some random position.

A solution is to check if SnackAudioWriteable() returns an error and to close down audio in this case, both in PlayCallback(). This is what the second patch dows; BEWARE that it changes the behaviour of SnackAudioWriteable() to return the error code instead of zero in case something goes wrong.

The patches are available at:
http://www.ims.uni-stuttgart.de/~kountzml/snack.html
Back to top
View users profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.speech.kth.se/wavesurfer Forum Index -> WaveSurfer All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.1 © 2001, 2002 phpBB Group