Skip to content

Commit

Permalink
MP1-4781V8 : madVR V340 (Handle the grabbing frame by new madVR method)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastiii committed Oct 6, 2017
1 parent 7716720 commit 1945ffd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
53 changes: 42 additions & 11 deletions mediaportal/Core/Player/FrameGrabber.cs
Expand Up @@ -22,8 +22,10 @@
using System.Drawing; using System.Drawing;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using DirectShowLib;
using MediaPortal.ExtensionMethods; using MediaPortal.ExtensionMethods;
using MediaPortal.GUI.Library; using MediaPortal.GUI.Library;
using MediaPortal.Player;
using Microsoft.DirectX; using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D; using Microsoft.DirectX.Direct3D;


Expand Down Expand Up @@ -93,16 +95,9 @@ public Bitmap GetCurrentImage()
{ {
lock (grabNotifier) lock (grabNotifier)
{ {
grabSucceeded = false; if (VMR9Util.g_vmr9 != null)
grabSample = true;
if (!Monitor.Wait(grabNotifier, 500))
{
Log.Debug("FrameGrabber: Timed-out waiting for grabbed frame!");
return null;
}

if (grabSucceeded)
{ {
VMR9Util.g_vmr9.MadVrGrabCurrentFrame();
try try
{ {
if (FrameResult != null) if (FrameResult != null)
Expand All @@ -111,9 +106,9 @@ public Bitmap GetCurrentImage()
FrameResult = null; FrameResult = null;
} }


if (GUIGraphicsContext.madVRFrameBitmap != null) if (GUIGraphicsContext.madVRCurrentFrameBitmap != null)
{ {
FrameResult = new Bitmap(GUIGraphicsContext.madVRFrameBitmap); FrameResult = new Bitmap(GUIGraphicsContext.madVRCurrentFrameBitmap);
return FrameResult; return FrameResult;
} }
} }
Expand All @@ -124,6 +119,42 @@ public Bitmap GetCurrentImage()
// When Bitmap is not yet ready // 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 // Bitmap not ready return null
Log.Debug("FrameGrabber: Frame grab failed for madVR"); Log.Debug("FrameGrabber: Frame grab failed for madVR");
Expand Down
5 changes: 4 additions & 1 deletion mediaportal/Core/Player/PlaneScene.cs
Expand Up @@ -810,7 +810,7 @@ public void GrabMadVrFrame(IntPtr pTargetmadVrDib)
public void GrabMadVrCurrentFrame(IntPtr pTargetmadVrDib) public void GrabMadVrCurrentFrame(IntPtr pTargetmadVrDib)
{ {
lock (GUIGraphicsContext.RenderModeSwitch) lock (GUIGraphicsContext.RenderModeSwitch)
{ {
if (GUIGraphicsContext.madVRCurrentFrameBitmap != null) if (GUIGraphicsContext.madVRCurrentFrameBitmap != null)
{ {
GUIGraphicsContext.madVRCurrentFrameBitmap.Dispose(); GUIGraphicsContext.madVRCurrentFrameBitmap.Dispose();
Expand Down Expand Up @@ -1253,6 +1253,9 @@ private int RenderLayers(GUILayers layers, Int16 width, Int16 height, Int16 arWi
if (VMR9Util.g_vmr9 != null) if (VMR9Util.g_vmr9 != null)
{ {
VMR9Util.g_vmr9.ProcessMadVrOsd(); VMR9Util.g_vmr9.ProcessMadVrOsd();

// Enable the GetCurrentImage new madVR
if (grabber != null) grabber.FrameGrabberD3D9Enable = false;
} }
} }
return _visible ? 0 : 1; // S_OK, S_FALSE return _visible ? 0 : 1; // S_OK, S_FALSE
Expand Down

0 comments on commit 1945ffd

Please sign in to comment.