Background Audio Continues During Suspend

38 views
Skip to first unread message

Dave Smith

unread,
Nov 10, 2015, 12:41:45 PM11/10/15
to android-platform
Hi all -

I'm observing a strange behavior and I'm wondering if you can help me track down the sources that indicate what is happening. I am currently testing some suspend behaviors on a Lollipop device (Nexus 5). All these tests are done WITHOUT holding wake locks (on purpose)…

My first test was doing some counting on a background thread. As expected, within a few minutes of the device going into suspend mode, code execution is paused and resumes when the device is activated again. However, when I start playing a local media file through MediaPlayer, the entire audio file (30 minutes in length) runs to completion without halting when the device does to sleep. Running dumpsys power during this time indicates that no wake locks are currently active, so I don't believe mediaserver is taking it's own automatic wake lock (though it's still possible).

Any thoughts and/or source references that would indicate why audio can continue to play without the application (or apparently the system) activating a wake lock?

Cheers,
--
Dave Smith, PE
@devunwired

Glenn Kasten

unread,
Nov 10, 2015, 4:38:58 PM11/10/15
to android-platform
Audioflinger takes a wake lock while any audio output is active, or has been active within the last 3 seconds.
Try dumpsys media.audio_flinger to see what AudioFlinger is doing.

Dave Smith

unread,
Nov 11, 2015, 2:21:55 PM11/11/15
to android-platform
Thanks Glenn -

This is interesting. I do see the AudioFlinger wake lock immediately after (it's tagged AudioMix), but it only appears temporarily (for perhaps 10-15 seconds). It seems to be released before event the screen automatically turns of and doesn't seem to be re-activated. Dumping media.audio_flinger does indicate there is an active MP3 output thread with one active track inside…so it surprises me that the wake lock is no longer active.

Power Manager says that the device's wake state is "asleep", so there doesn't seem to be anything keeping it out of suspend…but the audio does continue to play in this state. Perhaps once the initial setup/mixing is done by Audioflinger, some form of DMA takes over in the hardware and the CPU is no longer necessary to keep the process moving?

Cheers,
--
Dave Smith, PE
@devunwired
Reply all
Reply to author
Forward
0 new messages