Mercurial > mplayer.hg
diff udp_sync.c @ 33155:16e5b7f9ddb8
Send udp master updates also when paused and let slave use normal timing
when it gets no messages.
This allows the slave to continue playing normally if the master crashes
or network stops working instead of hanging forever.
Note that the slave might still hang for the 30 second network timeout
in some cases.
author | reimar |
---|---|
date | Sat, 09 Apr 2011 14:55:22 +0000 |
parents | 5dcbfb18ad58 |
children | 9ac31195a5e0 |
line wrap: on
line diff
--- a/udp_sync.c Sat Apr 09 14:47:16 2011 +0000 +++ b/udp_sync.c Sat Apr 09 14:55:22 2011 +0000 @@ -53,9 +53,6 @@ // (can be a broadcast address) float udp_seek_threshold = 1.0; // how far off before we seek -// remember where the master is in the file -static double udp_master_position = -1.0; - // how far off is still considered equal #define UDP_TIMING_TOLERANCE 0.02 @@ -84,6 +81,9 @@ int n; static int sockfd = -1; + + *master_position = MP_NOPTS_VALUE; + if (sockfd == -1) { struct timeval tv = { .tv_sec = 30 }; struct sockaddr_in servaddr = { 0 }; @@ -159,10 +159,12 @@ // position. returns 1 if the master tells us to exit, 0 otherwise. int udp_slave_sync(MPContext *mpctx) { + double udp_master_position; + // grab any waiting datagrams without blocking int master_exited = get_udp(0, &udp_master_position); - while (!master_exited) { + while (udp_master_position != MP_NOPTS_VALUE && !master_exited) { double my_position = mpctx->sh_video->pts; // if we're way off, seek to catch up