From 3d5348deb73fb55c17b31eb4ae7cb2dd663306cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sat, 25 Sep 2010 23:54:49 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9tection=20(pourrie)=20de=20fin=20de=20fi?= =?UTF-8?q?chier.=20:(=20:(=20:(=20:(?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mplayerd | 4 ++-- mplayerd-getinfo | 4 ++++ mplayerd-play | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mplayerd b/mplayerd index 5883004..628bb8b 100755 --- a/mplayerd +++ b/mplayerd @@ -5,7 +5,7 @@ source "$(dirname "$0")/config" if [ "$1" == "stop" ]; then if [ -e /dev/shm/mplayer-pid ]; then if ! kill "$(<"$MP_PID")"; then - echo "Failed to kill mplayer" + echo "Failed to kill mplayer." exit 2 fi else @@ -17,5 +17,5 @@ else [ -p "$MP_OUTPUT" ] || mkfifo "$MP_OUTPUT" mplayer -quiet -slave -input file="$MP_CONTROL" -idle > "$MP_OUTPUT" 2> "$MP_ERROR" & - echo "$!" > /dev/shm/mplayer-pid + echo "$!" > "$MP_PID" fi diff --git a/mplayerd-getinfo b/mplayerd-getinfo index 0654d2f..e8309d3 100755 --- a/mplayerd-getinfo +++ b/mplayerd-getinfo @@ -13,6 +13,10 @@ old_album="" cat "$MP_OUTPUT" \ | while read ligne; do + # Détection de la fin de fichier (voir commentaire dans mplayerd-play. + if [ "$ligne" == "Playing /dev/null." ]; then + echo "EOF" + fi # TODO : utiliser grep n'est pas du tout efficace ! if grep -q "^[a-zA-Z_][a-zA-Z0-9_]*='"<<<"$ligne"; then modif=0 diff --git a/mplayerd-play b/mplayerd-play index cfed186..9786d83 100755 --- a/mplayerd-play +++ b/mplayerd-play @@ -3,3 +3,9 @@ source "$(dirname "$0")/config" echo "loadfile '$(readlink -f "$1")' 0" > "$MP_CONTROL" + +# On lit /dev/null après le fichier, pour détecter la fin du fichier. +# Sinon, mplayer ne donne aucune indication comme quoi il est arrivé +# à la fin du fichier (en fait il affiche un "\n", mais c'est dur à +# détecter et il se peut que d'autres évènements en génèrent un aussi). +echo "loadfile '/dev/null' 1" > "$MP_CONTROL"