예제 #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 {
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Cleans up the first data block in play queue.
 /// </summary>
 /// <param name="state">User data.</param>
 private void OnCleanUpFirstBlock(object state)
 {
     try{
         lock (m_pPlayItems){
             PlayItem item = m_pPlayItems[0];
             WavMethods.waveOutUnprepareHeader(m_pWavDevHandle, item.HeaderHandle.AddrOfPinnedObject(), Marshal.SizeOf(item.Header));
             m_pPlayItems.Remove(item);
             m_BytesBuffered -= item.DataSize;
             item.Dispose();
         }
     }
     catch {
     }
 }