Skip to content

Commit

Permalink
main: Unbreak linux support
Browse files Browse the repository at this point in the history
SetHandle has to behave in a specific way in linux to support automatic
handle setting as window does.

The last update caused it to infiniloop.
  • Loading branch information
lu-zero committed Oct 14, 2016
1 parent b2d01c9 commit 3f7a978
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions src/main.cpp
Expand Up @@ -904,39 +904,63 @@ FUNCTION(mfxStatus, MFXGetPriority, (mfxSession session, mfxPriority *priority),

#undef FUNCTION

#ifdef MFX_HAVE_LINUX
static void init_internal_hwctx(mfxSession session)
{
#ifdef MFX_HAVE_LINUX
MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session;
if (!pHandle->got_user_hwctx && !pHandle->tried_internal_hwctx) {
void *handle = mfx_allocate_va(session);
if (handle)
pHandle->internal_hwctx = handle;
pHandle->tried_internal_hwctx = 1;
}
#endif
}

#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
return_value DISPATCHER_EXPOSED_PREFIX(func_name) formal_param_list \
{ \
mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session; \
/* get the function's address and make a call */ \
if (pHandle) \
{ \
mfxFunctionPointer pFunc = pHandle->callTable[e##func_name]; \
init_internal_hwctx(session); \
if (pFunc) \
{ \
/* get the real session pointer */ \
session = pHandle->session; \
/* pass down the call */ \
mfxRes = (*(mfxStatus (MFX_CDECL *) formal_param_list) pFunc) actual_param_list; \
} \
} \
return mfxRes; \
}
#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
return_value DISPATCHER_EXPOSED_PREFIX(func_name) formal_param_list \
{ \
mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *)session; \
/* get the function's address and make a call */ \
if (pHandle) \
{ \
mfxFunctionPointer pFunc = pHandle->callTable[e ## func_name]; \
if (pFunc) \
{ \
if (eMFXVideoCORE_SetHandle == e ## func_name) \
pHandle->got_user_hwctx = 1; \
else \
init_internal_hwctx(session); \
/* get the real session pointer */ \
session = pHandle->session; \
/* pass down the call */ \
mfxRes = (*(mfxStatus(MFX_CDECL *) formal_param_list)pFunc)actual_param_list; \
} \
} \
return mfxRes; \
}
#else

#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
return_value DISPATCHER_EXPOSED_PREFIX(func_name) formal_param_list \
{ \
mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *)session; \
/* get the function's address and make a call */ \
if (pHandle) \
{ \
mfxFunctionPointer pFunc = pHandle->callTable[e ## func_name]; \
if (pFunc) \
{ \
/* get the real session pointer */ \
session = pHandle->session; \
/* pass down the call */ \
mfxRes = (*(mfxStatus(MFX_CDECL *) formal_param_list)pFunc)actual_param_list; \
} \
} \
return mfxRes; \
}
#endif

#include "mfx_exposed_functions_list.h"
#undef FUNCTION
Expand Down

0 comments on commit 3f7a978

Please sign in to comment.