[AVRT] Import Audio/Video Runtime module from Wine 9.7 (#6826)

Enhance compatibility with future programs, including browsers.
AVRT is an acronym for "Audio/Video Multimedia Realtime Runtime" and is NT6.
This commit is contained in:
Joe Mason 2024-05-07 08:40:27 -04:00 committed by GitHub
parent 2b43390d04
commit d234dc2d52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 242 additions and 0 deletions

View File

@ -262,5 +262,6 @@ add_subdirectory(xmllite)
add_subdirectory(xolehlp)
if(DLL_EXPORT_VERSION GREATER_EQUAL 0x600)
add_subdirectory(avrt)
add_subdirectory(dwmapi)
endif()

View File

@ -0,0 +1,15 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
add_definitions(-D__WINESRC__)
spec2def(avrt.dll avrt.spec)
list(APPEND SOURCE
main.c
${CMAKE_CURRENT_BINARY_DIR}/avrt_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/avrt.def)
add_library(avrt MODULE ${SOURCE})
set_module_type(avrt win32dll)
target_link_libraries(avrt wine)
add_importlibs(avrt user32 msvcrt kernel32 ntdll)
add_cd_file(TARGET avrt DESTINATION reactos/system32 FOR all)

14
dll/win32/avrt/avrt.spec Normal file
View File

@ -0,0 +1,14 @@
@ stdcall AvQuerySystemResponsiveness(long ptr)
@ stdcall AvRevertMmThreadCharacteristics(long)
@ stub AvRtCreateThreadOrderingGroup
@ stub AvRtCreateThreadOrderingGroupExA
@ stub AvRtCreateThreadOrderingGroupExW
@ stub AvRtDeleteThreadOrderingGroup
@ stub AvRtJoinThreadOrderingGroup
@ stub AvRtLeaveThreadOrderingGroup
@ stub AvRtWaitOnThreadOrderingGroup
@ stdcall AvSetMmMaxThreadCharacteristicsA(str str ptr)
@ stdcall AvSetMmMaxThreadCharacteristicsW(wstr wstr ptr)
@ stdcall AvSetMmThreadCharacteristicsA(str ptr)
@ stdcall AvSetMmThreadCharacteristicsW(wstr ptr)
@ stdcall AvSetMmThreadPriority(ptr long)

136
dll/win32/avrt/main.c Normal file
View File

@ -0,0 +1,136 @@
/* Avrt dll implementation
*
* Copyright (C) 2009 Maarten Lankhorst
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "wine/debug.h"
#include "avrt.h"
WINE_DEFAULT_DEBUG_CHANNEL(avrt);
static inline WCHAR *strdupAW(const char *src)
{
int len;
WCHAR *dst;
if (!src) return NULL;
len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
if ((dst = malloc(len * sizeof(*dst)))) MultiByteToWideChar(CP_ACP, 0, src, -1, dst, len);
return dst;
}
HANDLE WINAPI AvSetMmThreadCharacteristicsA(const char *name, DWORD *index)
{
WCHAR *nameW = NULL;
HANDLE ret;
if (name && !(nameW = strdupAW(name)))
{
SetLastError(ERROR_OUTOFMEMORY);
return NULL;
}
ret = AvSetMmThreadCharacteristicsW(nameW, index);
free(nameW);
return ret;
}
HANDLE WINAPI AvSetMmThreadCharacteristicsW(const WCHAR *name, DWORD *index)
{
FIXME("(%s,%p): stub\n", debugstr_w(name), index);
if (!name)
{
SetLastError(ERROR_INVALID_TASK_NAME);
return NULL;
}
if (!index)
{
SetLastError(ERROR_INVALID_HANDLE);
return NULL;
}
return (HANDLE)0x12345678;
}
BOOL WINAPI AvQuerySystemResponsiveness(HANDLE AvrtHandle, ULONG *value)
{
FIXME("(%p, %p): stub\n", AvrtHandle, value);
return FALSE;
}
BOOL WINAPI AvRevertMmThreadCharacteristics(HANDLE AvrtHandle)
{
FIXME("(%p): stub\n", AvrtHandle);
return TRUE;
}
BOOL WINAPI AvSetMmThreadPriority(HANDLE AvrtHandle, AVRT_PRIORITY prio)
{
FIXME("(%p)->(%u) stub\n", AvrtHandle, prio);
return TRUE;
}
HANDLE WINAPI AvSetMmMaxThreadCharacteristicsA(const char *task1, const char *task2, DWORD *index)
{
WCHAR *task1W = NULL, *task2W = NULL;
HANDLE ret;
if (task1 && !(task1W = strdupAW(task1)))
{
SetLastError(ERROR_OUTOFMEMORY);
return NULL;
}
if (task2 && !(task2W = strdupAW(task2)))
{
SetLastError(ERROR_OUTOFMEMORY);
return NULL;
}
ret = AvSetMmMaxThreadCharacteristicsW(task1W, task2W, index);
free(task2W);
free(task1W);
return ret;
}
HANDLE WINAPI AvSetMmMaxThreadCharacteristicsW(const WCHAR *task1, const WCHAR *task2, DWORD *index)
{
FIXME("(%s,%s,%p): stub\n", debugstr_w(task1), debugstr_w(task2), index);
if (!task1 || task2)
{
SetLastError(ERROR_INVALID_TASK_NAME);
return NULL;
}
if (!index)
{
SetLastError(ERROR_INVALID_HANDLE);
return NULL;
}
return (HANDLE)0x12345678;
}

View File

@ -51,6 +51,7 @@ dll/win32/atl # Synced to WineStaging-4.18
dll/win32/atl80 # Synced to WineStaging-4.18
dll/win32/atl100 # Synced to WineStaging-3.3
dll/win32/avifil32 # Synced to WineStaging-4.18
dll/win32/avrt # Synced to Wine-9.7
dll/win32/bcrypt # Synced to WineStaging-1.9.23 (+ winetest synced to 8d8936cbb6fea3cac862e059e814527f5361f48b, a.k.a 20161206-BJ)
dll/win32/browseui # Out of sync
dll/win32/cabinet # Synced to WineStaging-4.18

75
sdk/include/psdk/avrt.h Normal file
View File

@ -0,0 +1,75 @@
/*
* avrt definitions
*
* Copyright 2009 Maarten Lankhorst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#ifndef _AVRT_
#define _AVRT_
#ifdef __cplusplus
extern "C" {
#endif
typedef enum _AVRT_PRIORITY
{
AVRT_PRIORITY_VERYLOW = -2,
AVRT_PRIORITY_LOW,
AVRT_PRIORITY_NORMAL,
AVRT_PRIORITY_HIGH,
AVRT_PRIORITY_CRITICAL
} AVRT_PRIORITY, *PAVRT_PRIORITY;
/* Windows compiler is more lax */
#define THREAD_ORDER_GROUP_INFINITE_TIMEOUT ((void*)((LONG_PTR)-1))
HANDLE WINAPI AvSetMmThreadCharacteristicsA(LPCSTR TaskName, LPDWORD TaskIndex);
HANDLE WINAPI AvSetMmThreadCharacteristicsW(LPCWSTR TaskName, LPDWORD TaskIndex);
#define AvSetMmThreadCharacteristics WINELIB_NAME_AW(AvSetMmThreadCharacteristics)
HANDLE WINAPI AvSetMmMaxThreadCharacteristicsA(LPCSTR FirstTask, LPCSTR SecondTask, LPDWORD TaskIndex);
HANDLE WINAPI AvSetMmMaxThreadCharacteristicsW(LPCWSTR FirstTask, LPCWSTR SecondTask, LPDWORD TaskIndex);
#define AvSetMmMaxThreadCharacteristics WINELIB_NAME_AW(AvSetMmMaxThreadCharacteristics)
BOOL WINAPI AvRevertMmThreadCharacteristics(HANDLE AvrtHandle);
BOOL WINAPI AvSetMmThreadPriority(HANDLE AvrtHandle, AVRT_PRIORITY Priority);
BOOL WINAPI AvRtCreateThreadOrderingGroup(
PHANDLE Context, PLARGE_INTEGER Period,
GUID *ThreadOrderingGuid, PLARGE_INTEGER Timeout);
BOOL WINAPI AvRtCreateThreadOrderingGroupExA(
PHANDLE Context, PLARGE_INTEGER Period,
GUID *ThreadOrderingGuid, PLARGE_INTEGER Timeout,
LPCSTR TaskName);
BOOL WINAPI AvRtCreateThreadOrderingGroupExW(
PHANDLE Context, PLARGE_INTEGER Period,
GUID *ThreadOrderingGuid, PLARGE_INTEGER Timeout,
LPCSTR TaskName);
#define AvRtCreateThreadOrderingGroupEx WINELIB_NAME_AW(AvRtCreateThreadOrderingGroupEx)
BOOL WINAPI AvRtJoinThreadOrderingGroup(PHANDLE Context, GUID *ThreadOrderingGuid, BOOL Before);
BOOL WINAPI AvRtWaitOnThreadOrderingGroup(HANDLE Context);
BOOL WINAPI AvRtLeaveThreadOrderingGroup(HANDLE Context);
BOOL WINAPI AvRtDeleteThreadOrderingGroup(HANDLE Context);
BOOL WINAPI AvQuerySystemResponsiveness(HANDLE AvrtHandle, PULONG SystemResponsivenessValue);
#ifdef __cplusplus
}
#endif
#endif /*_AVRT_*/