Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <syrjala@sci.fi>
To: Rich Rattanni <rattanni@gmail.com>
Cc: Takashi Iwai <tiwai@suse.de>, alsa-devel@lists.sourceforge.net
Subject: Re: ALSA driver problem after standby/resume
Date: Tue, 20 Mar 2007 00:59:26 +0200	[thread overview]
Message-ID: <20070319225926.GA9072@sci.fi> (raw)
In-Reply-To: <3187bd480703191230n628ed4fbtd368aa02a70e858c@mail.gmail.com>

On Mon, Mar 19, 2007 at 03:30:33PM -0400, Rich Rattanni wrote:
> On 3/19/07, Takashi Iwai <tiwai@suse.de> 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ä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

      reply	other threads:[~2007-03-19 22:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-19 16:31 ALSA driver problem after standby/resume Rich Rattanni
2007-03-19 17:32 ` Lee Revell
2007-03-19 17:42 ` Takashi Iwai
2007-03-19 19:30   ` Rich Rattanni
2007-03-19 22:59     ` Ville Syrjälä [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070319225926.GA9072@sci.fi \
    --to=syrjala@sci.fi \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=rattanni@gmail.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox