mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
stop sender properly after session end
This commit is contained in:
parent
d8d538ef65
commit
20ff174fe8
2 changed files with 32 additions and 6 deletions
|
@ -463,13 +463,21 @@ static const struct cli_cmd cli_cmds[] = {
|
|||
{ },
|
||||
};
|
||||
|
||||
static void kill_gst(void)
|
||||
static void stop_sender(void)
|
||||
{
|
||||
if (src_pid <= 0)
|
||||
GError *error = NULL;
|
||||
|
||||
if (!sender)
|
||||
return;
|
||||
|
||||
kill(src_pid, SIGTERM);
|
||||
src_pid = 0;
|
||||
sender_call_stop_sync(sender, NULL, &error);
|
||||
if(error) {
|
||||
cli_error("SOURCE failed to stop sender: %s", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
g_object_unref(sender);
|
||||
sender = NULL;
|
||||
}
|
||||
|
||||
void ctl_fn_src_connected(struct ctl_src *s)
|
||||
|
@ -586,7 +594,7 @@ void ctl_fn_peer_free(struct ctl_peer *p)
|
|||
cli_printf("no longer running on peer %s\n",
|
||||
running_peer->label);
|
||||
stop_timeout(&src_timeout);
|
||||
kill_gst();
|
||||
stop_sender();
|
||||
ctl_src_close(src);
|
||||
running_peer = NULL;
|
||||
stop_timeout(&scan_timeout);
|
||||
|
@ -686,7 +694,7 @@ void ctl_fn_peer_disconnected(struct ctl_peer *p)
|
|||
cli_printf("no longer running on peer %s\n",
|
||||
running_peer->label);
|
||||
stop_timeout(&src_timeout);
|
||||
kill_gst();
|
||||
stop_sender();
|
||||
ctl_src_close(src);
|
||||
running_peer = NULL;
|
||||
stop_timeout(&scan_timeout);
|
||||
|
|
|
@ -44,6 +44,8 @@ struct SenderImpl
|
|||
guint bus_obj_id;
|
||||
|
||||
GDBusMethodInvocation *method_invoke;
|
||||
|
||||
guint timer_handle;
|
||||
};
|
||||
|
||||
static gchar *arg_host = NULL;
|
||||
|
@ -519,6 +521,11 @@ static gboolean sender_impl_prepare(struct SenderImpl *self,
|
|||
guint16 refresh_rate,
|
||||
gboolean interleave)
|
||||
{
|
||||
if(self->timer_handle) {
|
||||
g_source_remove(self->timer_handle);
|
||||
self->timer_handle = 0;
|
||||
}
|
||||
|
||||
if(self->pipeline) {
|
||||
sender_complete_prepare(SENDER(self->skeleton), invocation);
|
||||
return TRUE;
|
||||
|
@ -607,6 +614,15 @@ static gboolean sender_impl_pause(struct SenderImpl *self,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_timeout_quit(gpointer user_data)
|
||||
{
|
||||
struct SenderImpl *self = user_data;
|
||||
|
||||
g_main_loop_quit(self->loop);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean sender_impl_stop(struct SenderImpl *self,
|
||||
GDBusMethodInvocation *invocation)
|
||||
{
|
||||
|
@ -628,6 +644,8 @@ static gboolean sender_impl_stop(struct SenderImpl *self,
|
|||
g_object_unref(self->pipeline);
|
||||
self->pipeline = NULL;
|
||||
|
||||
self->timer_handle = g_timeout_add_seconds(3, on_timeout_quit, self);
|
||||
|
||||
end:
|
||||
sender_complete_stop(SENDER(self->skeleton), invocation);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue