Search code examples
windows-phone-8voice-recordingwasapi

How to increase battery efficiency for a voice recording application in Windows Phone 8?


I have developed a voice recording app using WasApi for Windows Phone 8. But users are facing battery problem a lot and also the screen is not getting timeout while the recording is on. And if users press the lock button on background recording is getting paused. Can anyone tell me how to solve these issues?


Solution

  • I am unaware of a way to turn off the screen while recording, or of a way to record while the application is in the background. That does not mean it's not possible, only that I don't know how. It may not be possible now, but become possible in the future. Other answers may explain how to do this.

    So I'll list ways to reduce battery consumption while your application is running in the foreground and the screen is on:

    • Black display. Bright images require a lot more power than dark ones. Depending on the display technology, black pixels require a lot less power than dark pixels. Look at the Lumia Glance feature which can be always on and still requires days to drain the battery.

    • No animations. Depending on the display technology, redrawing the screen may require more power. In any case, calculating the animation to be drawn on the screen prevents the CPU from sleeping. Having an animation that only updates every second instead of every 15 milliseconds should already be a big improvement.

    • No wait loops/busy wait. If the CPU needs to wait for something don't use this pattern:

    while (true) { if (arewethereyet()) break; }

    • Cluster work into batches. The CPU needs to be able to sleep and ideally it needs to be able to sleep for long continuous periods of time. Use a long buffer duration for the microphone and don't fetch the buffer too aggressively.