Mercurial > mplayer.hg
changeset 24770:6a8be4b73d07
Add Coinitialize function to vfw encoder and win32 loader.
Fixes crash when trying to load vp7vfw.dll in vfw2menc.
Patch by Gianluigi Tiesi mplayer___netfarm.it
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2007-September/054136.html
author | compn |
---|---|
date | Wed, 17 Oct 2007 05:14:21 +0000 |
parents | c3839c904be4 |
children | 14e4e1ca7988 |
files | libmpcodecs/ve_vfw.c loader/win32.c loader/wine/objbase.h |
diffstat | 3 files changed, 71 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/ve_vfw.c Wed Oct 17 02:24:50 2007 +0000 +++ b/libmpcodecs/ve_vfw.c Wed Oct 17 05:14:21 2007 +0000 @@ -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 @@ //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 @@ 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 @@ 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;
--- a/loader/win32.c Wed Oct 17 02:24:50 2007 +0000 +++ b/loader/win32.c Wed Oct 17 05:14:21 2007 +0000 @@ -38,6 +38,7 @@ #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 @@ 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 @@ /* * 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 @@ FF(CoCreateFreeThreadedMarshaler,-1) FF(CoCreateInstance, -1) FF(CoInitialize, -1) + FF(CoInitializeEx, -1) + FF(CoUninitialize, -1) FF(CoTaskMemAlloc, -1) FF(CoTaskMemFree, -1) FF(StringFromGUID2, -1)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loader/wine/objbase.h Wed Oct 17 05:14:21 2007 +0000 @@ -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