henrik wrote:
> On 25 apr, 12:08, henrik <henrik.aron...@gmail.com> wrote:
>> I have a problem with MediaPlayer on my HTC Hero.  When I set it to
>> decrypt & play a local file in the background, it starts skipping
>> after a minute or two, even though I have aquired the
>> PARTIAL_WAKE_LOCK.  This only happens when the phone is running on
>> battery:  I'm unable to reproduce this with the USB cable plugged in.
>> In addition, this only happens when I leave the phone to play.  If I'm
>> using another app actively, the music never skips.
> 
> The weird thing is, the problem goes away if I use
> SCREEN_DIM_WAKE_LOCK instead.  But I really don't want to drain my
> users' batteries needlessly.

With respect to "Does the CPU lower its frequency when running on
battery?", that is up to the device manufacturer and probably cannot be
stated for Android as a whole. It is eminently possible that on your
edition of the Hero the CPU drops when the screen is not on.

If you have one media file (decrypted) playing while you are decrypting
another, consider reducing the the priority of the decryption thread:

Thread.currentThread().setPriority(Thread.MIN_PRIORITY+1);

And perhaps, if possible, toss a yield() in periodically during the
decryption itself, if you aren't just passing this over to some API call:

Thread.yield();

That way, if the skip is caused by slower CPU speeds, you'll be doing
more to let MediaPlayer have "first dibs" on what CPU there is.

If you can reproduce the skipping problem even without your decryption
thread running -- if it skips on ordinary files -- see if the Music app
also skips. If so, then there's something funky about your device or
some other app that's running on it. If the Music app is fine, you might
putter around its implementation in the open source code to see if it
gives you any ideas.

Note that your original post got truncated. It ends with "Also, if I".

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

-- 
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