Esempio n. 1
0
 /// <summary>
 /// A constructor that creates an Audio resource. No sound will be heard
 /// until StartPlayback() is called. The Action<byte[], uint, double, object>
 /// is called with the byte[] buffer and user data whenever the buffer needs to be filled.
 /// From within the delegate, you should not call <code>Audio</code>
 /// functions. The action delegate will be called on a different thread than the one
 /// which created the interface. For performance-critical applications (such
 /// as low-latency audio), the action delegate should avoid blocking or calling
 /// functions that can obtain locks, such as memory allocates. The layout and the size
 /// of the buffer passed to the audio callback will be determined by
 /// the device configuration and is specified in the <code>AudioConfig</code>
 /// documentation.
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="config"></param>
 /// <param name="callbackAction"></param>
 /// <param name="userData"></param>
 public Audio(Instance instance,
              AudioConfig config,
              Action <byte[], uint, double, object> callbackAction,
              object userData = null)
 {
     this.config      = config;
     callbackDelegate = callbackAction;
     meBePinned       = (IntPtr)(GCHandle.Alloc(this, GCHandleType.Normal));
     if (userData != null)
     {
         userDataHandle = (IntPtr)(GCHandle.Alloc(userData, GCHandleType.Normal));
     }
     handle = PPBAudio.Create(instance, config, audioCallback, meBePinned);
 }
Esempio n. 2
0
 /// <summary>
 /// StopPlayback stops playback of audio.
 /// </summary>
 /// <returns>true if successful, otherwise false.</returns>
 public bool StopPlayback()
 => PPBAudio.StopPlayback(this) == PPBool.True;