/// <summary>
 /// Initializes a new instance of the <see cref="SessionCreatedEventArgs"/> class.
 /// </summary>
 /// <param name="newSession">The <see cref="AudioSessionControl"/> object of the audio session that was created.</param>
 /// <exception cref="System.ArgumentNullException"><paramref name="newSession"/> must not be null.</exception>
 public SessionCreatedEventArgs(AudioSessionControl newSession)
 {
     if (newSession == null)
     {
         throw new ArgumentNullException("newSession");
     }
     NewSession = newSession;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Notifies the registered processes that the audio session has been created.
 /// </summary>
 /// <param name="newSession">Pointer to the <see cref="AudioSessionControl"/> object of the audio session that was created.</param>
 /// <returns>HRESULT</returns>
 int IAudioSessionNotification.OnSessionCreated([In] IntPtr newSession)
 {
     if (SessionCreated != null)
     {
         var sessionControl = new AudioSessionControl(newSession);
         //make sure, the reference can be used within our application
         //in order to prevent the instance from being released, add a reference
         //if it won't be used in our application (eventhandlers and so on), the
         //destructor will release the instance.
         ((IUnknown)sessionControl).AddRef();
         SessionCreated(this, new SessionCreatedEventArgs(sessionControl));
     }
     return((int)HResult.S_OK);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieves an audio session control.
        /// </summary>
        /// <param name="audioSessionGuid">If the GUID does not identify a session that has been previously opened, the call opens a new but empty session. If the value is Guid.Empty, the method assigns the stream to the default session.</param>
        /// <param name="streamFlags">Specifies the status of the flags for the audio stream.</param>
        /// <param name="sessionControl">The <see cref="AudioSessionControl"/> of the specified <paramref name="audioSessionGuid"/>.</param>
        /// <returns>HRESULT</returns>
        public unsafe int GetAudioSessionControlNative(Guid audioSessionGuid, int streamFlags,
                                                       out AudioSessionControl sessionControl)
        {
            sessionControl = null;
            IntPtr ptr    = IntPtr.Zero;
            int    result = LocalInterop.Calli(UnsafeBasePtr, &audioSessionGuid, streamFlags, &ptr,
                                               ((void **)(*(void **)UnsafeBasePtr))[3]);

            if (ptr != IntPtr.Zero)
            {
                sessionControl = new AudioSessionControl(ptr);
            }
            return(result);
        }