Skip to content

Commit

Permalink
fix(qavplayer): crash on terminate
Browse files Browse the repository at this point in the history
Reproduce:
1. Switch source and call play()
2. Repeat first step

Possible reason:
Functions executing in wrong order. We waiting for futures when we already
deallocated some resources that futures might depend on.
  • Loading branch information
yunag committed Dec 5, 2024
1 parent 746db80 commit a8900a6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/QtAVPlayer/qavplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ void QAVPlayerPrivate::terminate()
setState(QAVPlayer::StoppedState);
quit = true;
wait(false);

if (dev)
dev->abort(true);
demuxer.abort();
demuxerFuture.waitForFinished();
loaderFuture.waitForFinished();
videoPlayFuture.waitForFinished();
audioPlayFuture.waitForFinished();
demuxer.abort(false);

videoFrameRate = 0.0;
videoQueue.clear();
videoQueue.abort();
Expand All @@ -326,14 +336,6 @@ void QAVPlayerPrivate::terminate()
subtitleQueue.clear();
subtitleQueue.abort();
subtitleClock.clear();
if (dev)
dev->abort(true);
demuxer.abort();
demuxerFuture.waitForFinished();
loaderFuture.waitForFinished();
videoPlayFuture.waitForFinished();
audioPlayFuture.waitForFinished();
demuxer.abort(false);

pendingPosition = 0;
pendingSeek = false;
Expand Down

0 comments on commit a8900a6

Please sign in to comment.