From 1945ffd855ef4c8b5cd1e85f1250dfc8864ca75f Mon Sep 17 00:00:00 2001 From: sebastiii Date: Thu, 5 Oct 2017 21:24:52 +0200 Subject: [PATCH] MP1-4781V8 : madVR V340 (Handle the grabbing frame by new madVR method) --- mediaportal/Core/Player/FrameGrabber.cs | 53 ++++++++++++++++++++----- mediaportal/Core/Player/PlaneScene.cs | 5 ++- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/mediaportal/Core/Player/FrameGrabber.cs b/mediaportal/Core/Player/FrameGrabber.cs index 0c7565e97ef..ae3c1ebc378 100644 --- a/mediaportal/Core/Player/FrameGrabber.cs +++ b/mediaportal/Core/Player/FrameGrabber.cs @@ -22,8 +22,10 @@ using System.Drawing; using System.Runtime.InteropServices; using System.Threading; +using DirectShowLib; using MediaPortal.ExtensionMethods; using MediaPortal.GUI.Library; +using MediaPortal.Player; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; @@ -93,16 +95,9 @@ public Bitmap GetCurrentImage() { lock (grabNotifier) { - grabSucceeded = false; - grabSample = true; - if (!Monitor.Wait(grabNotifier, 500)) - { - Log.Debug("FrameGrabber: Timed-out waiting for grabbed frame!"); - return null; - } - - if (grabSucceeded) + if (VMR9Util.g_vmr9 != null) { + VMR9Util.g_vmr9.MadVrGrabCurrentFrame(); try { if (FrameResult != null) @@ -111,9 +106,9 @@ public Bitmap GetCurrentImage() FrameResult = null; } - if (GUIGraphicsContext.madVRFrameBitmap != null) + if (GUIGraphicsContext.madVRCurrentFrameBitmap != null) { - FrameResult = new Bitmap(GUIGraphicsContext.madVRFrameBitmap); + FrameResult = new Bitmap(GUIGraphicsContext.madVRCurrentFrameBitmap); return FrameResult; } } @@ -124,6 +119,42 @@ public Bitmap GetCurrentImage() // When Bitmap is not yet ready } } + + //////// Part of code used for D3D9 setting in madVR + //////lock (grabNotifier) + //////{ + ////// grabSucceeded = false; + ////// grabSample = true; + ////// if (!Monitor.Wait(grabNotifier, 500)) + ////// { + ////// Log.Debug("FrameGrabber: Timed-out waiting for grabbed frame!"); + ////// return null; + ////// } + + ////// if (grabSucceeded) + ////// { + ////// try + ////// { + ////// if (FrameResult != null) + ////// { + ////// FrameResult.SafeDispose(); + ////// FrameResult = null; + ////// } + + ////// if (GUIGraphicsContext.madVRFrameBitmap != null) + ////// { + ////// FrameResult = new Bitmap(GUIGraphicsContext.madVRFrameBitmap); + ////// return FrameResult; + ////// } + ////// } + ////// catch + ////// { + ////// Log.Debug("FrameGrabber: Frame grab catch failed for madVR"); + ////// return null; + ////// // When Bitmap is not yet ready + ////// } + ////// } + //////} } // Bitmap not ready return null Log.Debug("FrameGrabber: Frame grab failed for madVR"); diff --git a/mediaportal/Core/Player/PlaneScene.cs b/mediaportal/Core/Player/PlaneScene.cs index 618f621a52e..1bdf75266af 100644 --- a/mediaportal/Core/Player/PlaneScene.cs +++ b/mediaportal/Core/Player/PlaneScene.cs @@ -810,7 +810,7 @@ public void GrabMadVrFrame(IntPtr pTargetmadVrDib) public void GrabMadVrCurrentFrame(IntPtr pTargetmadVrDib) { lock (GUIGraphicsContext.RenderModeSwitch) - { + { if (GUIGraphicsContext.madVRCurrentFrameBitmap != null) { GUIGraphicsContext.madVRCurrentFrameBitmap.Dispose(); @@ -1253,6 +1253,9 @@ private int RenderLayers(GUILayers layers, Int16 width, Int16 height, Int16 arWi if (VMR9Util.g_vmr9 != null) { VMR9Util.g_vmr9.ProcessMadVrOsd(); + + // Enable the GetCurrentImage new madVR + if (grabber != null) grabber.FrameGrabberD3D9Enable = false; } } return _visible ? 0 : 1; // S_OK, S_FALSE