/*****************************************************************************
- * netsync.c: synchronisation between several network clients.
+ * netsync.c: synchronization between several network clients.
*****************************************************************************
* Copyright (C) 2004-2009 the VideoLAN team
* $Id$
#include <vlc_input.h>
#include <vlc_playlist.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
#include <sys/types.h>
+#include <unistd.h>
#ifdef HAVE_POLL
# include <poll.h>
#endif
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)
return VLC_EGENERIC;
}
- intf->pf_run = NULL;
intf->p_sys = sys = malloc(sizeof(*sys));
if (!sys) {
net_Close(fd);
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 */
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)
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;
}