mirror of
https://github.com/albfan/miraclecast.git
synced 2025-02-13 13:41:54 +00:00
miracle-dispd, demo/miracle-wfdctl: improve error handling and reporting
This commit is contained in:
parent
0c7e3092b3
commit
4147c2c38d
2 changed files with 34 additions and 5 deletions
|
@ -473,22 +473,45 @@ private class WfdCtl : GLib.Application
|
|||
}
|
||||
|
||||
info("session status: %s", session_state_to_str(v.get_int32()));
|
||||
|
||||
if(6 == v.get_int32()) {
|
||||
Idle.add(establish_session.callback);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
Error error = null;
|
||||
uint id = Timeout.add_seconds(10, () => {
|
||||
error = new WfdCtlError.TIMEOUT("failed to establish session");
|
||||
Idle.add(establish_session.callback);
|
||||
return false;
|
||||
});
|
||||
|
||||
info("session status: %s", session_state_to_str(curr_session.state));
|
||||
yield;
|
||||
|
||||
Source.remove(id);
|
||||
if(null != error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private async void wait_for_session_ending()
|
||||
{
|
||||
info("wait for session ending");
|
||||
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();
|
||||
});
|
||||
|
||||
yield;
|
||||
|
||||
disconnect(id);
|
||||
}
|
||||
|
||||
private async void release_wnic_ownership() throws Error
|
||||
|
|
|
@ -464,6 +464,7 @@ static int wfd_session_handle_request(struct rtsp *bus,
|
|||
return 0;
|
||||
|
||||
error:
|
||||
log_warning("error while handling request: %s", strerror(-r));
|
||||
wfd_session_teardown(s);
|
||||
|
||||
return r;
|
||||
|
@ -525,12 +526,12 @@ int wfd_session_request(struct wfd_session *s,
|
|||
|
||||
r = wfd_session_do_request(s, id, args, &m);
|
||||
if(0 > r) {
|
||||
return r;
|
||||
goto error;
|
||||
}
|
||||
|
||||
r = rtsp_message_seal(m);
|
||||
if(0 > r) {
|
||||
return r;
|
||||
goto error;
|
||||
}
|
||||
|
||||
r = rtsp_call_async(s->rtsp,
|
||||
|
@ -540,7 +541,7 @@ int wfd_session_request(struct wfd_session *s,
|
|||
0,
|
||||
NULL);
|
||||
if(0 > r) {
|
||||
return r;
|
||||
goto error;
|
||||
}
|
||||
|
||||
s->last_request = id;
|
||||
|
@ -551,6 +552,10 @@ int wfd_session_request(struct wfd_session *s,
|
|||
(char *) rtsp_message_get_raw(m));
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
log_warning("error while requesting: %s", strerror(-r));
|
||||
return r;
|
||||
}
|
||||
|
||||
static int wfd_session_handle_io(sd_event_source *source,
|
||||
|
@ -610,6 +615,7 @@ static int wfd_session_handle_io(sd_event_source *source,
|
|||
|
||||
end:
|
||||
if (0 > r) {
|
||||
log_warning("error while handling I/O: %s", strerror(-r));
|
||||
wfd_session_teardown(s);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue