Skip to content

Commit

Permalink
Fork : MP1-4781 : WIP blackscreen fix V4.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastiii committed Mar 29, 2016
1 parent 34f87e2 commit e24fde9
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 73 deletions.
4 changes: 2 additions & 2 deletions mediaportal/Core/Player/BDPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -856,14 +856,13 @@ protected virtual void SetSourceDestRectangles(Rectangle source, Rectangle desti
return;
}

_basicVideo.SetSourcePosition(source.Left, source.Top, source.Width, source.Height);

if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
_basicVideo.SetDestinationPosition(destination.Left, destination.Top, destination.Width, destination.Height);
}
else
{
_basicVideo.SetSourcePosition(source.Left, source.Top, source.Width, source.Height);
_basicVideo.SetDestinationPosition(0, 0, destination.Width, destination.Height);
}
}
Expand Down Expand Up @@ -2992,6 +2991,7 @@ protected void CloseInterfaces()
{
_videoWin.put_Owner(IntPtr.Zero);
_videoWin.put_Visible(OABool.False);
_videoWin.SafeDispose();
_videoWin = null;
}

Expand Down
2 changes: 1 addition & 1 deletion mediaportal/Core/Player/BaseTSReaderPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,14 +1498,14 @@ protected virtual void SetSourceDestRectangles(Rectangle rSource, Rectangle rDes
return;
}

_basicVideo.SetSourcePosition(rSource.Left, rSource.Top, rSource.Width, rSource.Height);

if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
_basicVideo.SetDestinationPosition(rDest.Left, rDest.Top, rDest.Width, rDest.Height);
}
else
{
_basicVideo.SetSourcePosition(rSource.Left, rSource.Top, rSource.Width, rSource.Height);
_basicVideo.SetDestinationPosition(0, 0, rDest.Width, rDest.Height);
}
}
Expand Down
3 changes: 1 addition & 2 deletions mediaportal/Core/Player/DVDPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2166,14 +2166,13 @@ protected virtual void SetSourceDestRectangles(Rectangle source, Rectangle desti
return;
}

_basicVideo.SetSourcePosition(source.Left, source.Top, source.Width, source.Height);

if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
_basicVideo.SetDestinationPosition(destination.Left, destination.Top, destination.Width, destination.Height);
}
else
{
_basicVideo.SetSourcePosition(source.Left, source.Top, source.Width, source.Height);
_basicVideo.SetDestinationPosition(0, 0, destination.Width, destination.Height);
}
}
Expand Down
1 change: 1 addition & 0 deletions mediaportal/Core/Player/DVDPlayer9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ private void Cleanup()
{
_videoWin.put_Owner(IntPtr.Zero);
_videoWin.put_Visible(OABool.False);
_videoWin.SafeDispose();
_videoWin = null;
}

Expand Down
1 change: 1 addition & 0 deletions mediaportal/Core/Player/RTSPPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ private void Cleanup()
{
videoWin.put_Owner(IntPtr.Zero);
videoWin.put_Visible(OABool.False);
videoWin.SafeDispose();
videoWin = null;
}

Expand Down
1 change: 1 addition & 0 deletions mediaportal/Core/Player/TSReaderPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ private void Cleanup()
{
_videoWin.put_Owner(IntPtr.Zero);
_videoWin.put_Visible(OABool.False);
_videoWin.SafeDispose();
_videoWin = null;
}

Expand Down
5 changes: 3 additions & 2 deletions mediaportal/Core/Player/VMR9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,9 @@ public bool AddVMR9(IGraphBuilder graphBuilder)
hr = new HResult(graphBuilder.AddFilter(_vmr9Filter, "Enhanced Video Renderer"));
Log.Info("VMR9: added EVR Renderer to graph");
}
else if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
else if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
GUIGraphicsContext.ResetD3D = false;
var backbuffer = GUIGraphicsContext.DX9Device.PresentationParameters;
MadInit(_scene, backbuffer.BackBufferWidth, backbuffer.BackBufferHeight, (uint)upDevice.ToInt32(), (uint)GUIGraphicsContext.ActiveForm.ToInt32(), ref _vmr9Filter);

Expand Down
1 change: 1 addition & 0 deletions mediaportal/Core/Player/VideoPlayerVMR9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,7 @@ protected void Cleanup()
{
videoWin.put_Owner(IntPtr.Zero);
videoWin.put_Visible(OABool.False);
videoWin.SafeDispose();
videoWin = null;
}

Expand Down
121 changes: 65 additions & 56 deletions mediaportal/Core/Player/g_player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,12 @@ private static void doStop(bool keepTimeShifting, bool keepExclusiveModeOn)
}
}
}
if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR && !GUIGraphicsContext.ResetD3D)
{
// Force D3D device
Action actionResetD3D = new Action(Action.ActionType.ACTION_RESET_D3D_DEVICE, 0, 0);
GUIGraphicsContext.OnAction(actionResetD3D);
}
}

public static void UpdateMediaInfoProperties()
Expand Down Expand Up @@ -3094,9 +3100,8 @@ public static void SetVideoWindow()

public static void Init()
{
GUIGraphicsContext.OnVideoWindowChanged += new VideoWindowChangedHandler(OnVideoWindowChanged);
GUIGraphicsContext.OnGammaContrastBrightnessChanged +=
new VideoGammaContrastBrightnessHandler(OnGammaContrastBrightnessChanged);
GUIGraphicsContext.OnVideoWindowChanged += OnVideoWindowChanged;
GUIGraphicsContext.OnGammaContrastBrightnessChanged += OnGammaContrastBrightnessChanged;
}

private static void OnGammaContrastBrightnessChanged()
Expand All @@ -3118,41 +3123,44 @@ private static void OnGammaContrastBrightnessChanged()
_player.Gamma = GUIGraphicsContext.Gamma;
}

[MethodImpl(MethodImplOptions.Synchronized)]
private static void OnVideoWindowChanged()
{
if (!Playing)
{
return;
}
if (!HasVideo && !HasViz)
{
return;
}
FullScreen = GUIGraphicsContext.IsFullScreenVideo;
ARType = GUIGraphicsContext.ARType;
if (!FullScreen)
{
PositionX = GUIGraphicsContext.VideoWindow.Left;
PositionY = GUIGraphicsContext.VideoWindow.Top;
RenderWidth = GUIGraphicsContext.VideoWindow.Width;
RenderHeight = GUIGraphicsContext.VideoWindow.Height;
}
bool inTV = false;
int windowId = GUIWindowManager.ActiveWindow;
if (windowId == (int)GUIWindow.Window.WINDOW_TV ||
windowId == (int)GUIWindow.Window.WINDOW_TVGUIDE ||
windowId == (int)GUIWindow.Window.WINDOW_SEARCHTV ||
windowId == (int)GUIWindow.Window.WINDOW_SCHEDULER ||
windowId == (int)GUIWindow.Window.WINDOW_RECORDEDTV)
lock (GUIGraphicsContext.RenderLock)
{
inTV = true;
if (!Playing)
{
return;
}
if (!HasVideo && !HasViz)
{
return;
}
FullScreen = GUIGraphicsContext.IsFullScreenVideo;
ARType = GUIGraphicsContext.ARType;
if (!FullScreen)
{
PositionX = GUIGraphicsContext.VideoWindow.Left;
PositionY = GUIGraphicsContext.VideoWindow.Top;
RenderWidth = GUIGraphicsContext.VideoWindow.Width;
RenderHeight = GUIGraphicsContext.VideoWindow.Height;
}
bool inTV = false;
int windowId = GUIWindowManager.ActiveWindow;
if (windowId == (int) GUIWindow.Window.WINDOW_TV ||
windowId == (int) GUIWindow.Window.WINDOW_TVGUIDE ||
windowId == (int) GUIWindow.Window.WINDOW_SEARCHTV ||
windowId == (int) GUIWindow.Window.WINDOW_SCHEDULER ||
windowId == (int) GUIWindow.Window.WINDOW_RECORDEDTV)
{
inTV = true;
}
Visible = (FullScreen || GUIGraphicsContext.Overlay ||
windowId == (int) GUIWindow.Window.WINDOW_SCHEDULER || inTV);
{
SetVideoWindow();
}
}
Visible = (FullScreen || GUIGraphicsContext.Overlay ||
windowId == (int)GUIWindow.Window.WINDOW_SCHEDULER || inTV);
GUIWindow._mainThreadContext.Post(delegate
{
SetVideoWindow();
}, null);
}

/// <summary>
Expand Down Expand Up @@ -3727,41 +3735,42 @@ public static bool ShowFullScreenWindowTVDefault()
return false;
}

[MethodImpl(MethodImplOptions.Synchronized)]
public static bool ShowFullScreenWindowVideoDefault()
{
if (!HasVideo && !IsMusic && !IsRadio)
{
return false;
}
// are we playing music and got the fancy BassMusicPlayer?
if ((IsMusic || IsRadio) && BassMusicPlayer.IsDefaultMusicPlayer)
lock (GUIGraphicsContext.RenderLock)
{
if (GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_MUSIC)
if (!HasVideo && !IsMusic && !IsRadio)
{
return true;
return false;
}

if (GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_MUSIC_PLAYING_NOW)
// are we playing music and got the fancy BassMusicPlayer?
if ((IsMusic || IsRadio) && BassMusicPlayer.IsDefaultMusicPlayer)
{
GUIWindowManager.ShowPreviousWindow();
if (GUIWindowManager.ActiveWindow == (int) GUIWindow.Window.WINDOW_FULLSCREEN_MUSIC)
{
return true;
}

if (GUIWindowManager.ActiveWindow == (int) GUIWindow.Window.WINDOW_MUSIC_PLAYING_NOW)
{
GUIWindowManager.ShowPreviousWindow();
return true;
}

Log.Info("g_Player: ShowFullScreenWindow: No Visualisation defined. Switching to Now Playing");
GUIWindowManager.ActivateWindow((int) GUIWindow.Window.WINDOW_MUSIC_PLAYING_NOW);
return true;
}

Log.Info("g_Player: ShowFullScreenWindow: No Visualisation defined. Switching to Now Playing");
GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_MUSIC_PLAYING_NOW);
return true;
}
else
{
if (GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO)
if (GUIWindowManager.ActiveWindow == (int) GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO)
{
return true;
}
Log.Info("g_Player: ShowFullScreenWindow switching to fullscreen video");
GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);
GUIWindowManager.ActivateWindow((int) GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);
GUIGraphicsContext.IsFullScreenVideo = true;
return true;
}
GUIGraphicsContext.IsFullScreenVideo = true;
return true;
}

public static bool ShowFullScreenWindowOtherDefault()
Expand Down
1 change: 1 addition & 0 deletions mediaportal/Core/guilib/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public enum ActionType
// jumps a few seconds forward during playback of movie. Can be used in VideoFullScreen.xml window id=2005
ACTION_JUMP_MUSIC_NOW_PLAYING = 125, // jump directly to now playing screen
ACTION_ADD_TO_PLAYLIST = 126, // add item to playlist (rather than ACTION_QUEUE_ITEM which will queue item regardless of whether a playlist is being used)
ACTION_RESET_D3D_DEVICE = 127, // Reset D3D device needed with madVR
ACTION_POWER_OFF = 991, // direct action rather than through ACTION_SHUTDOWN dialog menu
ACTION_SUSPEND = 992, // direct action rather than through ACTION_SHUTDOWN dialog menu
ACTION_HIBERNATE = 993, // direct action rather than through ACTION_SHUTDOWN dialog menu
Expand Down
46 changes: 37 additions & 9 deletions mediaportal/Core/guilib/GUIWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,18 @@ public virtual bool Load(string skinFileName)
return true;
}

// else load xml file now
GUIWindow._mainThreadContext.Send(delegate
// else load xml file now
if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
LoadSkin();
}, null);
}
else
{
GUIWindow._mainThreadContext.Send(delegate
{
LoadSkin();
}, null);
}

if (!_windowAllocated)
{
Expand Down Expand Up @@ -1070,10 +1077,17 @@ protected virtual void OnPageLoad()
{
if (_isSkinLoaded && (_lastSkin != GUIGraphicsContext.Skin))
{
GUIWindow._mainThreadContext.Send(delegate
if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
LoadSkin();
}, null);
}
else
{
GUIWindow._mainThreadContext.Send(delegate
{
LoadSkin();
}, null);
}
}

if (_rememberLastFocusedControl && _rememberLastFocusedControlId >= 0)
Expand Down Expand Up @@ -1202,10 +1216,17 @@ public virtual void AllocResources()

Dispose();

GUIWindow._mainThreadContext.Send(delegate
if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
LoadSkin();
}, null);
}
else
{
GUIWindow._mainThreadContext.Send(delegate
{
LoadSkin();
}, null);
}

HashSet<int> faultyControl = new HashSet<int>();
// tell every control we're gonna alloc the resources next
Expand Down Expand Up @@ -1750,10 +1771,17 @@ public virtual bool OnMessage(GUIMessage message)
}
else
{
GUIWindow._mainThreadContext.Send(delegate
if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
{
LoadSkin();
}, null);
}
else
{
GUIWindow._mainThreadContext.Send(delegate
{
LoadSkin();
}, null);
}

if (!_windowAllocated)
{
Expand Down
7 changes: 6 additions & 1 deletion mediaportal/Core/guilib/GraphicContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,10 @@ public static bool Overlay

if (bOldOverlay != _overlay)
{
VideoWindowChanged();
if (VideoRenderer != VideoRendererType.madVR)
{
VideoWindowChanged();
}
}
}
}
Expand Down Expand Up @@ -1704,6 +1707,8 @@ public static object RenderLock
get { return RenderLoopLock; }
}

public static bool ResetD3D { get; set; }

/// <summary>
/// Enable/Disable bypassing of UI Calibration transforms
/// </summary>
Expand Down
Loading

0 comments on commit e24fde9

Please sign in to comment.