Forráskód Böngészése

added error when having 0 samples sound
added -check-ogg in pak build to detect such cases

ncannasse 7 éve
szülő
commit
2a9d44ae3f
2 módosított fájl, 11 hozzáadás és 1 törlés
  1. 7 0
      hxd/fmt/pak/Build.hx
  2. 4 1
      hxd/snd/Manager.hx

+ 7 - 0
hxd/fmt/pak/Build.hx

@@ -13,6 +13,7 @@ class Build {
 	public var compressSounds = true;
 	public var compressMP3 = false;
 	public var checkJPG = false;
+	public var checkOGG = false;
 
 	function new() {
 	}
@@ -55,6 +56,10 @@ class Build {
 					command("jpegtran", ["-optimize", "-copy","all", filePath, filePath]);
 					data = sys.io.File.getBytes(filePath);
 				}
+			case "wav", "ogg" if( checkOGG ):
+				var snd = new hxd.snd.OggData(sys.io.File.getBytes(filePath));
+				if( snd.samples == 0 )
+					Sys.println("\t*** ERROR *** " + path + " has 0 samples");
 			}
 
 			f.dataPosition = pakDiff ? out.bytes.length : out.size;
@@ -194,6 +199,8 @@ class Build {
 					b.excludedExt.push(ext);
 			case "-check-jpg":
 				b.checkJPG = true;
+			case "-check-ogg":
+				b.checkOGG = true;
 			default:
 				throw "Unknown parameter " + f;
 			}

+ 4 - 1
hxd/snd/Manager.hx

@@ -170,9 +170,12 @@ class Manager {
 		if (soundGroup   == null) soundGroup   = masterSoundGroup;
 		if (channelGroup == null) channelGroup = masterChannelGroup;
 
+		var sdat = sound.getData();
+		if( sdat.samples == 0 ) throw sound + " has no samples";
+
 		var c = new Channel();
 		c.sound        = sound;
-		c.duration     = sound.getData().duration;
+		c.duration     = sdat.duration;
 		c.manager      = this;
 		c.soundGroup   = soundGroup;
 		c.channelGroup = channelGroup;