Files
raven/testdata/native_loader/media_client.c
T
Clansty 68e2ab517b feat: add the avrt and mfplat guest components
- native/upstream/raven-media builds avrt.dll and mfplat.dll for both widths and the runtime ships them beside itself: a media library imports both, and without mfplat.dll such a library does not load at all. cri_ware_unity.dll is one, and the program that imports it stopped before its first frame.

- avrt.dll answers the multimedia task calls with a stand-in handle. Nothing here schedules threads, so a program that asks for a task is one that raises its own priority and keeps its own period; the calls made with the handle are answered as they would be for a granted task.

- mfplat.dll answers the four factories with E_NOTIMPL rather than an object with no implementation behind it, which would fail every later call far from the request that started it.

- The new guest fixture media_client.c imports both libraries the way a media library does, and checks the task handle, its priority, its responsiveness and that each factory reports the interface as unsupported. It is built for both widths.

Assisted-by: Claude Code:deepseek-v4.1-flash-1017

AI-Scope: Wrote the two guest components from the multimedia and Media Foundation interfaces they answer, wired them into the component build and the runtime component list, and checked them with ctest (native_media_x64, native_media_x32).
2026-11-02 12:00:02 +08:00

37 lines
1.4 KiB
C

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <avrt.h>
#include <mfapi.h>
/* The multimedia components a media library takes its threads and its buffers through: avrt.dll registers a thread with the scheduler and
mfplat.dll makes the samples, types and buffers a pipeline carries. Nothing here schedules threads or carries media, so the task is a
stand-in handle and each factory names its interface as unsupported instead of handing back an object every later call fails on. */
int raven_entry(void)
{
DWORD task_index = 0xdead;
HANDLE task = AvSetMmThreadCharacteristicsW(L"Audio", &task_index);
if (!task || task_index != 0)
return 1;
if (!AvSetMmThreadPriority(task, AVRT_PRIORITY_HIGH))
return 2;
ULONG responsiveness = 0xdead;
if (AvQuerySystemResponsiveness(task, &responsiveness) != S_OK || responsiveness != 0)
return 3;
if (!AvRevertMmThreadCharacteristics(task))
return 4;
IMFSample *sample = (IMFSample *)0xdead;
if (MFCreateSample(&sample) != E_NOTIMPL || sample)
return 5;
IMFMediaType *type = (IMFMediaType *)0xdead;
if (MFCreateMediaType(&type) != E_NOTIMPL || type)
return 6;
IMFMediaBuffer *buffer = (IMFMediaBuffer *)0xdead;
if (MFCreateMemoryBuffer(4096, &buffer) != E_NOTIMPL || buffer)
return 7;
buffer = (IMFMediaBuffer *)0xdead;
if (MFCreateAlignedMemoryBuffer(4096, 16, &buffer) != E_NOTIMPL || buffer)
return 8;
return 0;
}