X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcontrol%2Fnetsync.c;h=2ced26bdaecdb99255f22550865ca45fa85762db;hb=3c2c9364a1f0c9c34db661a22be6cb8b490dc0cb;hp=852ef7848b98dffd021bc7201e6e7e488dbf3b39;hpb=cabb37428b3ab8449392d559688d4353985c39f2;p=vlc diff --git a/modules/control/netsync.c b/modules/control/netsync.c index 852ef7848b..2ced26bdae 100644 --- a/modules/control/netsync.c +++ b/modules/control/netsync.c @@ -1,5 +1,5 @@ /***************************************************************************** - * netsync.c: synchronisation between several network clients. + * netsync.c: synchronization between several network clients. ***************************************************************************** * Copyright (C) 2004-2009 the VideoLAN team * $Id$ @@ -36,10 +36,8 @@ #include #include -#ifdef HAVE_UNISTD_H -# include -#endif #include +#include #ifdef HAVE_POLL # include #endif @@ -55,29 +53,29 @@ static int Open (vlc_object_t *); static void Close(vlc_object_t *); #define NETSYNC_TEXT N_("Network master clock") -#define NETSYNC_LONGTEXT N_("When set then " \ - "this vlc instance shall dictate its clock for synchronisation" \ - "over clients listening on the masters network ip address") +#define NETSYNC_LONGTEXT N_("When set, " \ + "this VLC instance will act as the master clock for synchronization " \ + "for clients listening") #define MIP_TEXT N_("Master server ip address") #define MIP_LONGTEXT N_("The IP address of " \ - "the network master clock to use for clock synchronisation.") + "the network master clock to use for clock synchronization.") #define NETSYNC_TIMEOUT_TEXT N_("UDP timeout (in ms)") -#define NETSYNC_TIMEOUT_LONGTEXT N_("Amount of time (in ms) " \ - "to wait before aborting network reception of data.") +#define NETSYNC_TIMEOUT_LONGTEXT N_("Length of time (in ms) " \ + "until aborting data reception.") vlc_module_begin() set_shortname(N_("Network Sync")) - set_description(N_("Network synchronisation")) + set_description(N_("Network synchronization")) set_category(CAT_ADVANCED) set_subcategory(SUBCAT_ADVANCED_MISC) - add_bool("netsync-master", false, NULL, + add_bool("netsync-master", false, NETSYNC_TEXT, NETSYNC_LONGTEXT, true) - add_string("netsync-master-ip", NULL, NULL, MIP_TEXT, MIP_LONGTEXT, + add_string("netsync-master-ip", NULL, MIP_TEXT, MIP_LONGTEXT, true) - add_integer("netsync-timeout", 500, NULL, + add_integer("netsync-timeout", 500, NETSYNC_TIMEOUT_TEXT, NETSYNC_TIMEOUT_LONGTEXT, true) set_capability("interface", 0) @@ -127,7 +125,6 @@ static int Open(vlc_object_t *object) return VLC_EGENERIC; } - intf->pf_run = NULL; intf->p_sys = sys = malloc(sizeof(*sys)); if (!sys) { net_Close(fd); @@ -180,7 +177,7 @@ static void *Master(void *handle) struct pollfd ufd = { .fd = sys->fd, .events = POLLIN, }; uint64_t data[2]; - if (poll(&ufd, 1, -1) <= 0) + if (poll(&ufd, 1, -1) < 0) continue; /* We received something */ @@ -233,11 +230,8 @@ static void *Slave(void *handle) goto wait; /* Don't block */ - int ret = poll(&ufd, 1, sys->timeout); - if (ret == 0) + if (poll(&ufd, 1, sys->timeout) <= 0) continue; - if (ret < 0) - goto wait; const mtime_t receive_date = mdate(); if (recv(sys->fd, data, sizeof(data), 0) <= 0) @@ -295,16 +289,21 @@ static int PlaylistEvent(vlc_object_t *object, char const *cmd, 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; + assert(sys->input == NULL); - sys->input = vlc_object_hold(input); - if (vlc_clone(&sys->thread, sys->is_master ? Master : Slave, intf, - VLC_THREAD_PRIORITY_INPUT)) { - vlc_object_release(input); - return VLC_SUCCESS; + + if (input != NULL) + { + sys->input = vlc_object_hold(input); + if (vlc_clone(&sys->thread, sys->is_master ? Master : Slave, intf, + VLC_THREAD_PRIORITY_INPUT)) { + vlc_object_release(input); + sys->input = NULL; + return VLC_SUCCESS; + } + var_AddCallback(input, "intf-event", InputEvent, intf); } - var_AddCallback(input, "intf-event", InputEvent, intf); return VLC_SUCCESS; }