public void ReclaimSource_ThrowsOnNull() { var instance = SourcePool.CreateInstance(1); Action reclaimSource = () => instance.ReclaimSource(null !); reclaimSource.Should().Throw <ArgumentNullException>(); }
public void CreateInstance_CreatesInstanceWithCorrectCapacity() { const int numSources = 19; var instance = SourcePool.CreateInstance(numSources); instance.Capacity.Should().Be(numSources); }
private void Initialize(ScoreCounter scoreCounter) { _scoreCounter = scoreCounter; _sourcePool = GetComponent <SourcePool>(); impulseSource = GetComponent <CinemachineImpulseSource>(); _initialScale = transform.localScale; _particleDuration = particlePrefab.main.duration; }
// Start is called before the first frame update void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } sources = new List <Source>(); }
void Awake() { if (Instance != null) { if (Instance != this && DebugMode) { Debug.LogError("AudioPlayer already has an instance."); } this.enabled = false; return; } Instance = this; if (Application.isPlaying) { DontDestroyOnLoad(this); } // setup runtime data structures pool = new SourcePool(AudioSettings.GetConfiguration().numRealVoices); activeAudio = new List <Voice>(); voiceComp = new VoiceComparer(); listener = (AudioListener)FindObjectOfType(typeof(AudioListener)); }
protected void Dispose(bool disposing) { if (this.isDisposed) return; OpenAL.DebugFormat ("Freeing OpenALPlaybackProvider. Disposing: ", disposing); if (disposing) { this.pool.Dispose(); if (this.device != null) this.device.Dispose(); } SourceBuffer.Clear(); OpenALRunner.RemoveUser(); OpenALRunner.RemovePlaybackProvider (this); this.pool = null; this.device = null; this.isDisposed = true; }
public void CreateInstanceAndAllocateSources_ThrowsExceptionForZeroCapacity() { Action createInstanceAndAllocateSources = () => SourcePool.CreateInstanceAndAllocateSources(0); createInstanceAndAllocateSources.Should().Throw <ArgumentException>(); }
public void CreateInstance_ThrowsExceptionForNegativeCapacity() { Action createInstance = () => SourcePool.CreateInstance(-32); createInstance.Should().Throw <ArgumentException>(); }