コード例 #1
0
        private void PlayCallback(void* data, void* samples, uint count, long pts)
        {
            var s = new Sound();
            s.SamplesData = new IntPtr(samples);
            s.SamplesSize = (uint)(count * _mFormat.BlockSize);
            s.Pts = pts;

            if (_mCallbacks.SoundCallback != null)
            {
                _mCallbacks.SoundCallback(s);
            }
        }
コード例 #2
0
ファイル: VLCStream.cs プロジェクト: vmail/main
        private void SoundCallback(Sound soundData)
        {
            if (DataAvailable == null || _needsSetup) return;

            if (_sampleChannel != null)
            {
                var samples = new byte[soundData.SamplesSize];
                Marshal.Copy(soundData.SamplesData, samples, 0, (int)soundData.SamplesSize);

                _waveProvider.AddSamples(samples, 0, samples.Length);

                var sampleBuffer = new float[samples.Length];
                _sampleChannel.Read(sampleBuffer, 0, samples.Length);

                if (Listening && WaveOutProvider != null)
                {
                    WaveOutProvider.AddSamples(samples, 0, samples.Length);
                }
                var da = new DataAvailableEventArgs((byte[])samples.Clone());
                if (DataAvailable != null)
                    DataAvailable(this, da);
            }
        }
コード例 #3
0
ファイル: VLCStream.cs プロジェクト: vmail/main
        private void SoundCallback(Sound soundData)
        {
            if (DataAvailable == null || _needsSetup) return;

            var samples = new byte[soundData.SamplesSize];
            Marshal.Copy(soundData.SamplesData, samples, 0, (int)soundData.SamplesSize);

            _waveProvider.AddSamples(samples, 0, samples.Length);

            if (Listening && WaveOutProvider != null)
            {
                WaveOutProvider.AddSamples(samples, 0, samples.Length);
            }

            //forces processing of volume level without piping it out
            var sampleBuffer = new float[samples.Length];
            _meteringProvider.Read(sampleBuffer, 0, samples.Length);

            if (DataAvailable != null)
                DataAvailable(this, new DataAvailableEventArgs((byte[])samples.Clone()));
        }
コード例 #4
0
ファイル: VLCStream.cs プロジェクト: ispysoftware/iSpy
        private void SoundCallback(Sound soundData)
        {
            var da = DataAvailable;
            if (da == null || _needsSetup) return;

            try
            {
                var data = new byte[soundData.SamplesSize];
                Marshal.Copy(soundData.SamplesData, data, 0, (int)soundData.SamplesSize);

                if (_realChannels > 2)
                {
                    //resample audio to 2 channels
                    data = ToStereo(data, _realChannels);
                }

                _waveProvider?.AddSamples(data, 0, data.Length);

                //forces processing of volume level without piping it out
                var sampleBuffer = new float[data.Length];
                int read = _sampleChannel.Read(sampleBuffer, 0, data.Length);

                da(this, new DataAvailableEventArgs((byte[])data.Clone(),read));

                if (Listening)
                {
                    WaveOutProvider?.AddSamples(data, 0, read);
                }
            }
            catch
            {
                //can fail at shutdown
            }
        }
コード例 #5
0
 public void AddFrame(int streamId, Sound sound, long dts = -1)
 {
     var clone = DeepClone(sound);
     clone.Dts = dts;
     _mStreamData[streamId].Queue.Add(clone);
 }
コード例 #6
0
 private FrameData DeepClone(Sound sound)
 {
     var clone = DeepClone(sound.SamplesData, (int)sound.SamplesSize);
     clone.Pts = sound.Pts;
     return clone;
 }
コード例 #7
0
ファイル: VLCStream.cs プロジェクト: WildGenie/ispyconnect
        private void SoundCallback(Sound soundData)
        {
            if (DataAvailable == null || _needsSetup) return;

            var data = new byte[soundData.SamplesSize];
            Marshal.Copy(soundData.SamplesData, data, 0, (int)soundData.SamplesSize);

            if (_realChannels>2)
            {
                //resample audio to 2 channels
                data = ToStereo(data, _realChannels);
            }

            _waveProvider.AddSamples(data, 0, data.Length);

            if (Listening && WaveOutProvider != null)
            {
                WaveOutProvider.AddSamples(data, 0, data.Length);
            }

            //forces processing of volume level without piping it out
            var sampleBuffer = new float[data.Length];
            _sampleChannel.Read(sampleBuffer, 0, data.Length);

            if (DataAvailable != null)
                DataAvailable(this, new DataAvailableEventArgs((byte[])data.Clone()));
        }
コード例 #8
0
ファイル: VLCStream.cs プロジェクト: vavavr00m/ispyconnect
        private void SoundCallback(Sound soundData)
        {
            var da = DataAvailable;
            if (da == null || _needsSetup) return;

            try
            {
                var l = (int)soundData.SamplesSize;
                var data = new byte[l];
                Marshal.Copy(soundData.SamplesData, data, 0, l);

                if (_realChannels > 2)
                {
                    //resample audio to 2 channels
                    data = ToStereo(data, _realChannels);
                }

                _audioQueue.Enqueue(data);

            }
            catch (NullReferenceException)
            {
                //DataAvailable can be removed at any time
            }
            catch (Exception ex)
            {
                MainForm.LogExceptionToFile(ex, "VLC Audio");
            }
        }