kms/surface: Fix racy output disable
This commit is contained in:
parent
5b89ad27fb
commit
9b4127555e
1 changed files with 8 additions and 4 deletions
|
|
@ -222,7 +222,7 @@ impl Default for QueueState {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ThreadCommand {
|
pub enum ThreadCommand {
|
||||||
Suspend,
|
Suspend(SyncSender<()>),
|
||||||
Resume {
|
Resume {
|
||||||
surface: DrmSurface,
|
surface: DrmSurface,
|
||||||
gbm: GbmDevice<DrmDeviceFd>,
|
gbm: GbmDevice<DrmDeviceFd>,
|
||||||
|
|
@ -433,7 +433,9 @@ impl Surface {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn suspend(&mut self) {
|
pub fn suspend(&mut self) {
|
||||||
let _ = self.thread_command.send(ThreadCommand::Suspend);
|
let (tx, rx) = std::sync::mpsc::sync_channel(1);
|
||||||
|
let _ = self.thread_command.send(ThreadCommand::Suspend(tx));
|
||||||
|
let _ = rx.recv();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resume(
|
pub fn resume(
|
||||||
|
|
@ -553,7 +555,7 @@ fn surface_thread(
|
||||||
event_loop
|
event_loop
|
||||||
.handle()
|
.handle()
|
||||||
.insert_source(thread_receiver, move |command, _, state| match command {
|
.insert_source(thread_receiver, move |command, _, state| match command {
|
||||||
Event::Msg(ThreadCommand::Suspend) => state.suspend(),
|
Event::Msg(ThreadCommand::Suspend(tx)) => state.suspend(tx),
|
||||||
Event::Msg(ThreadCommand::Resume {
|
Event::Msg(ThreadCommand::Resume {
|
||||||
surface,
|
surface,
|
||||||
gbm,
|
gbm,
|
||||||
|
|
@ -642,7 +644,7 @@ fn surface_thread(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SurfaceThreadState {
|
impl SurfaceThreadState {
|
||||||
fn suspend(&mut self) {
|
fn suspend(&mut self, tx: SyncSender<()>) {
|
||||||
self.active.store(false, Ordering::SeqCst);
|
self.active.store(false, Ordering::SeqCst);
|
||||||
let _ = self.compositor.take();
|
let _ = self.compositor.take();
|
||||||
|
|
||||||
|
|
@ -660,6 +662,8 @@ impl SurfaceThreadState {
|
||||||
self.loop_handle.remove(queued_render);
|
self.loop_handle.remove(queued_render);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let _ = tx.send(());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resume(
|
fn resume(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue