mirror of
https://github.com/albfan/miraclecast.git
synced 2025-02-15 04:42:06 +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;
|
string curr_sink_mac;
|
||||||
Gdk.Display display;
|
Gdk.Display display;
|
||||||
|
Peer curr_peer;
|
||||||
|
Sink curr_sink;
|
||||||
Session curr_session;
|
Session curr_session;
|
||||||
|
|
||||||
const GLib.OptionEntry[] option_entries = {
|
const GLib.OptionEntry[] option_entries = {
|
||||||
|
@ -218,8 +220,12 @@ private class WfdCtl : GLib.Application
|
||||||
key = decode_path(key);
|
key = decode_path(key);
|
||||||
Peer p = peers.lookup(key);
|
Peer p = peers.lookup(key);
|
||||||
if(null == p) {
|
if(null == p) {
|
||||||
|
info("removing stray peer: %s", key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(p == curr_peer) {
|
||||||
|
curr_peer = null;
|
||||||
|
}
|
||||||
peers.remove(key);
|
peers.remove(key);
|
||||||
peer_removed(key, p);
|
peer_removed(key, p);
|
||||||
break;
|
break;
|
||||||
|
@ -227,8 +233,12 @@ private class WfdCtl : GLib.Application
|
||||||
key = decode_path(key);
|
key = decode_path(key);
|
||||||
Sink s = sinks.lookup(key);
|
Sink s = sinks.lookup(key);
|
||||||
if(null == s) {
|
if(null == s) {
|
||||||
|
info("removing stray sink: %s", key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(s == curr_sink) {
|
||||||
|
curr_sink = null;
|
||||||
|
}
|
||||||
sinks.remove(key);
|
sinks.remove(key);
|
||||||
sink_removed(key, s);
|
sink_removed(key, s);
|
||||||
break;
|
break;
|
||||||
|
@ -236,8 +246,12 @@ private class WfdCtl : GLib.Application
|
||||||
key = decode_path(key);
|
key = decode_path(key);
|
||||||
Session s = sessions.lookup(key);
|
Session s = sessions.lookup(key);
|
||||||
if(null == s) {
|
if(null == s) {
|
||||||
|
info("removing stray session: %s", key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(s == curr_session) {
|
||||||
|
curr_session = null;
|
||||||
|
}
|
||||||
sessions.remove(key);
|
sessions.remove(key);
|
||||||
session_removed(key, s);
|
session_removed(key, s);
|
||||||
break;
|
break;
|
||||||
|
@ -397,6 +411,8 @@ private class WfdCtl : GLib.Application
|
||||||
|
|
||||||
(p as Object).disconnect(id);
|
(p as Object).disconnect(id);
|
||||||
|
|
||||||
|
curr_peer = p;
|
||||||
|
|
||||||
info("P2P group formed");
|
info("P2P group formed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,24 +518,23 @@ private class WfdCtl : GLib.Application
|
||||||
if(null != error) {
|
if(null != error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curr_sink = sink;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void wait_for_session_ending()
|
private async void wait_for_session_ending()
|
||||||
{
|
{
|
||||||
info("wait for session ending");
|
info("wait for session ending");
|
||||||
ulong id = session_removed.connect((id, s) => {
|
ulong id = session_removed.connect((id, s) => {
|
||||||
if(s != curr_session) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
info("session ended");
|
|
||||||
curr_session = null;
|
|
||||||
wait_for_session_ending.callback();
|
wait_for_session_ending.callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
yield;
|
yield;
|
||||||
|
|
||||||
disconnect(id);
|
disconnect(id);
|
||||||
|
|
||||||
|
info("session ended");
|
||||||
|
curr_session = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void release_wnic_ownership() throws Error
|
private async void release_wnic_ownership() throws Error
|
||||||
|
|
Loading…
Reference in a new issue