[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[abcde] abcde patch




Hi there,

I've made some modifications to abcde and I though I would share them
with you.

I've worked on completing the parallelism and the support for distmp3.

I'll quickly resume what I changed
First of all I've moved $ABCDETEMPDIR to $WAVOUTPUTDIR which is 
pretty usefull in my case since I want to store the completed MP3 on 
an NFS server but I want to rip locally.

When I started playing around in the script I incorrectly thought the 
way you were choosing the LOCATION was broken without really looking 
into the mechanics first so I started changing it for something else. 
What I wanted is to have something that always choose the first 
available location in $REMOTEHOSTS instead of going round robin in 
them (which I think is what you did using modulo if i'm not 
mistaken). I guess this behavior could be changed as a config option. 
I can imagine different network setup where some will want round 
robin and some will want first listed, first served.

Also distmp3 can use the ":" in the hostname field as a way to 
specify the port, so I used a space as the separator in 
$ENCODELOCATION instead of the ":" to make it possible to specify a 
port with hostnames in the config file.

I added another status file message so that the main script can wait 
for the encoding childs to be done before cleaning up.

The patch should apply cleanely to 1.9.7

Feedback is welcome.

David


-- Attached file included as plaintext by Listar --

--- abcde.orig	Sun Jan 14 00:18:43 2001
+++ abcde	Sun Jan 14 00:19:02 2001
@@ -211,7 +211,7 @@
 	run_command '' echo "Encoding track $1 of $TRACKS: $TRACKNAME..."
 	case "$OUTPUTTYPE" in
 	mp3)
-		if [ "$2" != "" ]; then
+		if [ "$2" != "__local__" ]; then
 			run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTS $2 "$IN" "$OUT"
 		else
 			case "$ENCODERSYNTAX" in
@@ -339,7 +339,7 @@
 	# We have the discid, create a temp directory after it to store all the temp
 	# info
 	
-	ABCDETEMPDIR="$OUTPUTDIR/abcde.$(echo $TRACKINFO | cut -f1 -d' ')"
+	ABCDETEMPDIR="$WAVOUTPUTDIR/abcde.$(echo $TRACKINFO | cut -f1 -d' ')"
 	if [ -e "$ABCDETEMPDIR" ]; then
 		echo -n "abcde: attempting to resume from $ABCDETEMPDIR"
 		# It already exists, see if it's a directory
@@ -1028,28 +1028,50 @@
 # Do the encoding, including parallelization of remote encoding
 # Figure out where each track is going to be encoded
 NUMLOCATIONS=0
-ENCODELOCATION=""
-for REMOTEHOST in $(echo $REMOTEHOSTS | sed 's-,- -g')
+ENCODELOCATIONS=""
+while [ "$NUMLOCATIONS" != "$MAXPROCS" ]
 do
-	if [ "$NUMLOCATIONS" = "0" ]; then
-		ENCODELOCATION=$REMOTEHOST
-	else
-		ENCODELOCATION=$REMOTEHOST:$ENCODELOCATION
-	fi
+	ENCODELOCATIONS="$ENCODELOCATIONS __local__"
 	NUMLOCATIONS=$(expr $NUMLOCATIONS + 1)
 done
-NUMPROCS=0
-while [ "$NUMPROCS" != "$MAXPROCS" ]
+
+for REMOTEHOST in $(echo $REMOTEHOSTS | sed 's-,- -g')
 do
-	NUMPROCS=$(expr $NUMPROCS + 1)
-	ENCODELOCATION=$ENCODELOCATION:
+	ENCODELOCATIONS="$ENCODELOCATIONS $REMOTEHOST"
 	NUMLOCATIONS=$(expr $NUMLOCATIONS + 1)
 done
-for I in $(seq 1 $QUEUEDTRACKS)
+ENCODELOCATIONS=$(echo $ENCODELOCATIONS | cut -b 2-)
+for UTRACKNUM in $TRACKQUEUE
 do
-	UTRACKNUM=$(echo $TRACKQUEUE | cut '-d ' -f$I)
-	LOCATION=$(echo $ENCODELOCATION | cut -d: -f$(expr $(expr $I - 1) % $NUMLOCATIONS + 1))
 	read FOO # For blocking only - $FOO never gets used
+	# find out where this track is to be encoded
+	if [ "$DOENCODE" = "y" ]; then
+		PROCEED=0
+		until [ "$PROCEED" = "1" ]
+		do
+			X=0
+			for LOCATION in $ENCODELOCATIONS
+			do
+				X=$(expr $X + 1)
+				# check first if a track has ever been assigned to this location
+				if [ "${LOCTRACK[$X]}" = "" ]; then
+					LOCTRACK[$X]=$UTRACKNUM
+					PROCEED=1
+					break
+				else
+					# else check if the location is done encoding it's previously assigned track
+					if checkstatus ^encodetrack-${LOCTRACK[$X]}
+					then
+						LOCTRACK[$X]=$UTRACKNUM
+						PROCEED=1
+						break
+					fi
+				fi
+			done
+			# all locations are working, wait and try again later
+			if [ "$PROCEED" = "0" ]; then sleep 5; fi
+		done
+	fi
 	( # Set TRACKNUM, TRACKNAME
 	if [ -e "$CDDBDATA" ]; then
 		TRACKNUM=$(printf %0.${TRACKNUMPADDING}d ${UTRACKNUM})
@@ -1066,12 +1088,20 @@
 	if [ "$DOMOVE" = "y" ]; then
 		if checkstatus ^movetrack-$UTRACKNUM; then :; else do_move $UTRACKNUM; fi
 	fi
-	)
+	# log in status that this track is finished
+	echo "alldone-$UTRACKNUM" >> "$ABCDETEMPDIR/status"
+	) &
 done
+# make sure every tracks are done or else wait for them
+for UTRACKNUM in $TRACKQUEUE
+do
+	until checkstatus alldone-$UTRACKNUM; do sleep 10; done
+done
+)
+
 echo Finished.
 if [ "$DOCLEAN" = "y" ]; then
 	# Wipe all the evidence
 	rm -rf "$ABCDETEMPDIR"
 fi
-)
 exit 0


To unsubscribe: echo unsubscribe | mail abcde-request@whimsica.lly.org