changes to runvdr for a nexus-s

Message ID 44FD8B97.7030206@syphir.sytes.net
State New
Headers

Commit Message

C.Y.M Sept. 5, 2006, 2:37 p.m. UTC
  Here is an example of the changes that I have had to make to runvdr so that my
nexus-s works.  I have added a maximum retry value to runvdr so that vdr will
not keep attempting to start over and over if there is a major problem with
reception.  Also, I have added a minimum runtime (in seconds) that vdr must have
in order to continue attempting to restart after a crash.  For example, if vdr
crashes within 10 seconds and the minimum runtime required is 45 seconds, then
runvdr will consider that VDR has major problems and it will not try to keep
restarting up to the maximum allowed retries.  However, the maximum retry value
can be set to "0" which would tell runvdr to attempt a restart unlimited times
after crashing.

BR.
#!/bin/sh
# insmod modules from current directory without having to install them first
# KERNELVER=`uname -r`
# KERNELDIR="/lib/modules/$KERNELVER/misc"

sync

function DriverLoaded()
{
  grep -qse dvb[-_]core /proc/modules
}

case "$1" in
    load)
	if ! DriverLoaded; then
	echo -n -e "\nInserting DVB modules into kernel\n"
	# av7110 based "full featured" cards
	modprobe stv0299
	# saa7146 based siemens/technotrend/hauppauge cards
	modprobe dvb-ttpci
	# wait for udev to create the devices before continuing
	until [ -e /dev/dvb/adapter0/video0 ]; do
	  sleep 1
	done
	if [ -e "/usr/local/bin/loadkeys/av7110_loadkeys" ]; then
	/usr/local/bin/loadkeys/av7110_loadkeys /usr/local/bin/loadkeys/hauppauge_grey.rc5 > /proc/av7110_ir
	sleep 1
	fi
	else
	echo -e "DVB Drivers already loaded..\n"
	fi
	;;
    debug)
	if ! DriverLoaded; then
	echo -n -e "\nInserting DVB modules (debug) into kernel\n"
	# av7110 based "full featured" cards
	modprobe stv0299 debug_switch_timing=1
	# saa7146 based siemens/technotrend/hauppauge cards
	modprobe dvb-ttpci debug=247
	until [ -e /dev/dvb/adapter0/video0 ]; do
	  sleep 1
	done
	if [ -e "/usr/local/bin/loadkeys/av7110_loadkeys" ]; then
	/usr/local/bin/loadkeys/av7110_loadkeys /usr/local/bin/loadkeys/hauppauge_grey.rc5 > /proc/av7110_ir
	sleep 1
	fi
	else
	echo -e "DVB Drivers already loaded..\n"
	fi
	;;
    unload)
        if lsmod | grep -q "^$(echo dvb_ttpci|sed -e 's/-/_/g') " > /dev/null 2>&1; then
	echo -n -e "\nRemoving DVB modules from kernel\n"
	rmmod ves1x93 dvb_ttpci saa7146_vv video_buf saa7146 videodev v4l1_compat \
		v4l2_common ttpci_eeprom stv0299 dvb_core
	echo
	else
	echo -e "DVB Drivers not loaded..\n"
	fi
	;;
    reload)
	$0 unload && $0 load
	;;
    *)
	echo "Usage$0 {load|unload|debug|reload}"
	exit 1
esac

sync
  

Patch

--- vdr-1.4.2/runvdr.orig	2006-09-05 06:30:55.000000000 -0700
+++ vdr-1.4.2/runvdr	2006-09-05 06:31:37.000000000 -0700
@@ -22,26 +22,72 @@ 
 #
 # $Id: runvdr 1.19 2006/05/14 16:02:05 kls Exp $
 
-VDRPRG="./vdr"
-VDRCMD="$VDRPRG -w 60 $*"
+## Start Configuration Section ##
 
+# Disable NPTL (recommended)
+export LD_ASSUME_KERNEL=2.4.1
+#export LD_ASSUME_KERNEL=2.4.19
+
+# Uncomment to disable UTF-8 within VDR
+#export LANG=en_US
+#export LC_CTYPE=iso_8859_1
+
+PLUGINS="-Premote -Pscreenshot -Pepgsearch -Pprefermenu -Pdvdselect -Pvcd -Pfemon -Ptaste -Pstreamdev-server -Pstreamplayer -Ptext2skin -Pyaepg -Pundelete -Pweatherng -Posdpip -Pmplayercluster -Peggtimer -Psysinfo -Plocals -Pradioinfo -P'mp3 -C /etc/vdr -m /etc/vdr/plugins/mount.sh -i /etc/vdr/plugins/image_convert.sh -c /etc/vdr/images' -P'dvd -C/dev/cdrom' -P'mplayer -M /etc/vdr/plugins/mplayer.sh -m /etc/vdr/plugins/mount.sh' -P'xine -r -X 720 -Y 480'"
+
+# VDR Recording directory (default is usually /video)
+VIDEO_DIR="/video"
+# VDR Configuration directory where setup.conf lives
+CFG_DIR="/etc/vdr"
+# Where the VDR epg.data file lives
+EPG_DIR="/etc/vdr"
+# Search path for VDR plugins
+PLUG_DIR="/usr/local/bin/PLUGINS/lib"
+# Startup Options passed to VDR
+OPTIONS="--terminal=/dev/tty8 -l 3 -w 0 --grab=/tmp"
+# Path to VDR binary
+VDRPRG="/usr/local/bin/vdr"
+# Path to insdvb.sh (for loading dvb modules)
+INSDVB="/usr/local/bin/insdvb.sh"
+# Path to mplayer
+MPLAY="/usr/bin/mplayer"
+# Path to startup video
+VIDEO="/etc/vdr/VDRboot-NTSC.mpeg"
+# Number of times runvdr will attempt to restart vdr after a crash has occured (set to 0 for no limit)
+MAXTRIES=10
+# Minimum runtime required (in seconds) for vdr to continue restart attempts
+MINRUN=45
+
+## End Configuration Section ##
+
+if [ ! -e "${INSDVB}" ]; then
+   echo -e "ERROR: ${INSDVB} was not detected.  Exiting. \n"
+   exit 0
+fi
+
+VDRCMD="$VDRPRG -v $VIDEO_DIR -E $EPG_DIR -c $CFG_DIR -L $PLUG_DIR $OPTIONS $PLUGINS"
 KILL="/usr/bin/killall -q -TERM"
 
 # Detect whether the DVB driver is already loaded
 # and return 0 if it *is* loaded, 1 if not:
 function DriverLoaded()
 {
-  return 1
+  grep -qse dvb[-_]core /proc/modules
 }
 
 # Load all DVB driver modules needed for your hardware:
 function LoadDriver()
 {
+  ${INSDVB} load
+  if [ -e "${MPLAY}" ]; then
+    ${MPLAY} -frames 145 -vo mpegpes -ao mpegpes ${VIDEO} 2>/dev/null 1>/dev/null
+  fi
+  echo
 }
 
 # Unload all DVB driver modules loaded in LoadDriver():
 function UnloadDriver()
 {
+  ${INSDVB} unload
 }
 
 # Load driver if it hasn't been loaded already:
@@ -49,13 +95,26 @@ 
    LoadDriver
    fi
 
+LASTRESTART=$(date +%s)
+LOOPCOUNT=0
 while (true) do
-      eval "$VDRCMD"
+      if [ $LOOPCOUNT -le $MAXTRIES ] || [ $MAXTRIES -eq 0 ] ; then
+        eval "$VDRCMD"
+      else
+        $KILL runvdr
+      fi
       if test $? -eq 0 -o $? -eq 2; then exit; fi
-      echo "`date` reloading DVB driver"
-      $KILL $VDRPRG
+      TIMEOFDEATH=$(date +%s)
+      if [ $TIMEOFDEATH -le $(($LASTRESTART + $MINRUN)) ] ; then
+        echo "`date` VDR crashed in `expr $TIMEOFDEATH - $LASTRESTART` seconds. Minimum required runtime for VDR is $MINRUN seconds. Killing runvdr process..."
+        $KILL runvdr
+      fi
+      echo "`date` Reloading DVB drivers"
+      $KILL vdr
       sleep 10
       UnloadDriver
       LoadDriver
-      echo "`date` restarting VDR"
+      LASTRESTART=$(date +%s)
+      LOOPCOUNT=`expr $LOOPCOUNT + 1`
+      echo "`date` Restarting VDR $LOOPCOUNT time(s). Maximum retries set to $MAXTRIES"
       done