Przeglądaj źródła

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

Zachary Kotlarek 13 lat temu
rodzic
commit
7838931a4e
1 zmienionych plików z 11 dodań i 2 usunięć
  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();