Skip to content

Commit e868f5a

Browse files
committed
exoplayer: small destroy improvements
1 parent cb79f55 commit e868f5a

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/controller/ExoPlayerController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,10 @@ private void releasePlayer() {
492492
mPlayer.stop(true); // Cause input lags due to high cpu load?
493493
mPlayer.clearVideoSurface();
494494
mPlayer.release();
495-
mPlayer = null;
496495
} catch (ArrayIndexOutOfBoundsException e) { // thrown on stop()
497496
e.printStackTrace();
497+
} finally {
498+
mPlayer = null;
498499
}
499500
}
500501
}

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/other/ExoPlayerInitializer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ private DefaultLoadControl createLoadControl() {
137137
baseBuilder
138138
.setBufferDurationsMs(minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs);
139139

140+
// Decrease buffer size?
141+
//baseBuilder.setAllocator(new DefaultAllocator(true, 16 * 1024));
142+
140143
return baseBuilder.createDefaultLoadControl();
141144
}
142145

smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/playback/PlaybackFragment.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -389,35 +389,33 @@ private void initializePlayer() {
389389
}
390390

391391
private void destroyPlayerObjects() {
392-
// Fix access calls when player isn't initialized
393-
mExoPlayerController.release();
392+
setAdapter(null); // PlayerGlue->LeanbackPlayerAdapter->Context memory leak fix
393+
if (mRowsAdapter != null) {
394+
mRowsAdapter.clear();
395+
mRowsAdapter = null;
396+
}
394397
if (mMediaSessionConnector != null) {
395398
mMediaSessionConnector.setPlayer(null);
399+
mMediaSessionConnector = null;
396400
}
397401
if (mMediaSession != null) {
398402
mMediaSession.setActive(false);
399403
mMediaSession.release();
404+
mMediaSession = null;
400405
}
401-
if (mRowsAdapter != null) {
402-
mRowsAdapter.clear();
403-
}
404-
setAdapter(null); // PlayerGlue->LeanbackPlayerAdapter->Context memory leak fix
405-
mPlayer = null;
406406
mPlayerGlue = null;
407-
mRowsAdapter = null;
407+
// Fix access calls when player isn't initialized
408+
mExoPlayerController.release();
409+
mPlayer = null;
408410
mSubtitleManager = null;
409411
mDebugInfoManager = null;
410-
mMediaSessionConnector = null;
411-
mMediaSession = null;
412412
if (mYouTubeOverlay != null) {
413413
mYouTubeOverlay
414414
.player(null)
415415
.playerView(null)
416416
.performListener(null);
417417
}
418-
if (mDoubleTapPlayerAdapter != null) {
419-
mDoubleTapPlayerAdapter = null;
420-
}
418+
mDoubleTapPlayerAdapter = null;
421419
}
422420

423421
private void createPlayerObjects() {

0 commit comments

Comments
 (0)