summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2011-12-13 16:32:57 (GMT)
committer Jaromil <jaromil@dyne.org>2011-12-13 16:32:57 (GMT)
commit18f41743f4fd481d83208b24ddcd8b2a2978ec3d (patch)
tree8ef4b550895a8522970473f6d580654d474130c0
parentbf55544f02a7b75490d5a45a21e022bf8a33f048 (diff)
more fixes to integrate the watchdog script into 0.6watchdog
includes testing of normal functioning needs testing if the watchdog solves the long-term freeze
-rw-r--r--scripts/S88hdsync3
-rw-r--r--scripts/hdsync.conf8
-rwxr-xr-xscripts/listen-sync.sh50
-rwxr-xr-xscripts/offer-sync.sh36
-rw-r--r--scripts/utils-sync.sh40
-rwxr-xr-xscripts/watchdog.sh30
6 files changed, 92 insertions, 75 deletions
diff --git a/scripts/S88hdsync b/scripts/S88hdsync
index 7f428a4..8e4b792 100644
--- a/scripts/S88hdsync
+++ b/scripts/S88hdsync
@@ -91,9 +91,6 @@ killall pandora_ep
killall apache2
killall smbtree
-# will get ready for play button
-prepare_play >> /tmp/hdsync.log
-
if test $WATCHDOGTIMER -gt 0; then
#start watchdog timer
echo "starting watchdog, movielenght is $WATCHDOGTIMER"
diff --git a/scripts/hdsync.conf b/scripts/hdsync.conf
index bbe40e6..abbf40f 100644
--- a/scripts/hdsync.conf
+++ b/scripts/hdsync.conf
@@ -3,7 +3,8 @@
# Network configuration to use: DYNAMIC or STATIC
# DYNAMIC = use the DHCP daemon on LAN to assign IPs
-# STATIC = most of the time you'll need this
+# STATIC = auto-configure IPs for LAN (use this if you don't know)
+# MANUAL = don't change the current configuration
HDSYNC_NETWORK=DYNAMIC
# number of this video channel
@@ -16,3 +17,8 @@ HDSYNC_SLEEP=0
# total video channels expected
TOTAL_CHANNELS=2
+# watchdog activation
+# if you like to run an additional watchdog process to look over
+# the playback and avoid long-term freezes, fill in here the duration
+# of the video in seconds, approximated to the minimum (experimental feature)
+# WATCHDOGTIMER=360
diff --git a/scripts/listen-sync.sh b/scripts/listen-sync.sh
index fb65114..046d370 100755
--- a/scripts/listen-sync.sh
+++ b/scripts/listen-sync.sh
@@ -4,7 +4,7 @@
#
# 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
-# the Free Software Foundation, either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -35,23 +35,31 @@ while [ true ]; do
# check the state of the video
state=`$AV -s localhost -p $UPNPPORT get 2>&1| awk '/^TInfo:/ {print $2}'`
-# echo "`date +%T` state (avremote) is $state"
+ echo "`date +%T` state (avremote) is $state"
- lsof | grep video/?* > /dev/null
- if [ $? == 1 ]; then # no video is running
+ if [ "$state" == "NO_MEDIA_PRESENT" ]; then
+
+ # will get ready for sync
+ prepare_play >> /tmp/hdsync.log
+
+ elif [ "$state" == "STOPPED" ]; then
+
+ # will get ready for sync again
+ prepare_play >> /tmp/hdsync.log
+
+ elif [ "$state" == "PAUSED_PLAYBACK" ]; then
+ # will sync start
- # will sync start
- . $USBROOT/hdsync.conf
rm -f /tmp/hdsync.reply
touch /tmp/hdsync.reply
-
+
echo "`date +%T` listening for offers on $IP"
-
+
offer="`echo | $NC -c -u -l -p 3332`"
-
+
echo "`date +%T` offered sync by $offer"
-
- # repeat udp replies to offer until ack
+
+ # repeat udp replies to offer until ack
echo "`date +%T` replying with our ip until ack"
ack=""
while [ "$ack" = "" ]; do
@@ -60,24 +68,22 @@ while [ true ]; do
echo -n "."
ack=`cat /tmp/hdsync.reply`
done
-
+
echo "`date +%T` ack received, we are channel $ack"
-
+
echo "`date +%T` ready: awaiting syncstarter signal"
-
-
- # exit after connection (-e true)
+
+
+ # exit after connection (-e true)
$NC -c -u -l -p 3336 -e true
-
+
if [ $HDSYNC_SLEEP ]; then
usleep $HDSYNC_SLEEP
fi
-
- # "press play on tape"
- $AV -p $UPNPPORT play
-
+
+ # "press play on tape"
+ $SYNC -s localhost -p $UPNPPORT start
echo "`date +%T` sync playback started"
fi
done
-
diff --git a/scripts/offer-sync.sh b/scripts/offer-sync.sh
index f3848c5..dfc23b4 100755
--- a/scripts/offer-sync.sh
+++ b/scripts/offer-sync.sh
@@ -4,7 +4,7 @@
#
# 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
-# the Free Software Foundation, either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -36,12 +36,20 @@ while [ true ]; do
# check the state of the video
state=`$AV -s localhost -p $UPNPPORT get 2>&1| awk '/^TInfo:/ {print $2}'`
-# echo "`date +%T` state (avremote) is $state"
+ echo "`date +%T` state (avremote) is $state"
- lsof | grep video/?* > /dev/null
- if [ $? == 1 ]; then # no video is running
+ if [ "$state" == "NO_MEDIA_PRESENT" ]; then
- . $USBROOT/hdsync.conf
+ # will get ready for sync
+ prepare_play >> /tmp/hdsync.log
+
+ elif [ "$state" == "STOPPED" ]; then
+
+ # will get ready for sync again
+ prepare_play >> /tmp/hdsync.log
+
+ elif [ "$state" == "PAUSED_PLAYBACK" ]; then
+ # will sync start
rm -f /tmp/hdsync.reply
touch /tmp/hdsync.reply
@@ -52,14 +60,14 @@ while [ true ]; do
bcast=`echo $IP | awk 'BEGIN { FS="." } {print $1 "." $2 "." $3 }'`.255
echo "to netmask $bcast"
- # send broadcast signals until somebody listens
+ # send broadcast signals until somebody listens
listeners=0
expected=`expr $TOTAL_CHANNELS - 1`
while [ $listeners -lt $expected ]; do
echo -n "`date +%X` "
$BC $bcast 3332 $IP
listeners=`cat /tmp/hdsync.reply | sort | uniq | wc -w`
- sleep 1
+ sleep 1
done
# echo "harvesting replies"
@@ -76,24 +84,22 @@ while [ true ]; do
echo "`date +%T` waiting for other players to get ready..."
sync
- # sync start in 2 seconds!
+ # sync start in 2 seconds!
(sleep 2
$BC $bcast 3336 s >> /dev/null) &
- # exit after connection (-e true)
+ # exit after connection (-e true)
$NC -c -u -l -p 3336 -e true
if [ $HDSYNC_SLEEP ]; then
- usleep $HDSYNC_SLEEP
+ usleep $HDSYNC_SLEEP
fi
- # "press play on tape"
- $AV -p $UPNPPORT play
-
+ # "press play on tape"
+ $SYNC -s localhost -p $UPNPPORT start
echo "`date +%T` sync playback started"
fi
-$BC $bcast 3336 s >> /dev/null # keep broadcasting in case someone didnt get the message
+# $BC $bcast 3336 s >> /dev/null # keep broadcasting in case someone didnt get the message
done
-
diff --git a/scripts/utils-sync.sh b/scripts/utils-sync.sh
index d58f14a..9b731a2 100644
--- a/scripts/utils-sync.sh
+++ b/scripts/utils-sync.sh
@@ -4,7 +4,7 @@
#
# 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
-# the Free Software Foundation, either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -23,20 +23,20 @@ get_conf() {
get_ip() {
if [ "$HDSYNC_NETWORK" = "DYNAMIC" ]; then
- echo "`date +%T` listening for DHCP assigned IP on the network"
- config_tool -c LAN_TYPE='d'
- IP=`get_conf IP2`
+ echo "`date +%T` listening for DHCP assigned IP on the network"
+ config_tool -c LAN_TYPE='d'
+ IP=`get_conf IP2`
elif [ "$HDSYNC_NETWORK" = "STATIC" ]; then
- echo "`date +%T` setting a static network address"
- IP="192.168.0.$HDSYNC_CHANNEL"
- config_tool -c LAN_TYPE='s'
- config_tool -c IP2=$IP
- config_tool -c NETMASK2=255.255.255.0
- ifconfig eth0 $IP netmask 255.255.255.0
- echo "`date +%T` network interface configured with address $IP ..."
+ echo "`date +%T` setting a static network address"
+ IP="192.168.0.$HDSYNC_CHANNEL"
+ config_tool -c LAN_TYPE='s'
+ config_tool -c IP2=$IP
+ config_tool -c NETMASK2=255.255.255.0
+ ifconfig eth0 $IP netmask 255.255.255.0
+ echo "`date +%T` network interface configured with address $IP ..."
else
- IP=`get_conf IP2`
- echo "`date +%T` network interface manualy configured with address $IP ..."
+ IP=`get_conf IP2`
+ echo "`date +%T` network interface manualy configured with address $IP ..."
fi
export IP
}
@@ -67,17 +67,5 @@ get_bins() {
prepare_play() {
file=`ls $USBROOT/video`
- $AV -p $UPNPPORT load "$USBROOT/video/$file"
-
- sync
-
- $AV -p $UPNPPORT play
-
- sync
- sleep 1
-
- $AV -p $UPNPPORT stop
-
- # $AV -p $UPNPPORT pause
- # sync
+ $SYNC -s localhost -p $UPNPPORT prepare "$USBROOT/video/$file"
}
diff --git a/scripts/watchdog.sh b/scripts/watchdog.sh
index e0fbc7b..df8a07b 100755
--- a/scripts/watchdog.sh
+++ b/scripts/watchdog.sh
@@ -1,5 +1,19 @@
#!/bin/sh
#
+# Copyright (C) 2011 Michael van Rosmalen <mvanrosmalen@zya.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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
PATH=/usr/bin:/bin:/usr/sbin:/sbin
@@ -18,19 +32,19 @@ while [ true ]; do
timer=`expr $timer + 5`
# check the state of the video
- state=`upnp-cmd GetTransportInfo | awk '/CurrentTransportState/ {print $3}'`
+ state=`$AV -s localhost -p $UPNPPORT get 2>&1| awk '/^TInfo:/ {print $2}'`
if [ "$state" != $laststate ]; then
- echo "`date +%T` watchdog timer reset after state change to $state"
- timer=0 # reset timer
+ echo "`date +%T` watchdog timer reset after state change to $state"
+ timer=0 # reset timer
fi
if [ $timer -gt $watchdogtimer ]; then
- echo "`date +%T` watchdog timer exceeded, trying to resolve"
- upnp-cmd stop
- sleep 5
- upnp-cmd stop
- timer=`expr $watchdogtimer - 60`
+ echo "`date +%T` watchdog timer exceeded, trying to resolve"
+ $AV -s localhost -p $UPNPPORT stop
+ sleep 5
+ $AV -s localhost -p $UPNPPORT stop
+ timer=`expr $watchdogtimer - 60`
fi
laststate="$state"