Skip to content

Commit

Permalink
MP1-4781V10 : madVR V418 (Another rework for DVD to avoid freeze on r…
Browse files Browse the repository at this point in the history
…esume state and avoid wrong start GUI when start to play DVD)
  • Loading branch information
Sebastiii committed Dec 24, 2017
1 parent 9b92028 commit 4ff4a89
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 31 deletions.
58 changes: 30 additions & 28 deletions mediaportal/Core/Player/DVDPlayer.cs
Expand Up @@ -295,6 +295,24 @@ private bool FirstPlayDvd(string file)
_showClosedCaptions = xmlreader.GetValueAsBool("dvdplayer", "showclosedcaptions", false);
}

DvdDiscSide side;
int titles, numOfVolumes, volume;
hr = _dvdInfo.GetDVDVolumeInfo(out numOfVolumes, out volume, out side, out titles);
if (hr < 0)
{
Log.Error("DVDPlayer:Unable to get dvdvolumeinfo 0x{0:X}", hr);
CloseInterfaces();
return false; // can't read disc
}
else
{
if (titles <= 0)
{
Log.Error("DVDPlayer:DVD does not contain any titles? {0}", titles);
//return false;
}
}

SetDefaultLanguages();

hr = _mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_DVD_EVENT, IntPtr.Zero);
Expand Down Expand Up @@ -324,34 +342,6 @@ private bool FirstPlayDvd(string file)
// }
// }
//}
if (VMR9Util.g_vmr9 != null) hr = VMR9Util.g_vmr9.StartMediaCtrl(_mediaCtrl);
if (hr < 0 || hr > 1)
{
HResult hrdebug = new HResult(hr);
Log.Info(hrdebug.ToDXString());
Log.Error("DVDPlayer:Unable to start playing() 0x:{0:X}", hr);
CloseInterfaces();
return false;
}
//DsUtils.DumpFilters(_graphBuilder);

DvdDiscSide side;
int titles, numOfVolumes, volume;
hr = _dvdInfo.GetDVDVolumeInfo(out numOfVolumes, out volume, out side, out titles);
if (hr < 0)
{
Log.Error("DVDPlayer:Unable to get dvdvolumeinfo 0x{0:X}", hr);
CloseInterfaces();
return false; // can't read disc
}
else
{
if (titles <= 0)
{
Log.Error("DVDPlayer:DVD does not contain any titles? {0}", titles);
//return false;
}
}

if (_videoWin != null)
{
Expand Down Expand Up @@ -385,6 +375,18 @@ private bool FirstPlayDvd(string file)
}
}
}

if (VMR9Util.g_vmr9 != null) hr = VMR9Util.g_vmr9.StartMediaCtrl(_mediaCtrl);
if (hr < 0 || hr > 1)
{
HResult hrdebug = new HResult(hr);
Log.Info(hrdebug.ToDXString());
Log.Error("DVDPlayer:Unable to start playing() 0x:{0:X}", hr);
CloseInterfaces();
return false;
}
//DsUtils.DumpFilters(_graphBuilder);

return true;
}
catch (Exception ex)
Expand Down
3 changes: 3 additions & 0 deletions mediaportal/Core/Player/g_player.cs
Expand Up @@ -4031,6 +4031,9 @@ private static void OnMessage(GUIMessage message)
GUIGraphicsContext.ProcessMadVrOsdDisplay = false;
}
break;
case GUIMessage.MessageType.GUI_MSG_SET_RESUME_STATE:
g_Player.Player.SetResumeState((byte[])message.Object);
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions mediaportal/Core/guilib/GUIMessage.cs
Expand Up @@ -166,6 +166,7 @@ public enum MessageType
GUI_MSG_ONDISPLAYMADVRCHANGED = 202,
GUI_MSG_MADVRREPOSITION = 203,
GUI_MSG_MADVR_SCREEN_REFRESH = 204, // Set madVR screen refresh
GUI_MSG_SET_RESUME_STATE = 205,
PS_ONSTANDBY = 9999
} ;

Expand Down
4 changes: 3 additions & 1 deletion mediaportal/MediaPortal.Application/D3D.cs
Expand Up @@ -1728,7 +1728,9 @@ protected void ResumePlayer()
g_Player.PlayDVD(fileName);
if (g_Player.Playing)
{
g_Player.Player.SetResumeState(null);
// send resume thread async
var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SET_RESUME_STATE, 0, 0, 0, 0, 0, null);
GUIWindowManager.SendThreadMessage(msg);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion mediaportal/WindowPlugins/GUIVideos/GUIVideoFiles.cs
Expand Up @@ -2180,7 +2180,9 @@ public static void PlayMovieFromPlayList(bool askForResumeMovie, int iMovieIndex
{
if (g_Player.IsDVD && !_BDDetect)
{
g_Player.Player.SetResumeState(resumeData);
// send resume thread async
var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SET_RESUME_STATE, 0, 0, 0, 0, 0, resumeData);
GUIWindowManager.SendThreadMessage(msg);
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion mediaportal/WindowPlugins/GUIVideos/SelectDVDHandler.cs
Expand Up @@ -191,7 +191,9 @@ public bool OnPlayDVD(String drive, int parentId)
{
if (g_Player.IsDVD)
{
g_Player.Player.SetResumeState(resumeData);
// send resume thread async
var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SET_RESUME_STATE, 0, 0, 0, 0, 0, resumeData);
GUIWindowManager.SendThreadMessage(msg);
}
else
{
Expand Down

0 comments on commit 4ff4a89

Please sign in to comment.