Exemplo n.º 1
0
        //------------------------------------------------------------------------------
        // Name: CWMVCopy::Process()
        // Desc: Processes the samples from the reader..
        //------------------------------------------------------------------------------
        protected void Process()
        {
            //
            // Begin writing
            //
            m_pWriter.BeginWriting();

            m_hr         = S_Ok;
            m_fEOF       = false;
            m_dwProgress = 0;
            m_hEvent.Reset();

            Console.WriteLine("            0%-------20%-------40%-------60%-------80%-------100%");
            Console.Write("Process:    ");

            //
            // Start the reader
            //
            m_pReader.Start(0, 0, 1.0f, IntPtr.Zero);

            //
            // Wait until the reading is finished
            //
            WaitForCompletion();
            Console.WriteLine("");

            //
            // End writing
            //
            m_pWriter.EndWriting();
        }
 private void DoStart(IWMReader read)
 {
     read.Start(0, 0, 1.0f, IntPtr.Zero);
     m_CallbackCalled = false;
     while (!m_CallbackCalled)
     {
         System.Threading.Thread.Sleep(0);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Start playing the audio
        /// </summary>
        /// <param name="cnsStart"></param>
        public void Start(long cnsStart)
        {
            //
            // Ensure that a reader object has been instantiated.
            //
            if (IsDisposed())
            {
                throw new COMException("Instance has been Disposed", E_Unexpected);
            }
            m_OldTime = -1;

            //
            // Configure the wave output device.
            //
            if (IntPtr.Zero != m_hWaveOut)
            {
                int woe = waveOut.Reset(m_hWaveOut);
                waveOut.ThrowExceptionForError(woe);
            }
            else
            {
                int mmr = waveOut.Open(out m_hWaveOut,
                                       m_DeviceIndex,
                                       m_pWfx,
                                       IntPtr.Zero,
                                       IntPtr.Zero,
                                       WaveOpenFlags.Null);
                waveOut.ThrowExceptionForError(mmr);

                // If a form was provided
                if (m_fForm != null)
                {
                    // Ensure volume change events get sent
                    MIXER_OBJECTF flags = MIXER_OBJECTF.CallBack_Window | MIXER_OBJECTF.WaveOut;
                    MMSYSERR      rc    = Mixer.Open(out m_hMixer, m_DeviceIndex, m_fForm.Handle, IntPtr.Zero, flags);
                    // Not checking for error.  If something goes wrong, rather than fail the call, we
                    // just won't update the volume bar
                }

                for (int x = 0; x < MAXBUFFERS; x++)
                {
                    m_InsBuf[x] = new INSBuf(m_hWaveOut, m_MaxSampleSize);
                }
            }
            m_pReader.Start(cnsStart, 0, 1.0f, IntPtr.Zero);
        }
Exemplo n.º 4
0
        private void TestControl()
        {
            m_read.Start(0, 50000000, 1.0f, IntPtr.Zero);
            while (m_SampleCount == 0)
            {
                System.Threading.Thread.Sleep(1);
            }

            m_read.Pause();
            System.Threading.Thread.Sleep(100);
            int cur = m_SampleCount;

            System.Threading.Thread.Sleep(500);
            Debug.Assert(cur == m_SampleCount);

            m_read.Resume();
            System.Threading.Thread.Sleep(100);
            Debug.Assert(m_SampleCount != cur);

            m_read.Stop();
            WaitForStatus(Status.Stopped);
        }
Exemplo n.º 5
0
        //------------------------------------------------------------------------------
        // Name: Start()
        // Desc: Plays the file.
        //------------------------------------------------------------------------------
        public void Start()
        {
            //
            // Start the reader to play the stream normally
            //
            m_hrAsync = 0;
            m_EOF     = false;

            m_pReader.Start(0, 0, 1.0f, IntPtr.Zero);

            // Wait for the start to complete
            m_hEvent.WaitOne(-1, false);
            Debug.WriteLine("Playing......");

            //
            // Check results
            //
            if (m_hrAsync < 0)
            {
                throw new COMException("IWMReader playback failed", m_hrAsync);
            }
        }
        private void Config()
        {
            WMUtils.WMCreateWriter(IntPtr.Zero, out writer);
            writer.SetProfileByID(g);

            WMUtils.WMCreateWriterNetworkSink(out sink);
            m_clientConns = (IWMClientConnections)sink;

            IWMWriterAdvanced advWriter = (IWMWriterAdvanced)writer;

            advWriter.AddSink(sink);
            sink.Open(ref port);

            int urlLen = 0;

            sink.GetHostURL(null, ref urlLen);
            sbUrl = new StringBuilder(urlLen);
            sink.GetHostURL(sbUrl, ref urlLen);

            writer.BeginWriting();

            WMUtils.WMCreateReader(IntPtr.Zero, Rights.Playback, out reader);
            reader.Open(sbUrl.ToString(), this, new IntPtr(123));

            lock (m_openLock)
            {
                Monitor.Wait(m_openLock);
            }

            reader.Start(0, 0, 1.0f, new IntPtr(321));

            lock (m_openLock)
            {
                Monitor.Wait(m_openLock);
            }
        }
 private void TestSample()
 {
     m_read.Start(0, 1, 1, new IntPtr(567));
     System.Threading.Thread.Sleep(300);
     Debug.Assert(m_CallbackCalled);
 }