mirror of
https://github.com/albfan/miraclecast.git
synced 2025-02-13 02:41:55 +00:00
demo/miracle-wfdctl: teardown session more gracefully
This commit is contained in:
parent
ad407d7505
commit
aa5d6c0468
1 changed files with 21 additions and 6 deletions
|
@ -101,6 +101,8 @@ private class WfdCtl : GLib.Application
|
|||
|
||||
string curr_sink_mac;
|
||||
Gdk.Display display;
|
||||
Peer curr_peer;
|
||||
Sink curr_sink;
|
||||
Session curr_session;
|
||||
|
||||
const GLib.OptionEntry[] option_entries = {
|
||||
|
@ -218,8 +220,12 @@ private class WfdCtl : GLib.Application
|
|||
key = decode_path(key);
|
||||
Peer p = peers.lookup(key);
|
||||
if(null == p) {
|
||||
info("removing stray peer: %s", key);
|
||||
break;
|
||||
}
|
||||
if(p == curr_peer) {
|
||||
curr_peer = null;
|
||||
}
|
||||
peers.remove(key);
|
||||
peer_removed(key, p);
|
||||
break;
|
||||
|
@ -227,8 +233,12 @@ private class WfdCtl : GLib.Application
|
|||
key = decode_path(key);
|
||||
Sink s = sinks.lookup(key);
|
||||
if(null == s) {
|
||||
info("removing stray sink: %s", key);
|
||||
break;
|
||||
}
|
||||
if(s == curr_sink) {
|
||||
curr_sink = null;
|
||||
}
|
||||
sinks.remove(key);
|
||||
sink_removed(key, s);
|
||||
break;
|
||||
|
@ -236,8 +246,12 @@ private class WfdCtl : GLib.Application
|
|||
key = decode_path(key);
|
||||
Session s = sessions.lookup(key);
|
||||
if(null == s) {
|
||||
info("removing stray session: %s", key);
|
||||
break;
|
||||
}
|
||||
if(s == curr_session) {
|
||||
curr_session = null;
|
||||
}
|
||||
sessions.remove(key);
|
||||
session_removed(key, s);
|
||||
break;
|
||||
|
@ -397,6 +411,8 @@ private class WfdCtl : GLib.Application
|
|||
|
||||
(p as Object).disconnect(id);
|
||||
|
||||
curr_peer = p;
|
||||
|
||||
info("P2P group formed");
|
||||
}
|
||||
|
||||
|
@ -502,24 +518,23 @@ private class WfdCtl : GLib.Application
|
|||
if(null != error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
curr_sink = sink;
|
||||
}
|
||||
|
||||
private async void wait_for_session_ending()
|
||||
{
|
||||
info("wait for session ending");
|
||||
ulong id = session_removed.connect((id, s) => {
|
||||
if(s != curr_session) {
|
||||
return;
|
||||
}
|
||||
|
||||
info("session ended");
|
||||
curr_session = null;
|
||||
wait_for_session_ending.callback();
|
||||
});
|
||||
|
||||
yield;
|
||||
|
||||
disconnect(id);
|
||||
|
||||
info("session ended");
|
||||
curr_session = null;
|
||||
}
|
||||
|
||||
private async void release_wnic_ownership() throws Error
|
||||
|
|
Loading…
Reference in a new issue