summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2011-05-13 12:56:37 (GMT)
committer Jaromil <jaromil@dyne.org>2011-05-13 12:56:37 (GMT)
commitd4c5f6cf838e947ae1df3f5680a5a7f5ba8a7d35 (patch)
treea2f004539adb4aebbd28bd356660338c3444a4a4
parentcd55271dc7737d89c1a8a35ab19c0cf165565264 (diff)
fixes to looping and various other things
-rw-r--r--doc/hdsync_manual.org2
-rw-r--r--scripts/S88hdsync15
-rw-r--r--scripts/hdsync.conf2
-rwxr-xr-xscripts/listen-sync.sh76
-rwxr-xr-xscripts/offer-sync.sh91
-rw-r--r--scripts/utils-sync.sh15
6 files changed, 119 insertions, 82 deletions
diff --git a/doc/hdsync_manual.org b/doc/hdsync_manual.org
index c969b06..d3eaa8e 100644
--- a/doc/hdsync_manual.org
+++ b/doc/hdsync_manual.org
@@ -73,7 +73,7 @@ the sync-starters will connect: (*HDSYNC_NETWORK*) if the IP will be
dynamically assigned (DYNAMIC) or if the devices are connected on
their own local network without a DHCP server (STATIC).
-At last, create a *sync/* directory and put a video file inside. At
+At last, create a *video/* directory and put a video file inside. At
the moment only one video file is supported, the first one in the sync
directory list, so we recommend to put only one file in that directory
to be sure of which one will play.
diff --git a/scripts/S88hdsync b/scripts/S88hdsync
index 422791e..61764eb 100644
--- a/scripts/S88hdsync
+++ b/scripts/S88hdsync
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2010 Denis Roio <jaromil@nimk.nl>
+# Copyright (C) 2010-2011 Denis Roio <jaromil@nimk.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,8 +17,11 @@
# wait the boot to complete
+APPROOT=/apps/hdsync
+
if [ "$1" = "stop" ]; then
- $AV -p $UPNPPORT stop
+ UPNPPORT="`lsof -a -i4 -sTCP:LISTEN -c DMARender -F n | awk -v FS=':' '/^n/ {print $2}'`"
+ $APPROOT/bin/avremote -p $UPNPPORT stop
rm -f /tmp/hdsync.reply
umount /apps/hdsync
exit 0
@@ -26,10 +29,6 @@ fi
sleep 15
-APPROOT=/apps/hdsync
-
-# kill dmaosd!
-killall dmaosd
touch /tmp/hdsync.log
# USBROOT=`mount | awk '/.tmp.mnt/ { print $3}'`
@@ -58,6 +57,7 @@ export USBROOT
export APPROOT
export HDSYNC_NETWORK
export HDSYNC_CHANNEL
+export HDSYNC_SLEEP
export TOTAL_CHANNELS
# load up utils
@@ -69,6 +69,9 @@ get_ip
# retrieve application details
get_bins $APPROOT
+if [ $HDSYNC_SLEEP ]; then
+ echo "SLEEP adjust set to $HDSYNC_SLEEP seconds" >> /tmp/hdsync.log
+fi
UPNPPORT="`lsof -a -i4 -sTCP:LISTEN -c DMARender -F n | awk -v FS=':' '/^n/ {print $2}'`"
export UPNPPORT
diff --git a/scripts/hdsync.conf b/scripts/hdsync.conf
index 835c2e1..bbe40e6 100644
--- a/scripts/hdsync.conf
+++ b/scripts/hdsync.conf
@@ -11,6 +11,8 @@ HDSYNC_CHANNEL=1
# be careful this number is unique across your players
# channel 1 is always the server, others are clients
+HDSYNC_SLEEP=0
+
# total video channels expected
TOTAL_CHANNELS=2
diff --git a/scripts/listen-sync.sh b/scripts/listen-sync.sh
index 3c955a9..bc4bbbd 100755
--- a/scripts/listen-sync.sh
+++ b/scripts/listen-sync.sh
@@ -17,7 +17,7 @@
PATH=/usr/bin:/bin:/usr/sbin:/sbin
-. /apps/hdsync/bin/utils-sync.sh
+. $APPROOT/bin/utils-sync.sh
# launch background listener for acks
@@ -28,37 +28,51 @@ touch /tmp/hdsync.reply
echo $answer >> /tmp/hdsync.reply
done) &
-echo "listening for offers on $IP"
-
-offer="`echo | $NC -c -u -l -p 3332`"
-
-echo "offered sync by $offer"
-
-
+# loop continuously
+while [ true ]; do
+ sleep 3
+ lsof | grep video > /dev/null
+ if [ $? == 1 ]; then
+
+ rm -f /tmp/hdsync.reply
+ touch /tmp/hdsync.reply
+
+ echo "listening for offers on $IP"
+
+ offer="`echo | $NC -c -u -l -p 3332`"
+
+ echo "offered sync by $offer"
+
+
# repeat udp replies to offer until ack
-echo "replying with our ip until ack"
-ack=""
-while [ "$ack" = "" ]; do
- sleep 1
- echo "$IP" | $NC -c -u $offer 3331
- echo -n "."
- ack=`cat /tmp/hdsync.reply`
+ echo "replying with our ip until ack"
+ ack=""
+ while [ "$ack" = "" ]; do
+ sleep 1
+ echo "$IP" | $NC -c -u $offer 3331
+ echo -n "."
+ ack=`cat /tmp/hdsync.reply`
+ done
+
+ echo "ack received, we are channel $ack"
+
+ sync
+
+ echo "ready: awaiting syncstarter signal"
+
+
+ # exit after connection (-e true)
+ $NC -c -u -l -p 3336 -e true
+
+ if [ $HDSYNC_SLEEP ]; then
+ sleep $HDSYNC_SLEEP
+ fi
+
+ # "press play on tape"
+ $AV -p $UPNPPORT play
+
+ echo "sync playback started on `date +%T`"
+ fi
done
-echo "ack received, we are channel $ack"
-
-sync
-
-echo "ready: awaiting syncstarter signal"
-
-
-# exit after connection (-e true)
-$NC -c -u -l -p 3336 -e true
-
-
-# "press play on tape"
-$AV -p $UPNPPORT play
-
-echo "sync playback started on `date +%T`"
-
diff --git a/scripts/offer-sync.sh b/scripts/offer-sync.sh
index f3981e5..e16d758 100755
--- a/scripts/offer-sync.sh
+++ b/scripts/offer-sync.sh
@@ -27,45 +27,58 @@ touch /tmp/hdsync.reply
echo $answer >> /tmp/hdsync.reply
done) &
-echo "broadcasting offer signals from $IP"
- # we do broadcast only on class C
- # must always make sure also listener expects on class C
-bcast=`echo $IP | awk 'BEGIN { FS="." } {print $1 "." $2 "." $3 }'`.255
-echo "to netmask $bcast"
-
-# send broadcast signals until somebody listens
-listeners=0
-expected=`expr $TOTAL_CHANNELS - 1`
-while [ "$listeners" != "$expected" ]; do
- echo -n "$b: `date +%X` "
- $BC $bcast 3332 $IP
- sleep 2
- listeners=`cat /tmp/hdsync.reply | sort | uniq | wc -w`
-done
-
-echo "harvesting replies"
-cat /tmp/hdsync.reply | sort | uniq > /tmp/hdsync.listeners
-
-echo "sending acks"
-c=1
-for l in `cat /tmp/hdsync.listeners`; do
- echo "$c: $l"
- echo "$c" | $NC -c -u $l 3333
-done
-
+# loop continuously
+while [ true ]; do
+ sleep 5
+ lsof | grep video > /dev/null
+ if [ $? == 1 ]; then # no video is running
-echo "waiting for other players to get ready..."
-sleep 10
+ rm -f /tmp/hdsync.reply
+ touch /tmp/hdsync.reply
-sync
-
-# sync start!
-$BC $bcast 3336 s
-
-# wait network latency
-sleep 0.1
-
-# "press play on tape"
-$AV -p $UPNPPORT play
+ echo "broadcasting offer signals from $IP"
+ # we do broadcast only on class C
+ # must always make sure also listener expects on class C
+ bcast=`echo $IP | awk 'BEGIN { FS="." } {print $1 "." $2 "." $3 }'`.255
+ echo "to netmask $bcast"
+
+ # send broadcast signals until somebody listens
+ listeners=0
+ expected=`expr $TOTAL_CHANNELS - 1`
+ while [ "$listeners" != "$expected" ]; do
+ echo -n "$b: `date +%X` "
+ $BC $bcast 3332 $IP
+ sleep 2
+ listeners=`cat /tmp/hdsync.reply | sort | uniq | wc -w`
+ done
-echo "sync playback started on `date +%T`"
+ echo "harvesting replies"
+ cat /tmp/hdsync.reply | sort | uniq > /tmp/hdsync.listeners
+
+ echo "sending acks"
+ c=1
+ for l in `cat /tmp/hdsync.listeners`; do
+ echo "$c: $l"
+ echo "$c" | $NC -c -u $l 3333
+ done
+
+
+ echo "waiting for other players to get ready..."
+ sync
+ sleep 10
+
+
+
+ # sync start!
+ $BC $bcast 3336 s
+
+ if [ $HDSYNC_SLEEP ]; then
+ sleep $HDSYNC_SLEEP
+ fi
+
+ # "press play on tape"
+ $AV -p $UPNPPORT play
+
+ echo "sync playback started on `date +%T`"
+ fi
+done \ No newline at end of file
diff --git a/scripts/utils-sync.sh b/scripts/utils-sync.sh
index 5c3e1a7..36d4f9c 100644
--- a/scripts/utils-sync.sh
+++ b/scripts/utils-sync.sh
@@ -62,18 +62,23 @@ prepare_play() {
config_tool -c DMA_ENABLE_SCREENSAVER='0'
config_tool -c DMA_SCREENSAVER='0'
- file=`ls $USBROOT/sync`
- $AV -p $UPNPPORT load "$USBROOT/sync/$file"
+ file=`ls $USBROOT/video`
+ $AV -p $UPNPPORT load "$USBROOT/video/$file"
sync
$AV -p $UPNPPORT play
- sleep 0.2
+ sync
+ sleep 5
- $AV -p $UPNPPORT pause
+ $AV -p $UPNPPORT stop
- sync
+ # kill dmaosd!
+ killall dmaosd
+
+ # $AV -p $UPNPPORT pause
+ # sync
echo "ready to play on `date +%T`"
}