On Jan 25, 12:33 am, Paul Marks <pma...@google.com> wrote:
> I'm currently writing an app that uses a Service.  A thread in the
> service generates an infinite stream of audio, and writes it to 
> theAudioTrack.  I want the audio to keep playing indefinitely until the
> user stops it.
>
> Based on my understanding of the PowerManager class, it looks like I
> should need a PARTIAL_WAKE_LOCK to keep the CPU awake so the audio can
> continue playing.
>
> However, I left the audio playing on my phone with no wake lock,
> running on battery, in airplane mode, with all five items on the power
> control widget disabled, and the audio just kept right on playing for
> at least 15 minutes.  Afterwards, I looked at the battery history, and
> it showed "Running (100%)", even though the Partial wake usage was
> negligible.
>
> Is there something special about AudioTrackwhich prevents the CPU
> from entering its deep sleep state?  Should it be necessary for my
> service to grab a PARTIAL_WAKE_LOCK and its associated permission?

After speaking with one of the developers, I learned:

- On current platforms, the audio driver acquires its own wake lock,
which explains why my phone was not going to sleep.
http://android.git.kernel.org/?p=platform/hardware/msm7k.git;a=blob;f=libaudio-qsd8k/AudioHardware.cpp;hb=HEAD

- There's no explicit guarantee that this will always be true for all
platforms, so it's still a good idea to hold a PARTIAL_WAKE_LOCK if
you need to stay awake while using an AudioTrack.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to