public void SetupBuffer(Channel channel, bool looping) { if (CurrentChannel != null) { throw new Exception("Slot is already busy!"); } WaveFormat format = channel.Sound.Format; ISourceVoice sv; if (!sourceVoices.TryGetValue(format, out sv)) { sourceVoices[format] = new NormalSourceVoice(system, format); } sv = sourceVoices[format]; JMOD.Sound.DebugOutput("{0} - Claimed SourceVoiceSlot {1}", DateTime.Now.TimeOfDay, ID); if (channel.State == Channel.ChannelState.Virtual) { sv.SetupBuffer(channel.Sound, looping, (int)channel.SamplesPlayed); } else { sv.SetupBuffer(channel.Sound, looping); } CurrentChannel = channel; CurrentSourceVoice = sv; }
public void ShutdownRevival() { if (savedSourceVoiceState == null) // nothing to resume here { return; } if (savedSourceVoiceState.Done) { CurrentSourceVoice = null; StopSourceVoice(StopReason.Ended); // WARNING: This may not work as intended (glanced over, but not tested) return; } var format = CurrentChannel.Sound.Format; NormalSourceVoice sourceVoice = new NormalSourceVoice(system, format); CurrentSourceVoice = sourceVoices[format] = sourceVoice; sourceVoice.SetupBuffer(CurrentChannel.Sound, CurrentChannel.Looping, (int)savedSourceVoiceState.SamplesPlayed); CurrentChannel.ReapplySettings(); savedSourceVoiceState = null; }