コード例 #1
0
 public void Dispose()
 {
     if (m_Thread != null)
     {
         try
         {
             m_Finished = true;
             if (m_WaveOut != IntPtr.Zero)
             {
                 WaveNative.waveOutReset(m_WaveOut);
             }
             m_Thread.Join();
             m_FillProc = null;
             FreeBuffers();
             if (m_WaveOut != IntPtr.Zero)
             {
                 WaveNative.waveOutClose(m_WaveOut);
             }
         }
         finally
         {
             m_Thread  = null;
             m_WaveOut = IntPtr.Zero;
         }
     }
     GC.SuppressFinalize(this);
 }
コード例 #2
0
 public WaveOutPlayer(int device, WaveFormat format, int bufferSize, int bufferCount, BufferFillEventHandler fillProc)
 {
     m_zero     = format.wBitsPerSample == 8 ? (byte)128 : (byte)0;
     m_FillProc = fillProc;
     WaveOutHelper.Try(WaveNative.waveOutOpen(out m_WaveOut, device, format, m_BufferProc, 0, WaveNative.CALLBACK_FUNCTION));
     AllocateBuffers(bufferSize, bufferCount);
     m_Thread = new Thread(new ThreadStart(ThreadProc));
     m_Thread.Start();
 }
コード例 #3
0
 public bool Play()
 {
     lock (this)
     {
         m_PlayEvent.Reset();
         m_Playing = WaveNative.waveOutWrite(m_WaveOut, ref m_Header, Marshal.SizeOf(m_Header)) == WaveNative.MMSYSERR_NOERROR;
         return(m_Playing);
     }
 }
コード例 #4
0
        public WaveOutBuffer(IntPtr waveOutHandle, int size)
        {
            m_WaveOut = waveOutHandle;

            m_HeaderHandle          = GCHandle.Alloc(m_Header, GCHandleType.Pinned);
            m_Header.dwUser         = (IntPtr)GCHandle.Alloc(this);
            m_HeaderData            = new byte[size];
            m_HeaderDataHandle      = GCHandle.Alloc(m_HeaderData, GCHandleType.Pinned);
            m_Header.lpData         = m_HeaderDataHandle.AddrOfPinnedObject();
            m_Header.dwBufferLength = size;
            WaveOutHelper.Try(WaveNative.waveOutPrepareHeader(m_WaveOut, ref m_Header, Marshal.SizeOf(m_Header)));
        }
コード例 #5
0
 public void Dispose()
 {
     if (m_Header.lpData != IntPtr.Zero)
     {
         WaveNative.waveOutUnprepareHeader(m_WaveOut, ref m_Header, Marshal.SizeOf(m_Header));
         m_HeaderHandle.Free();
         m_Header.lpData = IntPtr.Zero;
     }
     m_PlayEvent.Close();
     if (m_HeaderDataHandle.IsAllocated)
     {
         m_HeaderDataHandle.Free();
     }
     GC.SuppressFinalize(this);
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: w4-pwr/studia
		internal static void WaveOutProc(IntPtr hdrvr, int uMsg, int dwUser, ref WaveNative.WaveHdr wavhdr, int dwParam2)
		{
			if (uMsg == WaveNative.MM_WOM_DONE)
			{
				try
				{
					GCHandle h = (GCHandle)wavhdr.dwUser;
					WaveOutBuffer buf = (WaveOutBuffer)h.Target;
					buf.OnCompleted();
				}
				catch
				{
				}
			}
		}