mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +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()));
|
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()
|
private async void wait_for_session_ending()
|
||||||
{
|
{
|
||||||
info("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");
|
info("session ended");
|
||||||
curr_session = null;
|
curr_session = null;
|
||||||
wait_for_session_ending.callback();
|
wait_for_session_ending.callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
yield;
|
yield;
|
||||||
|
|
||||||
|
disconnect(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void release_wnic_ownership() throws Error
|
private async void release_wnic_ownership() throws Error
|
||||||
|
|
|
@ -464,6 +464,7 @@ static int wfd_session_handle_request(struct rtsp *bus,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
log_warning("error while handling request: %s", strerror(-r));
|
||||||
wfd_session_teardown(s);
|
wfd_session_teardown(s);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
@ -525,12 +526,12 @@ int wfd_session_request(struct wfd_session *s,
|
||||||
|
|
||||||
r = wfd_session_do_request(s, id, args, &m);
|
r = wfd_session_do_request(s, id, args, &m);
|
||||||
if(0 > r) {
|
if(0 > r) {
|
||||||
return r;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = rtsp_message_seal(m);
|
r = rtsp_message_seal(m);
|
||||||
if(0 > r) {
|
if(0 > r) {
|
||||||
return r;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = rtsp_call_async(s->rtsp,
|
r = rtsp_call_async(s->rtsp,
|
||||||
|
@ -540,7 +541,7 @@ int wfd_session_request(struct wfd_session *s,
|
||||||
0,
|
0,
|
||||||
NULL);
|
NULL);
|
||||||
if(0 > r) {
|
if(0 > r) {
|
||||||
return r;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->last_request = id;
|
s->last_request = id;
|
||||||
|
@ -551,6 +552,10 @@ int wfd_session_request(struct wfd_session *s,
|
||||||
(char *) rtsp_message_get_raw(m));
|
(char *) rtsp_message_get_raw(m));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
log_warning("error while requesting: %s", strerror(-r));
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wfd_session_handle_io(sd_event_source *source,
|
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:
|
end:
|
||||||
if (0 > r) {
|
if (0 > r) {
|
||||||
|
log_warning("error while handling I/O: %s", strerror(-r));
|
||||||
wfd_session_teardown(s);
|
wfd_session_teardown(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue