]> git.vomp.tv Git - vompclient.git/commitdiff
Windows compatibility
authorChris Tallon <chris@vomp.tv>
Mon, 14 Apr 2008 19:58:06 +0000 (19:58 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 14 Apr 2008 19:58:06 +0000 (19:58 +0000)
osdwin.cc
playerliveradio.cc

index 859ac901f35b0192b207aebcb3b0257068d494a6..bf829b3f594fd6d4b34172b264adec0c3c20e127 100644 (file)
--- 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();
                }
index c5a1a7cf95d1ec25629eca4438d2e92c6fb6687b..f4846a7e7fc244b87fe47b92412e38bc52fad9a3 100644 (file)
@@ -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;
 }