Sfoglia il codice sorgente

make sure not to desync channelID when loading sound data

ncannasse 10 anni fa
parent
commit
7050799f74
1 ha cambiato i file con 4 aggiunte e 0 eliminazioni
  1. 4 0
      hxd/snd/Worker.hx

+ 4 - 0
hxd/snd/Worker.hx

@@ -102,9 +102,13 @@ class Worker extends hxd.Worker<Message> {
 		switch( msg ) {
 		switch( msg ) {
 		case Play(path, loop, volume, time):
 		case Play(path, loop, volume, time):
 			var res = hxd.Res.loader.load(path).toSound();
 			var res = hxd.Res.loader.load(path).toSound();
+			var cid = channelID++;
 			var snd = res.getData();
 			var snd = res.getData();
 			snd.load(function() {
 			snd.load(function() {
+				var old = channelID;
+				channelID = cid;
 				var c = allocChannel(null, loop, volume, time);
 				var c = allocChannel(null, loop, volume, time);
+				channelID = old;
 				if( c == null )
 				if( c == null )
 					return;
 					return;
 				c.res = res;
 				c.res = res;