internal ScheduledAudioFileRegion GetAudioFileRegion() { if (alreadyUsed) { throw new InvalidOperationException("You should not call SetScheduledFileRegion with a previously set region instance"); } IntPtr ptr = IntPtr.Zero; if (completionHandler != null) { handle = GCHandle.Alloc(this); ptr = GCHandle.ToIntPtr(handle); } var ret = new ScheduledAudioFileRegion { TimeStamp = TimeStamp, CompletionHandlerUserData = ptr, CompletionHandler = ptr != IntPtr.Zero ? static_ScheduledAudioFileRegionCompletionHandler : null, AudioFile = AudioFile.Handle, LoopCount = LoopCount, StartFrame = StartFrame, FramesToPlay = FramesToPlay }; alreadyUsed = true; return(ret); }
static void ScheduledAudioFileRegionCallback (IntPtr userData, ref ScheduledAudioFileRegion fileRegion, AudioUnitStatus status) { if (userData == IntPtr.Zero) return; var handle = GCHandle.FromIntPtr (userData); var inst = (AUScheduledAudioFileRegion) handle.Target; inst?.completionHandler (inst, status); }
static void ScheduledAudioFileRegionCallback(IntPtr userData, ref ScheduledAudioFileRegion fileRegion, AudioUnitStatus status) { if (userData == IntPtr.Zero) { return; } var handle = GCHandle.FromIntPtr(userData); var inst = (AUScheduledAudioFileRegion)handle.Target; inst?.completionHandler(inst, status); }
internal ScheduledAudioFileRegion GetAudioFileRegion () { if (alreadyUsed) throw new InvalidOperationException ("You should not call SetScheduledFileRegion with a previously set region instance"); IntPtr ptr = IntPtr.Zero; if (completionHandler != null) { handle = GCHandle.Alloc (this); ptr = GCHandle.ToIntPtr (handle); } var ret = new ScheduledAudioFileRegion { TimeStamp = TimeStamp, CompletionHandlerUserData = ptr, CompletionHandler = ptr != IntPtr.Zero ? static_ScheduledAudioFileRegionCompletionHandler : null, AudioFile = AudioFile.Handle, LoopCount = LoopCount, StartFrame = StartFrame, FramesToPlay = FramesToPlay }; alreadyUsed = true; return ret; }