From bd68abc8f7b2879fe0a6dc062f65db12e3c3a667 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 27 Jan 2007 01:12:39 +0000 Subject: [PATCH] Windows updates --- GNUmakefile | 11 ++++++----- dsallocator.cc | 7 +++---- dsallocator.h | 2 +- osdwin.cc | 40 +++++++++++++++++++++++++++++----------- osdwin.h | 2 +- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index ae83373..011e9da 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,16 +1,17 @@ -CC=/home/chris/mvp/vomp/compiler/crosstool/gcc-3.4.5-glibc-2.2.5/powerpc-405-linux-gnu/bin/powerpc-405-linux-gnu-g++ -#CC = /opt/crosstool/powerpc-405-linux-gnu/gcc-2.95.3-glibc-2.2.5/bin/powerpc-405-linux-gnu-g++ -STRIP = /opt/crosstool/powerpc-405-linux-gnu/gcc-2.95.3-glibc-2.2.5/bin/powerpc-405-linux-gnu-strip +include ../crosstool/cross-var + +CC=$(CROSS)g++ +STRIP=$(CROSS)strip CXX = $(CC) -INCLUDES = -I../jpeg-6b +INCLUDES = -I../jpeg/jpeg-6b CXXFLAGS_DEV = -g -O0 -Wall -Wshadow -Werror -DDEV -D_GNU_SOURCE $(INCLUDES) CXXFLAGS_REL = -O3 -Wall -Wshadow -Werror -D_GNU_SOURCE $(INCLUDES) LDFLAGS = -Wall -static LIBPATHS = LIBS = -lpthread -lrt -CROSSLIBS = ../jpeg-6b/libjpeg.a +CROSSLIBS = ../jpeg/jpeg-6b/libjpeg.a # This is the only thing windows and linux share include objects.mk diff --git a/dsallocator.cc b/dsallocator.cc index eb7b8f9..44cb11f 100644 --- a/dsallocator.cc +++ b/dsallocator.cc @@ -52,13 +52,12 @@ HRESULT STDMETHODCALLTYPE DsAllocator::InitializeDevice(DWORD_PTR userid,VMR9All return hres; } -void DsAllocator::LostDevice() { +void DsAllocator::LostDevice(IDirect3DDevice9 *d3ddev, IDirect3D9* d3d) { if (!surfallocnotify) return ; Lock(); CleanupSurfaces(); - IDirect3DDevice9 *d3ddev; - d3ddev=((OsdWin*)Osd::getInstance())->getD3dDev(); - HMONITOR hmon=((OsdWin*)Osd::getInstance())->getD3d()->GetAdapterMonitor(D3DADAPTER_DEFAULT); +// d3ddev=((OsdWin*)Osd::getInstance())->getD3dDev(); + HMONITOR hmon=d3d->GetAdapterMonitor(D3DADAPTER_DEFAULT); surfallocnotify->ChangeD3DDevice(d3ddev,hmon); Unlock(); diff --git a/dsallocator.h b/dsallocator.h index 32cf553..27ba2ef 100644 --- a/dsallocator.h +++ b/dsallocator.h @@ -52,7 +52,7 @@ public: virtual ULONG STDMETHODCALLTYPE AddRef(); virtual ULONG STDMETHODCALLTYPE Release(); - void LostDevice(); + void LostDevice(IDirect3DDevice9 *d3ddev, IDirect3D9* d3d); protected: diff --git a/osdwin.cc b/osdwin.cc index 9896779..943201b 100644 --- a/osdwin.cc +++ b/osdwin.cc @@ -25,6 +25,8 @@ #include "surfacewin.h" #include "dsallocator.h" +#include "message.h" +#include "command.h" //This is stuff for rendering the OSD @@ -205,8 +207,19 @@ void OsdWin::RenderDS(LPDIRECT3DSURFACE9 present){ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ + WaitForSingleObject(d3dmutex,INFINITE); + HRESULT losty=d3ddevice->TestCooperativeLevel(); + if (losty==D3DERR_DEVICELOST) { + Sleep(10); + return; //Device Lost + } + if (losty==D3DERR_DEVICENOTRESET){ + DoLost(); + return; + } WaitForSingleObject(event,INFINITE); - WaitForSingleObject(d3dmutex,INFINITE); + + BeginPainting(); if (external_driving) { //Copy video to Backbuffer @@ -262,7 +275,7 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ //Show it to the user! if (d3ddevice->Present(NULL,NULL,NULL,NULL)==D3DERR_DEVICELOST){ EndPainting(); - DoLost(); + if (!external_driving) DoLost(); } EndPainting(); } @@ -272,17 +285,18 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ } } -void OsdWin::DoLost(){ +bool OsdWin::DoLost(){ Log::getInstance()->log("OSD", Log::WARN, "Direct3D Device Lost! Reobtaining..."); ResetEvent(event); if (external_driving && dsallocator!=NULL) { - dsallocator->LostDevice(); //Propagate the information through DS + dsallocator->LostDevice(d3ddevice,d3d); //Propagate the information through DS } //First we free up all resources Video* video = Video::getInstance(); ((SurfaceWin*)screen)->ReleaseSurface(); - d3drtsurf->Release(); - d3dvb->Release(); + if (d3drtsurf) d3drtsurf->Release(); + d3drtsurf=NULL; + if (d3dvb) d3dvb->Release(); d3dvb=NULL; D3DPRESENT_PARAMETERS d3dparas; ZeroMemory(&d3dparas,sizeof(d3dparas)); @@ -291,18 +305,22 @@ void OsdWin::DoLost(){ d3dparas.Windowed=TRUE; d3dparas.SwapEffect=D3DSWAPEFFECT_COPY; if (d3ddevice->Reset(&d3dparas)!=D3D_OK){ - return; + return false; } - screen->create(video->getScreenWidth(), video->getScreenHeight()); - screen->display(); - d3ddevice->GetRenderTarget(0,&d3drtsurf); + d3ddevice->GetRenderTarget(0,&d3drtsurf); InitVertexBuffer(); - //Redraw Views, Chris could you add a member function to viewman, so that + //Redraw Views, Chris could you add a member function to viewman, so that // I can cause it to completely redraw the Views? // Otherwise the OSD would be distorted after Device Lost SetEvent(event); + + screen->create(video->getScreenWidth(), video->getScreenHeight()); + screen->display(); + + return true; + } LPDIRECT3DDEVICE9 OsdWin::getD3dDev() { WaitForSingleObject(event,INFINITE);//We will only return if we are initted diff --git a/osdwin.h b/osdwin.h index 1323758..df99899 100644 --- a/osdwin.h +++ b/osdwin.h @@ -73,7 +73,7 @@ private: HANDLE d3dmutex; DWORD lastrendertime; void InternalRendering(LPDIRECT3DSURFACE9 present); - void DoLost(); + bool DoLost(); int InitVertexBuffer(); OSDVERTEX osdvertices[4]; HANDLE event; -- 2.39.5