Destroy screen once stream is finished
The screen receives callbacks from the decoder, fed by the stream. The decoder is run from the stream thread, so waiting for the end of stream is sufficient to avoid possible use-after-destroy.
This commit is contained in:
parent
08fc6694e1
commit
28f6cbaea6
1 changed files with 7 additions and 4 deletions
|
@ -430,10 +430,6 @@ scrcpy(const struct scrcpy_options *options) {
|
|||
LOGD("quit...");
|
||||
|
||||
end:
|
||||
if (screen_initialized) {
|
||||
screen_destroy(&screen);
|
||||
}
|
||||
|
||||
// stop stream and controller so that they don't continue once their socket
|
||||
// is shutdown
|
||||
if (stream_started) {
|
||||
|
@ -459,6 +455,13 @@ end:
|
|||
if (stream_started) {
|
||||
stream_join(&stream);
|
||||
}
|
||||
|
||||
// Destroy the screen only after the stream is guaranteed to be finished,
|
||||
// because otherwise the screen could receive new frames after destruction
|
||||
if (screen_initialized) {
|
||||
screen_destroy(&screen);
|
||||
}
|
||||
|
||||
if (controller_started) {
|
||||
controller_join(&controller);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue