mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
20 lines
620 B
C++
20 lines
620 B
C++
|
|
#include "LoopbackCapture.h"
|
|
#define DECLARE extern "C" __declspec(dllexport)
|
|
|
|
DECLARE void StartCaptureAsync(void (*datacb)(void *ptr, size_t size), void (*handlecb)(HANDLE))
|
|
{
|
|
auto mutex = CreateSemaphoreW(NULL, 0, 1, NULL);
|
|
handlecb(mutex);
|
|
CLoopbackCapture loopbackCapture;
|
|
loopbackCapture.StartCaptureAsync(GetCurrentProcessId(), false);
|
|
WaitForSingleObject(mutex, INFINITE);
|
|
CloseHandle(mutex);
|
|
loopbackCapture.StopCaptureAsync();
|
|
datacb(loopbackCapture.buffer.data(), loopbackCapture.buffer.size());
|
|
}
|
|
|
|
DECLARE void StopCaptureAsync(HANDLE m)
|
|
{
|
|
ReleaseSemaphore(m, 1, NULL);
|
|
} |