Skip to content

Commit

Permalink
Merge branch 'feature/80-fix-deadlock' into develop
Browse files Browse the repository at this point in the history
Fixes GitHub issue #81.
  • Loading branch information
protyposis committed Jan 5, 2018
2 parents 53231f1 + 0488072 commit c65ee4c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,13 @@ public void stop() {
synchronized (mReleaseSyncLock) {
try {
// Schedule release on the playback thread
mPlaybackThread.release();
boolean awaitingRelease = mPlaybackThread.release();
mPlaybackThread = null;

// Wait for the release on the playback thread to finish
mReleaseSyncLock.wait();
if (awaitingRelease) {
mReleaseSyncLock.wait();
}
} catch (InterruptedException e) {
// nothing to do here
}
Expand Down Expand Up @@ -969,9 +971,9 @@ public void setSurface(Surface surface) {
mHandler.sendMessage(mHandler.obtainMessage(PlaybackThread.DECODER_SET_SURFACE, surface));
}

private void release() {
private boolean release() {
if(!isAlive()) {
return;
return false;
}

mPaused = true; // Set this flag so the loop does not schedule next loop iteration
Expand All @@ -982,6 +984,8 @@ private void release() {
// something so {@link #handleMessage} gets called on the handler thread, read the
// mReleasing flag, and call {@link #releaseInternal}.
mHandler.sendEmptyMessage(PLAYBACK_RELEASE);

return true;
}

@Override
Expand Down

0 comments on commit c65ee4c

Please sign in to comment.