public void Process() { if (!_isVmr9Initialized) { return; } if (!GUIGraphicsContext.Vmr9Active) { return; } if (g_Player.Playing && g_Player.IsDVD && g_Player.IsDVDMenu) { GUIGraphicsContext.Vmr9FPS = 0f; currentVmr9State = Vmr9PlayState.Playing; _scene.DrawVideo = true; _repaintTimer = DateTime.Now; return; } TimeSpan ts = DateTime.Now - _repaintTimer; int frames = FrameCounter; if (ts.TotalMilliseconds >= 1750 || (currentVmr9State == Vmr9PlayState.Repaint && FrameCounter > 0) || g_Player.Paused) // in paused state frames aren't rendered so we need "force" the GUI drawing here { _repaintTimer = DateTime.Now; GUIGraphicsContext.Vmr9FPS = ((float)(frames * 1000)) / ((float)ts.TotalMilliseconds); //Log.Info("VMR9Helper:frames:{0} fps:{1} time:{2}", frames, GUIGraphicsContext.Vmr9FPS,ts.TotalMilliseconds); FrameCounter = 0; if (_threadId == Thread.CurrentThread.ManagedThreadId) { if (_qualityInterface != null) { VideoRendererStatistics.Update(_qualityInterface); } else { Log.Debug("_qualityInterface is null!"); } } } if (currentVmr9State == Vmr9PlayState.Repaint && frames > 0) { Log.Debug("VMR9: Repainting -> Playing, Frames: {0}", frames); GUIGraphicsContext.Vmr9FPS = 50f; currentVmr9State = Vmr9PlayState.Playing; _scene.DrawVideo = true; _repaintTimer = DateTime.Now; } else if (currentVmr9State == Vmr9PlayState.Playing && GUIGraphicsContext.Vmr9FPS < 2f) { Log.Debug("VMR9Helper: Playing -> Repainting, Frames {0}", frames); GUIGraphicsContext.Vmr9FPS = 0f; currentVmr9State = Vmr9PlayState.Repaint; _scene.DrawVideo = false; } }
/// <summary> /// removes the vmr9 filter from the graph and free up all unmanaged resources /// </summary> public void Dispose() { Log.Debug("VMR9: Dispose"); if (false == _isVmr9Initialized) { return; } if (_threadId != Thread.CurrentThread.ManagedThreadId) { Log.Error("VMR9: Dispose() from wrong thread"); //return; } if (_vmr9Filter == null) { Log.Error("VMR9: Dispose() no filter"); return; } if (_scene != null) { _scene.Stop(); _instanceCounter--; _scene.Deinit(); GUIGraphicsContext.Vmr9Active = false; GUIGraphicsContext.Vmr9FPS = 0f; GUIGraphicsContext.InVmr9Render = false; currentVmr9State = Vmr9PlayState.Playing; } _vmr9MixerBitmapInterface = null; _qualityInterface = null; if (GUIGraphicsContext.IsEvr) { EvrDeinit(); } else { Vmr9Deinit(); } DirectShowUtil.ReleaseComObject(_vmr9Filter); _vmr9Filter = null; _graphBuilderInterface = null; _scene = null; g_vmr9 = null; _isVmr9Initialized = false; }
public void SetRepaint() { if (!_isVmr9Initialized) { return; } if (!GUIGraphicsContext.Vmr9Active) { return; } Log.Debug("VMR9: SetRepaint()"); FrameCounter = 0; _repaintTimer = DateTime.Now; currentVmr9State = Vmr9PlayState.Repaint; _scene.DrawVideo = false; }
public void SetRepaint() { if (!_isVmr9Initialized) { return; } if (!GUIGraphicsContext.Vmr9Active) { return; } Log.Debug("VMR9: SetRepaint()"); FrameCounter = 0; _repaintTimer = DateTime.Now; currentVmr9State = Vmr9PlayState.Repaint; if (_scene != null) _scene.DrawVideo = false; //if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR && // GUIGraphicsContext.InVmr9Render) //{ // MadVrRepeatFrameSend(); // Log.Debug("VMR9: MadVrRepeatFrameSend()"); //} }
/// <summary> /// removes the vmr9 filter from the graph and free up all unmanaged resources /// </summary> public void Dispose() { try { Log.Debug("VMR9: Dispose"); if (false == _isVmr9Initialized) { Log.Debug("VMR9: Dispose 0"); return; } if (_threadId != Thread.CurrentThread.ManagedThreadId) { Log.Error("VMR9: Dispose() from wrong thread"); //return; } if (_vmr9Filter == null) { Log.Error("VMR9: Dispose() no filter"); return; } if (_scene != null) { _scene.Stop(); _instanceCounter--; _scene.Deinit(); GUIGraphicsContext.Vmr9Active = false; GUIGraphicsContext.Vmr9FPS = 0f; GUIGraphicsContext.InVmr9Render = false; currentVmr9State = Vmr9PlayState.Playing; Log.Debug("VMR9: Dispose 1"); } _vmr9MixerBitmapInterface = null; _qualityInterface = null; if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.EVR) { EvrDeinit(); } else if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR) { Log.Debug("VMR9: Dispose MadDeinit - thread : {0}", Thread.CurrentThread.Name); GC.Collect(); MadDeinit(); GC.Collect(); MadvrInterface.restoreDisplayModeNow(_vmr9Filter); DirectShowUtil.FinalReleaseComObject(_vmr9Filter); Log.Debug("VMR9: Dispose 2"); } else { Vmr9Deinit(); } if (_vmr9Filter != null) { DirectShowUtil.RemoveFilter(_graphBuilder, _vmr9Filter); DirectShowUtil.ReleaseComObject(_vmr9Filter); Log.Debug("VMR9: Dispose 3"); } g_vmr9.Enable(false); _scene = null; g_vmr9 = null; _isVmr9Initialized = false; GUIGraphicsContext.DX9DeviceMadVr = null; Log.Debug("VMR9: Dispose 4"); } catch (Exception) { _vmr9Filter = null; _scene = null; g_vmr9 = null; _isVmr9Initialized = false; GUIGraphicsContext.DX9DeviceMadVr = null; } finally { RestoreGuiForMadVr(); DirectShowUtil.TryRelease(ref _vmr9Filter); GUIWindowManager.MadVrProcess(); _vmr9Filter = null; Log.Debug("VMR9: Dispose done"); } }