mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Release MediaPlayers immediately after stopping ringers
Closes #4987 // FREEBIE
This commit is contained in:
parent
1abf39685a
commit
1512f6e172
@ -56,7 +56,6 @@ public class IncomingRinger {
|
|||||||
public IncomingRinger(Context context) {
|
public IncomingRinger(Context context) {
|
||||||
this.context = context.getApplicationContext();
|
this.context = context.getApplicationContext();
|
||||||
vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
|
vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
player = createPlayer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MediaPlayer createPlayer() {
|
private MediaPlayer createPlayer() {
|
||||||
@ -77,10 +76,8 @@ public class IncomingRinger {
|
|||||||
public void start() {
|
public void start() {
|
||||||
AudioManager audioManager = ServiceUtil.getAudioManager(context);
|
AudioManager audioManager = ServiceUtil.getAudioManager(context);
|
||||||
|
|
||||||
if(player == null) {
|
if (player != null) player.release();
|
||||||
//retry player creation to pick up changed ringtones or audio server restarts
|
player = createPlayer();
|
||||||
player = createPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ringerMode = audioManager.getRingerMode();
|
int ringerMode = audioManager.getRingerMode();
|
||||||
|
|
||||||
@ -113,6 +110,8 @@ public class IncomingRinger {
|
|||||||
if (player != null) {
|
if (player != null) {
|
||||||
Log.d(TAG, "Stopping ringer");
|
Log.d(TAG, "Stopping ringer");
|
||||||
player.stop();
|
player.stop();
|
||||||
|
player.release();
|
||||||
|
player = null;
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Cancelling vibrator");
|
Log.d(TAG, "Cancelling vibrator");
|
||||||
vibrator.cancel();
|
vibrator.cancel();
|
||||||
|
@ -115,6 +115,8 @@ public class OutgoingRinger implements MediaPlayer.OnCompletionListener, MediaPl
|
|||||||
if( mediaPlayer == null ) return;
|
if( mediaPlayer == null ) return;
|
||||||
try {
|
try {
|
||||||
mediaPlayer.stop();
|
mediaPlayer.stop();
|
||||||
|
mediaPlayer.release();
|
||||||
|
mediaPlayer = null;
|
||||||
} catch( IllegalStateException e ) {
|
} catch( IllegalStateException e ) {
|
||||||
}
|
}
|
||||||
currentSoundID = -1;
|
currentSoundID = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user