Explorar o código

Stat() the file before playing, to be sure we are in-sync over the netowrk

Zachary Kotlarek %!s(int64=13) %!d(string=hai) anos
pai
achega
7838931a4e
Modificáronse 1 ficheiros con 11 adicións e 2 borrados
  1. 11 2
      dmx/leds.pl

+ 11 - 2
dmx/leds.pl

@@ -302,10 +302,15 @@ sub red_alert() {
 		print STDERR "red_alert()\n";
 	}
 
+	my $file  = '/mnt/media/Sounds/DMX/Red Alert.mp3';
+	my @sound = ('afplay', $file);
 	my $ramp  = 450;
-	my @sound = ('afplay', '/mnt/media/Sounds/DMX/Red Alert.mp3');
 	my $sleep = $ramp;
 
+	# Stat the file to bring the network up-to-date
+	stat($file);
+
+	# Bring the B & G channels down to 0
 	my @other = ();
 	push(@other, { 'channel' => 13, 'value' => 0, 'time' => 0 });
 	push(@other, { 'channel' => 15, 'value' => 0, 'time' => 0 });
@@ -341,7 +346,11 @@ sub rave() {
 		print STDERR "rave()\n";
 	}
 
-	my @sound = ('afplay', '/mnt/media/Sounds/DMX/Rave.mp3');
+	my $file  = '/mnt/media/Sounds/DMX/Rave.mp3';
+	my @sound = ('afplay', $file);
+
+	# Stat the file to bring the network up-to-date
+	stat($file);
 
 	# Play the sound in a child (i.e. in the background)
 	$PID = fork();