public void ThreadRun() { try { m_stream.Start(Convert.ToInt32(wavDataProvider.SampleRate)); int nSamples = Convert.ToInt32(wavDataProvider.SampleRate / 50); do { System.Runtime.InteropServices.ComTypes.IStream strm = wavDataProvider.GetNextAudioChunk(nSamples); if (null == strm) { break; } while (false == PushSamples(strm)) { Thread.Sleep(20); } System.Runtime.InteropServices.Marshal.FinalReleaseComObject(strm); strm = null; } while (wavDataProvider.HasMoreData); } catch (COMException) { } m_stream.Stop(); AllDataWritten.Invoke(this, null); }
public void SetStream(PttLib.IAudioStream _stream) { if (null != trdFeed) { return; } m_stream = _stream; m_stream.Start(Convert.ToInt32(wavDataProvider.SampleRate)); trdFeed = new Thread(new ThreadStart(this.ThreadRun)); trdFeed.SetApartmentState(ApartmentState.MTA); trdFeed.Start(); }