[MPlayer-cvslog] r24798 - in trunk: libmpcodecs/ve_vfw.c loader/win32.c loader/wine/objbase.h

compn subversion at mplayerhq.hu
Wed Oct 17 07:14:21 CEST 2007


Author: compn
Date: Wed Oct 17 07:14:21 2007
New Revision: 24798

Log:
vfw fixes
patch by Gianluigi Tiesi mplayer___netfarm.it
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2007-September/054136.html

Added:
   trunk/loader/wine/objbase.h
Modified:
   trunk/libmpcodecs/ve_vfw.c
   trunk/loader/win32.c

Modified: trunk/libmpcodecs/ve_vfw.c
==============================================================================
--- trunk/libmpcodecs/ve_vfw.c	(original)
+++ trunk/libmpcodecs/ve_vfw.c	Wed Oct 17 07:14:21 2007
@@ -19,6 +19,8 @@
 //#include "loader/wine/mmreg.h"
 #include "loader/wine/vfw.h"
 #include "loader/wine/avifmt.h"
+#include "loader/wine/winerror.h"
+#include "loader/wine/objbase.h"
 
 #include "img_format.h"
 #include "mp_image.h"
@@ -31,6 +33,7 @@
 
 static char *vfw_param_codec = NULL;
 static char *vfw_param_compdata = NULL;
+static HRESULT CoInitRes = -1;
 
 #include "m_option.h"
 
@@ -63,7 +66,7 @@ static BITMAPINFOHEADER* vfw_open_encode
 //sh_video = malloc(sizeof(sh_video_t));
 
   mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Encoder init =======\n");
-
+  CoInitRes = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 //  memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
 //  output_bih->biSize = sizeof(BITMAPINFOHEADER);
 
@@ -295,6 +298,24 @@ static int put_image(struct vf_instance_
     return 1;
 }
 
+static void uninit(struct vf_instance_s* vf)
+{
+    HRESULT ret;
+
+    if(encoder_hic){
+        if(encoder_buf){
+            ret=ICCompressEnd(encoder_hic);
+            if(ret) mp_msg(MSGT_WIN32, MSGL_WARN, "ICCompressEnd failed: %ld\n", ret);
+            free(encoder_buf);
+            encoder_buf=NULL;
+        }
+        ret=ICClose(encoder_hic);
+        if(ret) mp_msg(MSGT_WIN32, MSGL_WARN, "ICClose failed: %ld\n", ret);
+        encoder_hic=0;
+        if ((CoInitRes == S_OK) || (CoInitRes == S_FALSE)) CoUninitialize();
+    }
+}
+
 //===========================================================================//
 
 static int vf_open(vf_instance_t *vf, char* args){
@@ -303,6 +324,7 @@ static int vf_open(vf_instance_t *vf, ch
     vf->control=control;
     vf->query_format=query_format;
     vf->put_image=put_image;
+    vf->uninit=uninit;
     vf->priv=malloc(sizeof(struct vf_priv_s));
     memset(vf->priv,0,sizeof(struct vf_priv_s));
     vf->priv->mux=(muxer_stream_t*)args;

Modified: trunk/loader/win32.c
==============================================================================
--- trunk/loader/win32.c	(original)
+++ trunk/loader/win32.c	Wed Oct 17 07:14:21 2007
@@ -38,6 +38,7 @@ for DLL to know too much about its envir
 #include "wine/debugtools.h"
 #include "wine/module.h"
 #include "wine/winuser.h"
+#include "wine/objbase.h"
 
 #include <stdio.h>
 #include "win32.h"
@@ -3816,6 +3817,12 @@ static int WINAPI expDuplicateHandle(HAN
     return 1;
 }
 
+static HRESULT WINAPI expCoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
+{
+    dbgprintf("CoInitializeEx(%p, %d) called\n", lpReserved, dwCoInit);
+    return S_OK;
+}
+
 // required by PIM1 codec (used by win98 PCTV Studio capture sw)
 static HRESULT WINAPI expCoInitialize(
 				      LPVOID lpReserved	/* [in] pointer to win32 malloc interface
@@ -3825,7 +3832,26 @@ static HRESULT WINAPI expCoInitialize(
     /*
      * Just delegate to the newer method.
      */
-    return 0; //CoInitializeEx(lpReserved, COINIT_APARTMENTTHREADED);
+    return expCoInitializeEx(lpReserved, COINIT_APARTMENTTHREADED);
+}
+
+static void WINAPI expCoUninitialize(void)
+{
+    dbgprintf("CoUninitialize() called\n");
+} 
+
+/* allow static linking */
+HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
+{
+    return expCoInitializeEx(lpReserved, dwCoInit);
+}
+HRESULT WINAPI CoInitialize(LPVOID lpReserved)
+{
+    return expCoInitialize(lpReserved); 
+}
+void WINAPI CoUninitialize(void)
+{
+    return expCoUninitialize();
 }
 
 static DWORD WINAPI expSetThreadAffinityMask
@@ -5132,6 +5158,8 @@ struct exports exp_ole32[]={
     FF(CoCreateFreeThreadedMarshaler,-1)
     FF(CoCreateInstance, -1)
     FF(CoInitialize, -1)
+    FF(CoInitializeEx, -1)
+    FF(CoUninitialize, -1)
     FF(CoTaskMemAlloc, -1)
     FF(CoTaskMemFree, -1)
     FF(StringFromGUID2, -1)

Added: trunk/loader/wine/objbase.h
==============================================================================
--- (empty file)
+++ trunk/loader/wine/objbase.h	Wed Oct 17 07:14:21 2007
@@ -0,0 +1,19 @@
+#ifndef WINE_OBJBASE_H
+#define WINE_OBJBASE_H
+
+#ifndef STDCALL
+#define STDCALL __attribute__((__stdcall__))
+#endif
+
+/* from objbase.h needed for ve_vfw.c */
+typedef enum tagCOINIT {
+    COINIT_APARTMENTTHREADED    = 0x2,
+    COINIT_MULTITHREADED        = 0x0,
+    COINIT_DISABLE_OLE1DDE      = 0x4,
+    COINIT_SPEED_OVER_MEMORY    = 0x8
+} COINIT;
+
+HRESULT STDCALL CoInitialize(LPVOID pvReserved);
+HRESULT STDCALL CoInitializeEx(LPVOID pvReserved, DWORD dwCoinit);
+void STDCALL CoUninitialize(void);
+#endif



More information about the MPlayer-cvslog mailing list