Skip to content

Commit 3f7a978

Browse files
committed
main: Unbreak linux support
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.
1 parent b2d01c9 commit 3f7a978

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

src/main.cpp

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -904,39 +904,63 @@ FUNCTION(mfxStatus, MFXGetPriority, (mfxSession session, mfxPriority *priority),
904904

905905
#undef FUNCTION
906906

907+
#ifdef MFX_HAVE_LINUX
907908
static void init_internal_hwctx(mfxSession session)
908909
{
909-
#ifdef MFX_HAVE_LINUX
910910
MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session;
911911
if (!pHandle->got_user_hwctx && !pHandle->tried_internal_hwctx) {
912912
void *handle = mfx_allocate_va(session);
913913
if (handle)
914914
pHandle->internal_hwctx = handle;
915915
pHandle->tried_internal_hwctx = 1;
916916
}
917-
#endif
918917
}
919918

920-
#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
921-
return_value DISPATCHER_EXPOSED_PREFIX(func_name) formal_param_list \
922-
{ \
923-
mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
924-
MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *) session; \
925-
/* get the function's address and make a call */ \
926-
if (pHandle) \
927-
{ \
928-
mfxFunctionPointer pFunc = pHandle->callTable[e##func_name]; \
929-
init_internal_hwctx(session); \
930-
if (pFunc) \
931-
{ \
932-
/* get the real session pointer */ \
933-
session = pHandle->session; \
934-
/* pass down the call */ \
935-
mfxRes = (*(mfxStatus (MFX_CDECL *) formal_param_list) pFunc) actual_param_list; \
936-
} \
937-
} \
938-
return mfxRes; \
939-
}
919+
#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
920+
return_value DISPATCHER_EXPOSED_PREFIX(func_name) formal_param_list \
921+
{ \
922+
mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
923+
MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *)session; \
924+
/* get the function's address and make a call */ \
925+
if (pHandle) \
926+
{ \
927+
mfxFunctionPointer pFunc = pHandle->callTable[e ## func_name]; \
928+
if (pFunc) \
929+
{ \
930+
if (eMFXVideoCORE_SetHandle == e ## func_name) \
931+
pHandle->got_user_hwctx = 1; \
932+
else \
933+
init_internal_hwctx(session); \
934+
/* get the real session pointer */ \
935+
session = pHandle->session; \
936+
/* pass down the call */ \
937+
mfxRes = (*(mfxStatus(MFX_CDECL *) formal_param_list)pFunc)actual_param_list; \
938+
} \
939+
} \
940+
return mfxRes; \
941+
}
942+
#else
943+
944+
#define FUNCTION(return_value, func_name, formal_param_list, actual_param_list) \
945+
return_value DISPATCHER_EXPOSED_PREFIX(func_name) formal_param_list \
946+
{ \
947+
mfxStatus mfxRes = MFX_ERR_INVALID_HANDLE; \
948+
MFX_DISP_HANDLE *pHandle = (MFX_DISP_HANDLE *)session; \
949+
/* get the function's address and make a call */ \
950+
if (pHandle) \
951+
{ \
952+
mfxFunctionPointer pFunc = pHandle->callTable[e ## func_name]; \
953+
if (pFunc) \
954+
{ \
955+
/* get the real session pointer */ \
956+
session = pHandle->session; \
957+
/* pass down the call */ \
958+
mfxRes = (*(mfxStatus(MFX_CDECL *) formal_param_list)pFunc)actual_param_list; \
959+
} \
960+
} \
961+
return mfxRes; \
962+
}
963+
#endif
940964

941965
#include "mfx_exposed_functions_list.h"
942966
#undef FUNCTION

0 commit comments

Comments
 (0)