fun
This commit is contained in:
parent
2e0a0ef40f
commit
cd43f50fdb
1 changed files with 54 additions and 25 deletions
|
@ -15,9 +15,9 @@ mod imp {
|
|||
pub(super) enum State {
|
||||
Idle,
|
||||
FileLoading,
|
||||
FileLoaded, // internal?
|
||||
FileLoaded, // internal
|
||||
Active,
|
||||
FileEnded, // internal?
|
||||
FileEnded, // internal
|
||||
Seeking,
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ mod imp {
|
|||
// "Useful to drain property changes before a new file is loaded."
|
||||
mpv.add_hook(0, "on_before_start_file", 0).unwrap();
|
||||
// "Useful to drain property changes after a file has finished."
|
||||
mpv.add_hook(0, "o_after_start_file", 0).unwrap();
|
||||
mpv.add_hook(0, "on_after_end_file", 0).unwrap();
|
||||
|
||||
Self {
|
||||
state: Cell::new(State::Idle),
|
||||
|
@ -265,16 +265,25 @@ mod imp {
|
|||
let mpv_event_loop_handle = glib::spawn_future_local(async move {
|
||||
loop {
|
||||
let window = window.upgrade().unwrap();
|
||||
let listener = window.imp().mpv.wakeup_listener();
|
||||
|
||||
// only send property change notifications after the event queue is drained
|
||||
let freeze_notify = window.freeze_notify();
|
||||
event!(
|
||||
Level::TRACE,
|
||||
"before event loop, state is {:?}",
|
||||
window.imp().state.get()
|
||||
);
|
||||
|
||||
let listener = loop {
|
||||
let listener = window.imp().mpv.wakeup_listener();
|
||||
|
||||
while let Some(event) = window.imp().mpv.wait_event(0.0) {
|
||||
use crate::mpv::Event;
|
||||
|
||||
match event {
|
||||
Event::PropertyChange(event) => window.imp().on_property_change(event),
|
||||
Event::PropertyChange(event) => {
|
||||
window.imp().on_property_change(event)
|
||||
}
|
||||
Event::Hook(event) => window.imp().on_hook(event),
|
||||
Event::LogMessage(event) => window.imp().on_log_message(event),
|
||||
|
||||
|
@ -297,8 +306,28 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
match window.imp().state.get() {
|
||||
State::FileLoaded | State::FileEnded => {
|
||||
// really annoying intermediary states we're not really interested
|
||||
// in seeing outside of this loop
|
||||
// just block until it's done lol
|
||||
use event_listener::Listener;
|
||||
event!(Level::INFO, "blocking");
|
||||
listener.wait();
|
||||
}
|
||||
|
||||
_ => break listener,
|
||||
}
|
||||
};
|
||||
|
||||
// send property change notifications now
|
||||
drop(freeze_notify);
|
||||
event!(
|
||||
Level::TRACE,
|
||||
"after event loop, state is {:?}",
|
||||
window.imp().state.get()
|
||||
);
|
||||
|
||||
drop(window);
|
||||
listener.await;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue