Exemplo n.º 1
0
        private void CheckForAbort()
        {
            if (_aborted)
            {
                // Synchronous operation
                lock (_queueIn)
                {
                    foreach (InItem inItem in _queueIn)
                    {
                        // Do we have an event or a sound buffer
                        if (inItem._waveHeader != null)
                        {
                            WaveHeader waveHeader = inItem._waveHeader;
                            Interop.WinMM.waveOutUnprepareHeader(
                                _hwo, waveHeader.WAVEHDR.AddrOfPinnedObject(), waveHeader.SizeHDR);
                            waveHeader.Dispose();
                        }
                        else
                        {
                            _asyncDispatch.Post(inItem._userData);
                        }
                    }
                    _queueIn.Clear();

                    // if the queue is empty, then restart the callers thread
                    _evt.Set();
                }
            }
            ClearBuffers();
        }
Exemplo n.º 2
0
 private void ClearBuffers()
 {
     foreach (InItem item in _queueOut)
     {
         WaveHeader waveHeader = item._waveHeader;
         MMSYSERR   mMSYSERR   = SafeNativeMethods.waveOutUnprepareHeader(_hwo, waveHeader.WAVEHDR.AddrOfPinnedObject(), waveHeader.SizeHDR);
     }
 }
Exemplo n.º 3
0
        private void ClearBuffers()
        {
            foreach (InItem item in _queueOut)
            {
                WaveHeader             waveHeader = item._waveHeader;
                Interop.WinMM.MMSYSERR result     = Interop.WinMM.waveOutUnprepareHeader(
                    _hwo, waveHeader.WAVEHDR.AddrOfPinnedObject(), waveHeader.SizeHDR);
                if (result != Interop.WinMM.MMSYSERR.NOERROR)
                {
                    //System.Diagnostics.Debug.Assert (false);
                }
                waveHeader.Dispose();
            }

            _queueOut.Clear();
        }
Exemplo n.º 4
0
 private void CheckForAbort()
 {
     if (_aborted)
     {
         lock (_queueIn)
         {
             foreach (InItem item in _queueIn)
             {
                 if (item._waveHeader != null)
                 {
                     WaveHeader waveHeader = item._waveHeader;
                     SafeNativeMethods.waveOutUnprepareHeader(_hwo, waveHeader.WAVEHDR.AddrOfPinnedObject(), waveHeader.SizeHDR);
                 }
                 else
                 {
                     _asyncDispatch.Post(item._userData);
                 }
             }
             _queueIn.Clear();
             _evt.Set();
         }
     }
     ClearBuffers();
 }
Exemplo n.º 5
0
 internal override void Play(byte[] buffer)
 {
     if (_deviceOpen)
     {
         int num = buffer.Length;
         _bytesWritten += num;
         WaveHeader waveHeader = new WaveHeader(buffer);
         GCHandle   wAVEHDR    = waveHeader.WAVEHDR;
         MMSYSERR   mMSYSERR   = SafeNativeMethods.waveOutPrepareHeader(_hwo, wAVEHDR.AddrOfPinnedObject(), waveHeader.SizeHDR);
         if (mMSYSERR != 0)
         {
             throw new AudioException(mMSYSERR);
         }
         lock (_noWriteOutLock)
         {
             if (!_aborted)
             {
                 lock (_queueIn)
                 {
                     InItem item = new InItem(waveHeader);
                     _queueIn.Add(item);
                     _evt.Reset();
                 }
                 mMSYSERR = SafeNativeMethods.waveOutWrite(_hwo, wAVEHDR.AddrOfPinnedObject(), waveHeader.SizeHDR);
                 if (mMSYSERR != 0)
                 {
                     lock (_queueIn)
                     {
                         _queueIn.RemoveAt(_queueIn.Count - 1);
                         throw new AudioException(mMSYSERR);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 internal InItem(WaveHeader waveHeader)
 {
     _waveHeader = waveHeader;
 }