forked from MoonsideGames/MoonWorks
				
			fix StaticSoundInstance race condition and state
							parent
							
								
									5df08727c1
								
							
						
					
					
						commit
						c037b4cb69
					
				|  | @ -1 +1 @@ | ||||||
| Subproject commit 63071f2c309f6fc2193de1c6b85da0e31df80040 | Subproject commit 590cc3537f64d3b118f0001a2f2c111fcbd2b23f | ||||||
|  | @ -274,10 +274,11 @@ namespace MoonWorks.Audio | ||||||
| 		{ | 		{ | ||||||
| 			if (AvailableInstances.Count == 0) | 			if (AvailableInstances.Count == 0) | ||||||
| 			{ | 			{ | ||||||
| 				AvailableInstances.Push(new StaticSoundInstance(Device, this, autoFree)); | 				AvailableInstances.Push(new StaticSoundInstance(Device, this)); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			var instance = AvailableInstances.Pop(); | 			var instance = AvailableInstances.Pop(); | ||||||
|  | 			instance.AutoFree = autoFree; | ||||||
| 			UsedInstances.Add(instance); | 			UsedInstances.Add(instance); | ||||||
| 			return instance; | 			return instance; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -32,21 +32,14 @@ namespace MoonWorks.Audio | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public bool AutoFree { get; } | 		public bool AutoFree { get; internal set; } | ||||||
| 
 | 
 | ||||||
| 		internal StaticSoundInstance( | 		internal StaticSoundInstance( | ||||||
| 			AudioDevice device, | 			AudioDevice device, | ||||||
| 			StaticSound parent, | 			StaticSound parent | ||||||
| 			bool autoFree |  | ||||||
| 		) : base(device, parent.FormatTag, parent.BitsPerSample, parent.BlockAlign, parent.Channels, parent.SamplesPerSecond) | 		) : base(device, parent.FormatTag, parent.BitsPerSample, parent.BlockAlign, parent.Channels, parent.SamplesPerSecond) | ||||||
| 		{ | 		{ | ||||||
| 			Parent = parent; | 			Parent = parent; | ||||||
| 			AutoFree = autoFree; |  | ||||||
| 
 |  | ||||||
| 			if (AutoFree) |  | ||||||
| 			{ |  | ||||||
| 				device.AddAutoFreeStaticSoundInstance(this); |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public override void Play() | 		public override void Play() | ||||||
|  | @ -87,6 +80,11 @@ namespace MoonWorks.Audio | ||||||
| 
 | 
 | ||||||
| 			FAudio.FAudioSourceVoice_Start(Voice, 0, operationSet); | 			FAudio.FAudioSourceVoice_Start(Voice, 0, operationSet); | ||||||
| 			State = SoundState.Playing; | 			State = SoundState.Playing; | ||||||
|  | 
 | ||||||
|  | 			if (AutoFree) | ||||||
|  | 			{ | ||||||
|  | 				Device.AddAutoFreeStaticSoundInstance(this); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public override void Pause() | 		public override void Pause() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue