summaryrefslogtreecommitdiffstats
path: root/libvo/vo_direct3d.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-02-03 11:00:09 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-02-03 11:00:09 +0000
commit0fcb10126775c40a9cba9c2cb43cd57ef13bbaa6 (patch)
treee1ce03e992b4e52242d98e71a0eb94810497c528 /libvo/vo_direct3d.c
parentcd8ef8a8f609e99d0225a27ceb84afa8cfe5d962 (diff)
downloadmpv-0fcb10126775c40a9cba9c2cb43cd57ef13bbaa6.tar.bz2
mpv-0fcb10126775c40a9cba9c2cb43cd57ef13bbaa6.tar.xz
Add checks that a D3D device is available before attempting rendering.
We may have lost the device e.g. because it became uncooperative e.g. when using remote desktop or Vista's UAC is activated. Patch by Georgi Petrov [gogothebee gmail com] git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28457 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/vo_direct3d.c')
-rw-r--r--libvo/vo_direct3d.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index 2f4847ee10..b9ad1002ad 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -566,6 +566,11 @@ static uint32_t render_d3d_frame(mp_image_t *mpi)
* if (mpi->flags & MP_IMGFLAG_DIRECT) ...
*/
+ /* If the D3D device is uncooperative (not initialized), return success.
+ The device will be probed for reinitialization in the next flip_page() */
+ if (!priv->d3d_device)
+ return VO_TRUE;
+
if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
goto skip_upload;
@@ -858,7 +863,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
static void flip_page(void)
{
RECT rect = {0, 0, vo_dwidth, vo_dheight};
- if (FAILED(IDirect3DDevice9_Present(priv->d3d_device, &rect, 0, 0, 0))) {
+ if (!priv->d3d_device ||
+ FAILED(IDirect3DDevice9_Present(priv->d3d_device, &rect, 0, 0, 0))) {
mp_msg(MSGT_VO, MSGL_V,
"<vo_direct3d>Trying to reinitialize uncooperative video adapter.\n");
if (!reconfigure_d3d()) {
@@ -909,6 +915,11 @@ static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y )
char *dst; /**< Pointer to the destination image */
int uv_stride; /**< Stride of the U/V planes */
+ /* If the D3D device is uncooperative (not initialized), return success.
+ The device will be probed for reinitialization in the next flip_page() */
+ if (!priv->d3d_device)
+ return 0;
+
/* Lock the offscreen surface if it's not already locked. */
if (!priv->locked_rect.pBits) {
if (FAILED(IDirect3DSurface9_LockRect(priv->d3d_surface,
@@ -1017,6 +1028,10 @@ static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
*/
static void draw_osd(void)
{
+ // we can not render OSD if we lost the device e.g. because it was uncooperative
+ if (!priv->d3d_device)
+ return;
+
if (vo_osd_changed(0)) {
D3DLOCKED_RECT locked_rect; /**< Offscreen surface we lock in order
to copy MPlayer's frame inside it.*/