Beispiel #1
0
        public void Dispose()
        {
            _core.RetroDeinit();
            if (_resamplerState != IntPtr.Zero)
            {
                Logger.Debug("Freeing resampler state");
                SampleRate.src_delete(_resamplerState);
            }

            Logger.Debug("Freeing libretro core");
            _core.Dispose();

            Logger.Debug("Freeing callback handles");
            foreach (var handle in _delegateDictionary.Values)
            {
                handle.Free();
            }
        }
Beispiel #2
0
        private void _updateAudioContext()
        {
            _dataWasSent = false;
            _stretcher?.Dispose();
            var speedRatio = (_renderer.RefreshRate / _config.TargetFps);

            Console.Write(speedRatio);
            _stretcher = new RubberBandStretcher(
                _config.SampleRate,
                2,
                RubberBandStretcher.Options.ProcessRealTime,
                1 / speedRatio,
                speedRatio
                );

            _latencyCounter = _stretcher.GetLatency();

            if (_resamplerState != IntPtr.Zero)
            {
                SampleRate.src_delete(_resamplerState);
            }

            if (_config.SampleRate != (int)_currentSystemAvInfo.Timing.SampleRate)
            {
                _resampleNeeded     = true;
                _audioResampleRatio = (_config.SampleRate / _currentSystemAvInfo.Timing.SampleRate);
                _resamplerState     = SampleRate.src_new(SampleRate.Quality.SRC_SINC_BEST_QUALITY, 2, out var error);

                if (error > 0)
                {
                    Logger.Error("Error initializing resampler: '{0}'", SampleRate.src_strerror(error));
                }

                Logger.Debug("Audio Resample Ratio: {0}", _audioResampleRatio);
            }
            else
            {
                _resampleNeeded = false;
                Logger.Debug("Resampling not needed");
            }
        }