Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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()));
        }
Exemplo n.º 4
0
        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
            }
        }
 public void AddFrame(int streamId, Sound sound, long dts = -1)
 {
     var clone = DeepClone(sound);
     clone.Dts = dts;
     _mStreamData[streamId].Queue.Add(clone);
 }
 private FrameData DeepClone(Sound sound)
 {
     var clone = DeepClone(sound.SamplesData, (int)sound.SamplesSize);
     clone.Pts = sound.Pts;
     return clone;
 }
Exemplo n.º 7
0
        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()));
        }
Exemplo n.º 8
0
        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");
            }
        }