Exemplo n.º 1
0
 /// <summary>
 /// Cleans up any resources being used.
 /// </summary>
 public void Dispose()
 {
     if (m_IsDisposed)
     {
         return;
     }
     m_IsDisposed = true;
     lock (m_pPlayItems) {
         try {
             // If playing, we need to reset wav device first.
             WavMethods.waveOutReset(m_pWavDevHandle);
             // If there are unprepared wav headers, we need to unprepare these.
             foreach (PlayItem item in m_pPlayItems)
             {
                 WavMethods.waveOutUnprepareHeader(m_pWavDevHandle, item.HeaderHandle.AddrOfPinnedObject(), Marshal.SizeOf(item.Header));
                 item.Dispose();
             }
             // Close output device.
             WavMethods.waveOutClose(m_pWavDevHandle);
             m_pOutDevice    = null;
             m_pWavDevHandle = IntPtr.Zero;
             m_pPlayItems    = null;
             m_pWaveOutProc  = null;
         } catch {
         }
     }
 }