Commit cc69b318 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

netsync: fix and simplify dead input handling (fixes #5426)

parent a7342143
......@@ -151,8 +151,13 @@ void Close(vlc_object_t *object)
intf_thread_t *intf = (intf_thread_t*)object;
intf_sys_t *sys = intf->p_sys;
assert(sys->input == NULL);
var_DelCallback(sys->playlist, "input-current", PlaylistEvent, intf);
if (sys->input != NULL) {
vlc_cancel(sys->thread);
vlc_join(sys->thread, NULL);
}
net_Close(sys->fd);
free(sys);
}
......@@ -266,43 +271,28 @@ static void *Slave(void *handle)
return NULL;
}
static int InputEvent(vlc_object_t *object, char const *cmd,
vlc_value_t oldval, vlc_value_t newval, void *data)
static int PlaylistEvent(vlc_object_t *object, char const *cmd,
vlc_value_t oldval, vlc_value_t newval, void *data)
{
VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(object);
VLC_UNUSED(cmd); VLC_UNUSED(object);
intf_thread_t *intf = data;
intf_sys_t *sys = intf->p_sys;
input_thread_t *input = newval.p_address;
if (newval.i_int == INPUT_EVENT_DEAD && sys->input) {
if (sys->input != NULL) {
msg_Err(intf, "InputEvent DEAD");
assert(oldval.p_address == sys->input);
vlc_cancel(sys->thread);
vlc_join(sys->thread, NULL);
vlc_object_release(sys->input);
sys->input = NULL;
}
return VLC_SUCCESS;
}
static int PlaylistEvent(vlc_object_t *object, char const *cmd,
vlc_value_t oldval, vlc_value_t newval, void *data)
{
VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(object);
intf_thread_t *intf = data;
intf_sys_t *sys = intf->p_sys;
input_thread_t *input = newval.p_address;
sys->input = input;
assert(sys->input == NULL);
if (input != NULL)
{
sys->input = vlc_object_hold(input);
if (input != NULL) {
if (vlc_clone(&sys->thread, sys->is_master ? Master : Slave, intf,
VLC_THREAD_PRIORITY_INPUT)) {
vlc_object_release(input);
VLC_THREAD_PRIORITY_INPUT))
sys->input = NULL;
return VLC_SUCCESS;
}
var_AddCallback(input, "intf-event", InputEvent, intf);
}
return VLC_SUCCESS;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment