Exemplo n.º 1
0
        void StopRenders()
        {
            _videoRender = null;

            if (null != _audioRender)
            {
                _audioRender.Stop();
                _audioRender.Dispose();
                _audioRender = null;
            }

            _mainForm.Dispose();
        }
Exemplo n.º 2
0
        internal static void WaveOutProc(IntPtr hdrvr, int uMsg, IntPtr dwInstance, IntPtr dwParam1, IntPtr dwParam2)
        {
            if (uMsg == Native.MM_WOM_DONE)
            {
                try
                {
                    System.Diagnostics.Debug.Assert(dwInstance != IntPtr.Zero);
                    WinMMAudioRender instance = (WinMMAudioRender)((GCHandle)dwInstance).Target;

                    System.Diagnostics.Debug.Assert(dwParam1 != IntPtr.Zero);
                    Native.WAVEHDR hdr = (Native.WAVEHDR)Marshal.PtrToStructure(dwParam1, typeof(Native.WAVEHDR));

                    System.Diagnostics.Debug.Assert(hdr.dwUser != IntPtr.Zero);
                    WaveOutBuffer waveOutBuffer = (WaveOutBuffer)((GCHandle)hdr.dwUser).Target;

                    if (hdr.dwBufferLength > 0)
                    {
                        instance._totalDuration += hdr.dwBufferLength;
                        instance._callback.PlaybackProgress(instance._totalDuration, hdr.dwBufferLength, instance._fmt.nAvgBytesPerSec);
                    }

                    // if we are still playing get a new audio buffer
                    if (instance._started)
                    {
                        int length = 0;

                        if (instance._callback.NextAudioBuffer(waveOutBuffer._data, ref length))
                        {
                            System.Diagnostics.Debug.Assert(length <= waveOutBuffer._data.Length);

                            waveOutBuffer._hdr.dwBufferLength = length;

                            int result = Native.waveOutWrite(instance._hWaveout, waveOutBuffer._gchHdr.AddrOfPinnedObject(), Marshal.SizeOf(waveOutBuffer._hdr));
                            System.Diagnostics.Debug.Assert(result == Native.MMSYSERR_NOERROR);
                        }
                        else
                        {
                            // end of stream read
                            instance._started = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
        }
Exemplo n.º 3
0
        void StarRenders()
        {
            _mainForm             = new MainForm();
            _mainForm.FormClosed += MainForm_FormClosed;
            _mainForm.Show();

            _videoRender = _mainForm.OpenGLVideoRender;

            if (_videoStreamInfo != null)
            {
                _videoRender.SetDisplayAspect(_videoStreamInfo.DisplayRatioWidth, _videoStreamInfo.DisplayRatioHeight);
                _videoRender.Start();
            }

            if (_audioStreamInfo != null)
            {
                _audioRender = new WinMMAudioRender();
                _audioRender.Start(this, _audioStreamInfo.SampleRate, _audioStreamInfo.Channels, _audioStreamInfo.BitsPerSample);
            }
        }