From c8bb3e3bee61da10de0e9a23c8e7d1b981195efe Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 14 Apr 2008 19:58:06 +0000 Subject: [PATCH] Windows compatibility --- osdwin.cc | 52 ++++++++++++++++++++++++++++++++++++++-------- playerliveradio.cc | 6 +++--- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/osdwin.cc b/osdwin.cc index 859ac90..bf829b3 100644 --- a/osdwin.cc +++ b/osdwin.cc @@ -40,7 +40,7 @@ OsdWin::OsdWin() d3drtsurf=NULL; external_driving=false; dsallocator=NULL; - filter_type=D3DTEXF_NONE; + filter_type=D3DTEXF_FORCE_DWORD; lastrendertime=timeGetTime(); event = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL); d3dmutex = CreateMutex(NULL,FALSE,NULL); @@ -92,15 +92,34 @@ int OsdWin::init(void* device) /* We have to determine which kind of filtering is supported*/ D3DCAPS9 caps; d3ddevice->GetDeviceCaps(&caps); - filter_type=D3DTEXF_NONE; + if ( ((caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MINFLINEAR)!=0) + && ((caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR)!=0)) { + if (filter_type==D3DTEXF_FORCE_DWORD) { + filter_type=D3DTEXF_LINEAR; + } + } else { + if (filter_type==D3DTEXF_LINEAR) + { + filter_type=D3DTEXF_POINT; + } + } + if ( ((caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MINFPOINT)!=0) && ((caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MAGFPOINT)!=0)) { + if (filter_type==D3DTEXF_FORCE_DWORD) + { filter_type=D3DTEXF_POINT; } - if ( ((caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MINFLINEAR)!=0) - && ((caps.StretchRectFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR)!=0)) { - filter_type=D3DTEXF_LINEAR; + } else { + if (filter_type==D3DTEXF_POINT) { + filter_type=D3DTEXF_NONE; } + } + if (filter_type==D3DTEXF_FORCE_DWORD) { + filter_type=D3DTEXF_NONE; + } + + //Now we will create the Screen screen = new SurfaceWin(Surface::SCREEN); @@ -112,6 +131,13 @@ int OsdWin::init(void* device) return 1; } +DWORD OsdWin::getFilterCaps() +{ + if (!initted) return NULL; + D3DCAPS9 caps; + d3ddevice->GetDeviceCaps(&caps); + return caps.StretchRectFilterCaps; +} int OsdWin::InitVertexBuffer() { Video* video = Video::getInstance(); @@ -142,7 +168,7 @@ int OsdWin::InitVertexBuffer() { osdvertices[3].c=osdcolor; osdvertices[3].x=0.f-0.5f; osdvertices[3].y=((float)video->getScreenHeight())-0.5f; - osdvertices[3].z=0; + osdvertices[3].z=0.5f; osdvertices[3].rhw=1.f; osdvertices[3].u=0.f; osdvertices[3].v=texy; @@ -189,7 +215,7 @@ void OsdWin::Render() InternalRendering(NULL); lastrendertime=timeGetTime(); } else { - Sleep(5); //Sleep for 5 ms, in order to avoid blocking the other threads + Sleep(5); //Sleep for 5 ms, in order to avoid blocking the other threads } } else { DWORD time1=timeGetTime(); @@ -228,9 +254,10 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ BeginPainting(); + d3ddevice->SetRenderTarget(0,d3drtsurf);//Stupid VMR manipulates the render target if (external_driving) { //Copy video to Backbuffer - if (present!=NULL) { + if (present!=NULL ) { VideoWin* video =(VideoWin*) Video::getInstance(); /*calculating destination rect */ RECT destrect={0,0,video->getScreenWidth(),video->getScreenHeight()}; @@ -258,6 +285,7 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ sourcerect.right=sourcerect.left+correction; } d3ddevice->StretchRect(present,&sourcerect,d3drtsurf ,&destrect,filter_type); + } } else { VideoWin* video =(VideoWin*) Video::getInstance(); @@ -271,6 +299,11 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ d3ddevice->SetTexture(0,((SurfaceWin*)screen)->getD3dtexture()); //d3ddevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE); d3ddevice->SetTextureStageState(0, D3DTSS_ALPHAOP,D3DTOP_MODULATE); + + d3ddevice->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR); + d3ddevice->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR); + + d3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); d3ddevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); d3ddevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); @@ -280,7 +313,8 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ d3ddevice->DrawPrimitive(D3DPT_TRIANGLEFAN,0,2); d3ddevice->EndScene(); //Show it to the user! - if (d3ddevice->Present(NULL,NULL,NULL,NULL)==D3DERR_DEVICELOST){ + HRESULT hres; + if (hres=d3ddevice->Present(NULL,NULL,NULL,NULL)==D3DERR_DEVICELOST){ EndPainting(); if (!external_driving) DoLost(); } diff --git a/playerliveradio.cc b/playerliveradio.cc index c5a1a7c..f4846a7 100644 --- a/playerliveradio.cc +++ b/playerliveradio.cc @@ -28,6 +28,7 @@ #include "remote.h" #include "message.h" #include "channel.h" +#include "video.h" // ----------------------------------- Called from outside, one offs or info funcs @@ -45,6 +46,7 @@ PlayerLiveRadio::PlayerLiveRadio(MessageQueue* tmessageQueue, void* tmessageRece stopNow = false; state = S_STOP; + Video::getInstance()->turnVideoOff(); } PlayerLiveRadio::~PlayerLiveRadio() @@ -81,9 +83,7 @@ int PlayerLiveRadio::shutdown() delete demuxer; -#ifdef WIN32 - CloseHandle(mutex); -#endif + return 1; } -- 2.39.5