示例#1
0
 public void Dispose()
 {
     if (_thread != null)
     {
         try
         {
             _isComplete = true;
             if (_wave != IntPtr.Zero)
             {
                 WindowsMultimedia.waveOutReset(_wave);
             }
             _thread.Join();
             _fillDelegate = null;
             FreeBufferList();
             if (_wave != IntPtr.Zero)
             {
                 WindowsMultimedia.waveOutClose(_wave);
             }
         }
         finally
         {
             _thread = null;
             _wave   = IntPtr.Zero;
         }
     }
     GC.SuppressFinalize(this);
 }
示例#2
0
文件: WaveOut.cs 项目: avogelba/PWR
        /// <summary>Stop playback, and cleanup resources</summary>
        /// <returns>MMSYSERR</returns>
        public MMSYSERR Stop()
        {
            MMSYSERR mmr = MMSYSERR.ERROR;

            try
            {
                _bFinished = true;
                if (_pWaveOut != IntPtr.Zero)
                {
                    waveOutReset(_pWaveOut);
                }
                if (_cThread != null)
                {
                    _cThread.Abort();
                }
                _eFillProc = null;
                FreeBuffers();
                if (_pWaveOut != IntPtr.Zero)
                {
                    mmr = waveOutClose(_pWaveOut);
                }
                else
                {
                    mmr = MMSYSERR.NOERROR;
                }
            }
            finally
            {
                _cThread     = null;
                _pWaveOut    = IntPtr.Zero;
                this.Playing = false;
            }
            return(mmr);
        }
示例#3
0
 public void Dispose()
 {
     if (objThread != null)
     {
         try
         {
             blnFinished = true;
             if (objWaveOut != IntPtr.Zero)
             {
                 WaveNative.waveOutReset(objWaveOut);
             }
             objThread.Join();
             objFillProc = null;
             FreeBuffers();
             if (objWaveOut != IntPtr.Zero)
             {
                 WaveNative.waveOutClose(objWaveOut);
             }
         }
         finally
         {
             objThread  = null;
             objWaveOut = IntPtr.Zero;
         }
     }
 }
 public void Dispose()
 {
     if (m_Thread != null)
     {
         try {
             m_Finished = true;
             if (m_WaveOut != IntPtr.Zero)
             {
                 WaveNative.waveOutReset(m_WaveOut);
             }
             m_FillProc = null;
             FreeBuffers();
             if (m_WaveOut != IntPtr.Zero)
             {
                 WaveNative.waveOutClose(m_WaveOut);
             }
             try {
                 if (m_Thread.IsAlive && m_Thread.ThreadState == ThreadState.Running)
                 {
                     try {
                         m_Thread.Abort();
                     } finally {}
                 }
             } catch (ThreadStateException) {
             }
             GC.KeepAlive(m_Thread);
         }
         finally {
             m_Thread  = null;
             m_WaveOut = IntPtr.Zero;
         }
     }
     GC.SuppressFinalize(this);
 }
示例#5
0
 public void Dispose()
 {
     if (this.m_Thread == null)
     {
         return;
     }
     try
     {
         this.m_Finished = true;
         if (this.m_WaveOut != IntPtr.Zero)
         {
             WaveNative.waveOutReset(this.m_WaveOut);
         }
         this.m_Thread.Join();
         this.m_FillProc = (BufferFillEventHandler)null;
         this.FreeBuffers();
         if (this.m_WaveOut != IntPtr.Zero)
         {
             WaveNative.waveOutClose(this.m_WaveOut);
         }
     }
     finally
     {
         this.m_Thread  = (Thread)null;
         this.m_WaveOut = IntPtr.Zero;
     }
 }
示例#6
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);
 }
示例#7
0
 public WaveOutPlayer(Int32 intDevice, WaveFormat objFormat, Int32 intBufferSize, Int32 intBufferCount, BufferFillEventHandler objFillProc)
 {
     objZero     = objFormat.shrWBitsPerSample == 8 ? (Byte)128 : (Byte)0;
     objFillProc = objFillProc;
     WaveOutHelper.Try(WaveNative.waveOutOpen(out objWaveOut, intDevice, objFormat, objBufferProc, 0, WaveNative.CALLBACK_FUNCTION));
     AllocateBuffers(intBufferSize, intBufferCount);
     objThread = new Thread(new ThreadStart(ThreadProc));
     objThread.Start();
 }
示例#8
0
 public WaveOut(int device, WaveFormat format, int bufferSize, int bufferCount, BufferFillEventHandler fillProc)
 {
     _isZero       = (format.wBitsPerSample == 8 ? (byte)128 : (byte)0);
     _fillDelegate = fillProc;
     Helper.Try(WindowsMultimedia.waveOutOpen(out _wave, device, format, _bufferDelegate, 0, WindowsMultimedia.CALLBACK_FUNCTION));
     AllocateBufferList(bufferSize, bufferCount);
     _thread = new Thread(new ThreadStart(Thread));
     _thread.Start();
 }
 public WaveOutPlayer(int device, WaveFormat format, int bufferSize, int bufferCount, BufferFillEventHandler fillProc)
 {
     zero = format.wBitsPerSample == 8 ? (byte)128 : (byte)0;
     this.fillProc = fillProc;
     WaveOutHelper.Try(Winmm.waveOutOpen(out waveOut, device, format, bufferProc, 0, Winmm.CALLBACK_FUNCTION));
     AllocateBuffers(bufferSize, bufferCount);
     playThread = new Thread(ThreadProc);
     playThread.Start();
 }
示例#10
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();
 }
示例#11
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();
 }
示例#12
0
文件: WaveOut.cs 项目: avogelba/PWR
 public WaveOutPlayer(int deviceId, BufferFillEventHandler fillProc)
 {
     _eFillProc = fillProc;
     // load defaults
     this.Playing     = false;
     this.Device      = deviceId;
     this.Length      = 0;
     this.BufferSize  = 1024;//defaults 4096 * 4
     this.BufferCount = 16;
 }
示例#13
0
 public WaveOutPlayer(
     int device,
     WaveFormat format,
     int bufferSize,
     int bufferCount,
     BufferFillEventHandler fillProc)
 {
     this.m_zero     = format.wBitsPerSample == (short)8 ? (byte)128 : (byte)0;
     this.m_FillProc = fillProc;
     WaveOutHelper.Try(WaveNative.waveOutOpen(out this.m_WaveOut, device, format, this.m_BufferProc, 0, 196608));
     this.AllocateBuffers(bufferSize, bufferCount);
     this.m_Thread = new Thread(new ThreadStart(this.ThreadProc));
     this.m_Thread.Start();
 }
示例#14
0
 public WaveOutPlayer(int device, WaveFormat format, int bufferSize, int bufferCount,
                      BufferFillEventHandler fillProc)
 {
     _mZero     = format.wBitsPerSample == 8 ? (byte)128 : (byte)0;
     _mFillProc = fillProc;
     WaveOutHelper.Try(WaveNative.waveOutOpen(out _mWaveOut, device, format, m_BufferProc, 0,
                                              WaveNative.CallbackFunction));
     AllocateBuffers(bufferSize, bufferCount);
     _mThread = new Thread(ThreadProc)
     {
         IsBackground = true
     };
     _mThread.Start();
 }
示例#15
0
        public WaveOut(int device, WAVEFORMATEX format, int bufferSize, int bufferCount, BufferFillEventHandler fillProc)
        {
            m_zero     = format.wBitsPerSample == 8 ? (byte)128 : (byte)0;
            m_FillProc = fillProc;

            var errorCode = (MMErrors)WaveNative.waveOutOpen(out m_WaveOut, device, ref format, m_BufferProc, 0, (int)CallBackFlag.CALLBACK_FUNCTION);

            if (errorCode != MMErrors.MMSYSERR_NOERROR)
            {
                throw new MixerException(errorCode, Audio.GetErrorDescription(FuncName.fnWaveOutOpen, errorCode));
            }

            AllocateBuffers(bufferSize, bufferCount);
            m_Thread = new Thread(new ThreadStart(ThreadProc));
            m_Thread.Start();
        }
示例#16
0
        public XAudio2Stream(int rate, int bits, int channels, int bufferSize, int numBuffers, BufferFillEventHandler bufferFillCallback)
        {
            xaudio2          = new XAudio2();
            masteringVoice   = new MasteringVoice(xaudio2);
            waveFormat       = new WaveFormat(rate, bits, channels);
            audioBuffersRing = new AudioBuffer[numBuffers];
            memBuffers       = new DataPointer[audioBuffersRing.Length];

            for (int i = 0; i < audioBuffersRing.Length; i++)
            {
                audioBuffersRing[i]   = new AudioBuffer();
                memBuffers[i].Size    = bufferSize;
                memBuffers[i].Pointer = Utilities.AllocateMemory(memBuffers[i].Size);
            }

            bufferFill      = bufferFillCallback;
            bufferSemaphore = new Semaphore(numBuffers, numBuffers);
            quitEvent       = new ManualResetEvent(false);
        }
示例#17
0
文件: WaveOut.cs 项目: e-COS/cspspemu
 public void Dispose()
 {
     Disposing = true;
     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);
 }
示例#18
0
 public void Dispose()
 {
     Disposing = true;
     if (_mThread != null)
     {
         try
         {
             _mFinished = true;
             //if (m_WaveOut != IntPtr.Zero) WaveNative.waveOutReset(m_WaveOut);
             //m_Thread.Join();
             _mFillProc = null;
             //FreeBuffers();
             //if (m_WaveOut != IntPtr.Zero) WaveNative.waveOutClose(m_WaveOut);
         }
         finally
         {
             _mThread  = null;
             _mWaveOut = IntPtr.Zero;
         }
     }
     GC.SuppressFinalize(this);
 }
示例#19
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);
             }
         }
         catch (Exception ex)
         {
             LogManage.WriteLog(this.GetType(), ex);
         }
     }
        public void Dispose()
        {
            if (playThread != null)
                try
                {
                    finished = true;
                    if (playThread.IsAlive)
                        playThread.Join();

                    fillProc = null;
                    FreeBuffers();
                    if (waveOut != IntPtr.Zero)
                    {
                        Winmm.waveOutReset(waveOut);
                        Winmm.waveOutClose(waveOut);
                    }
                }
                finally
                {
                    playThread = null;
                    waveOut = IntPtr.Zero;
                }
            GC.SuppressFinalize(this);
        }
示例#21
0
		public void Dispose()
		{
			if (m_Thread != null)
				try
				{
					m_Finished = true;
					if (m_WaveOut != IntPtr.Zero)
						WINMM_DLL.waveOutReset(m_WaveOut);
					m_Thread.Join();
					m_FillProc = null;
					FreeBuffers();
					if (m_WaveOut != IntPtr.Zero)
						WINMM_DLL.waveOutClose(m_WaveOut);
				}
				finally
				{
					m_Thread.Abort();
					m_Thread = null;
					m_WaveOut = IntPtr.Zero;
				}
			GC.SuppressFinalize(this);
		}