Skip to content

Commit

Permalink
Fix crash on PlaybackService destruction
Browse files Browse the repository at this point in the history
Fix a destructive crash when PlaybackService attempted to release a wakelock that wasn't being held.
  • Loading branch information
OxygenCobalt committed Mar 24, 2021
1 parent 688f9d3 commit d0280ff
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -440,17 +440,13 @@ 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)
}

/**
* Release the wakelock if its currently being held.
*/
private fun releaseWakelock() {
logD("Attempting to release the wakelock.")

if (wakeLock.isHeld) {
wakeLock.release()
}
Expand Down

0 comments on commit d0280ff

Please sign in to comment.