Fix crash on PlaybackService destruction

Fix a destructive crash when PlaybackService attempted to release a wakelock that wasn't being held.
This commit is contained in:
OxygenCobalt 2021-03-23 19:21:44 -06:00
parent 688f9d3a52
commit d0280fffb2
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -169,7 +169,7 @@ class PlaybackService : Service(), Player.EventListener, PlaybackStateManager.Ca
player.release()
mediaSession.release()
audioReactor.release()
wakeLock.release()
releaseWakelock()
playbackManager.removeCallback(this)
settingsManager.removeCallback(this)
@ -440,8 +440,6 @@ class PlaybackService : Service(), Player.EventListener, PlaybackStateManager.Ca
* Hold the wakelock for the default amount of time [25 Seconds]
*/
private fun holdWakelock() {
logD("Holding wakelock.")
wakeLock.acquire(WAKELOCK_TIME)
}
@ -449,8 +447,6 @@ class PlaybackService : Service(), Player.EventListener, PlaybackStateManager.Ca
* Release the wakelock if its currently being held.
*/
private fun releaseWakelock() {
logD("Attempting to release the wakelock.")
if (wakeLock.isHeld) {
wakeLock.release()
}