Denis:
The following patch was suggested from the ALSA developers. We
applied and tested this patch and it works well. We tested this patch
with our own application as well as the example program, music, and it
works. Attached is the patch.
Thanks for your assistance in this matter, it would have taken me a
long time to track this down by myself.
--
Rich
---------- Forwarded message ----------
From: Ville Syrjälä <[EMAIL PROTECTED]>
Date: Mar 19, 2007 6:59 PM
Subject: Re: [Alsa-devel] ALSA driver problem after standby/resume
To: Rich Rattanni <[EMAIL PROTECTED]>
Cc: Takashi Iwai <[EMAIL PROTECTED]>, [email protected]
On Mon, Mar 19, 2007 at 03:30:33PM -0400, Rich Rattanni wrote:
On 3/19/07, Takashi Iwai <[EMAIL PROTECTED]> wrote:
> At Mon, 19 Mar 2007 12:31:16 -0400,
> Rich Rattanni wrote:
> >
> > All:
> >
> > I have noticed a strange behaviour in the ALSA driver that seems to be
> > occur after initiating a power standby and resume. I am working on an
> > application that uses FusionSound to playback OGG audio files. When
> > the application recognizes it is idle, it tells the OS to enter
> > standby mode. Upon resuming from standby, the ALSA API call made by
> > fusionsound no longer acts as a blocking read, instead it returns
> > immediately. I have confirmed this with Denis Oliver Kropp of the
> > DirectFB / FusionSound project. He suggested that the ALSA driver
> > should be repaired to prevent this problem from occuring.
>
> It's not clear what is happening there.
> Do you have a small testcase?
>
> When the suspend/resume happens, the apps is usually requested to call
> snd_pcm_resume() and/or snd_pcm_prepare() appropriately to reset the
> stream. Otherwise the PCM status is kept as SUSPENDED.
<snip>
static void
device_write( void *device_data, void *samples, unsigned int size )
{
AlsaDeviceData *data = device_data;
snd_pcm_uframes_t frames = size;
snd_pcm_sframes_t r;
u8 *src;
src = samples;
while (frames) {
r = snd_pcm_writei( data->handle, src, frames );
Maybe we just need to add something like this here?
+ if (r == -ESTRPIPE) {
+ while ((r = snd_pcm_resume( data->handle )) == -EAGAIN)
+ sleep( 1 );
+ }
if (r < 0) {
r = snd_pcm_prepare( data->handle );
if (r < 0) {
D_WARN( "FusionSound/Device/ALSA: snd_pcm_writei()
failed: %s\n",
snd_strerror( r ) );
break;
}
continue;
}
frames -= r;
src += snd_pcm_frames_to_bytes( data->handle, r );
}
}
--
Ville Syrjälä
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/
--- git/drivers/alsa.c~org 2007-03-20 07:31:15.000000000 -0400
+++ git/drivers/alsa.c 2007-03-20 07:30:51.000000000 -0400
@@ -262,6 +262,10 @@
src = samples;
while (frames) {
r = snd_pcm_writei( data->handle, src, frames );
+ if (r == -ESTRPIPE) {
+ while ((r = snd_pcm_resume( data->handle )) == -EAGAIN)
+ sleep( 1 );
+ }
if (r < 0) {
r = snd_pcm_prepare( data->handle );
if (r < 0) {
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users