Skip to content

Commit

Permalink
release locks in player on stop
Browse files Browse the repository at this point in the history
  • Loading branch information
segler-alex committed May 11, 2016
1 parent aeaece7 commit 30fd193
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ public void onCreate() {
wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, TAG);
}
wifiLock.setReferenceCounted(false);
}else{
Log.e(TAG,"could not aquire wifi lock");
}
}

Expand Down Expand Up @@ -307,14 +309,8 @@ public void SendMessage(String theTitle, String theMessage, String theTicker) {

@Override
public void onDestroy() {
Log.i(TAG,"onDestroy()");
Stop();
stopForeground(true);
wakeLock.release();
wakeLock = null;
if (wifiLock != null) {
wifiLock.release();
wifiLock = null;
}
}

public void PlayUrl(String theURL, String theName, String theID) {
Expand Down Expand Up @@ -437,6 +433,7 @@ public void streamStopped() {
}

public void Stop() {
Log.i(TAG,"stop()");
if (itsMediaPlayer != null) {
if (itsMediaPlayer.isPlaying()) {
itsMediaPlayer.stop();
Expand All @@ -455,5 +452,14 @@ public void Stop() {
clearTimer();
stopForeground(true);
sendBroadCast(PLAYER_SERVICE_STATUS_UPDATE);

if (wakeLock != null) {
wakeLock.release();
wakeLock = null;
}
if (wifiLock != null) {
wifiLock.release();
wifiLock = null;
}
}
}

0 comments on commit 30fd193

Please sign in to comment.