Browse Source

Report the enacted state, not the command state

Zachary Kotlarek 13 years ago
parent
commit
41255f5613
1 changed files with 11 additions and 11 deletions
  1. 11 11
      dmx/audio.pl

+ 11 - 11
dmx/audio.pl

@@ -97,17 +97,6 @@ while (1) {
 		$state = 'DEFAULT';
 	}
 
-	# If the state has changed, save to disk
-	if ($stateLast ne $state) {
-		if ($DEBUG) {
-			print STDERR 'New output state: ' . $stateLast . ' => ' . $state . "\n";
-		}
-		my ($fh, $tmp) = tempfile($OUTPUT_STATE . '.XXXXXXXX', 'UNLINK' => 0);
-		print $fh $state . "\n";
-		close($fh);
-		rename($tmp, $OUTPUT_STATE);
-	}
-
 	# Force updates on a periodic basis
 	if (!$update && time() - $pushLast > $PUSH_TIMEOUT) {
 
@@ -141,4 +130,15 @@ while (1) {
 		# Clear the update flag
 		$update = 0;
 	}
+
+	# If the state has changed and the device has responded, save to disk
+	if (!$update && $stateLast ne $state) {
+		if ($DEBUG) {
+			print STDERR 'New output state: ' . $stateLast . ' => ' . $state . "\n";
+		}
+		my ($fh, $tmp) = tempfile($OUTPUT_STATE . '.XXXXXXXX', 'UNLINK' => 0);
+		print $fh $state . "\n";
+		close($fh);
+		rename($tmp, $OUTPUT_STATE);
+	}
 }