Mathieu Capdegelle 8 年之前
父节点
当前提交
d77e11a873
共有 3 个文件被更改,包括 8 次插入7 次删除
  1. 1 1
      hxd/snd/Data.hx
  2. 6 5
      hxd/snd/Driver.hx
  3. 1 1
      hxd/snd/effect/Spatialization.hx

+ 1 - 1
hxd/snd/Data.hx

@@ -59,7 +59,7 @@ class Data {
 		var resample = samples != newSamples;
 		var srcChannels = this.channels;
 		var commonChannels = channels < srcChannels ? channels : srcChannels;
-		var extraChannels = (channels > srcChannels ? channels : srcChannels) - commonChannels;
+		var extraChannels  = channels - commonChannels;
 		var sval = 0., ival = 0;
 		for( i in 0...newSamples ) {
 			var targetSample = (i / (newSamples - 1)) * (samples - 1);

+ 6 - 5
hxd/snd/Driver.hx

@@ -202,7 +202,6 @@ class Driver {
 					if( c.positionChanged ) {
 						// force full resync
 						releaseSource(s);
-						c.source = null;
 						continue;
 					}
 					var count = AL.getSourcei(s.inst, AL.BUFFERS_PROCESSED);
@@ -408,7 +407,11 @@ class Driver {
 	// ------------------------------------------------------------------------
 
 	function releaseSource( s : Source ) {
-		s.channel = null;
+		if (s.channel != null) {
+			s.channel.source = null;
+			s.channel = null;
+		}
+		
 		if( s.playing ) {
 			s.playing = false;
 			AL.sourceStop(s.inst);
@@ -630,10 +633,8 @@ class Driver {
 		}
 		c.next = null;
 		c.driver = null;
-		if( c.source != null ) {
+		if( c.source != null )
 			releaseSource(c.source);
-			c.source = null;
-		}
 	}
 
 	function fillBuffer(buf : Buffer, dat : hxd.snd.Data, forceMono = false) {

+ 1 - 1
hxd/snd/effect/Spatialization.hx

@@ -33,7 +33,7 @@ class Spatialization extends Effect {
 		return gain;
 	}
 
-	override function apply(channel : Channel, s : System.Source) {
+	override function apply(channel : Channel, s : Driver.Source) {
 		AL.source3f(s.inst, AL.POSITION,  position.x,  position.y,  position.z);
 		AL.source3f(s.inst, AL.VELOCITY,  velocity.x,  velocity.y,  velocity.z);
 		AL.source3f(s.inst, AL.DIRECTION, direction.x, direction.y, direction.z);