/*****************************************************************************
- * 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);
sys->timeout = var_InheritInteger(intf, "netsync-timeout");
if (sys->timeout < 500)
sys->timeout = 500;
- sys->playlist = pl_Hold(intf);
+ sys->playlist = pl_Get(intf);
sys->input = NULL;
var_AddCallback(sys->playlist, "input-current", PlaylistEvent, intf);
assert(sys->input == NULL);
var_DelCallback(sys->playlist, "input-current", PlaylistEvent, intf);
- pl_Release(intf);
net_Close(sys->fd);
free(sys);
}
static mtime_t GetPcrSystem(input_thread_t *input)
{
int canc = vlc_savecancel();
+ /* TODO use the delay */
mtime_t system;
- if (input_GetPcrSystem(input, &system))
+ if (input_GetPcrSystem(input, &system, NULL))
system = -1;
vlc_restorecancel(canc);
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 */
: "non-IPv4", /*date*/ 0);
#endif
}
+ return NULL;
}
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)
int canc = vlc_savecancel();
mtime_t client_system;
- if (!input_GetPcrSystem(sys->input, &client_system)) {
+ if (!input_GetPcrSystem(sys->input, &client_system, NULL)) {
const mtime_t diff_system = client_system - master_system - diff_date;
if (diff_system != 0) {
input_ModifyPcrSystem(sys->input, true, master_system - diff_date);
wait:
msleep(INTF_IDLE_SLEEP);
}
+ return NULL;
}
static int InputEvent(vlc_object_t *object, char const *cmd,