From ad097a744759c6a78e1b33ea9d2b4b2af01c529d Mon Sep 17 00:00:00 2001 From: Konstantin Date: Wed, 18 Jan 2023 19:55:25 +0100 Subject: Consistent cancellation API across the library: S_OK = continue, S_FALSE = stop --- Whisper/API/MfStructs.h | 3 +++ Whisper/API/sFullParams.h | 2 ++ Whisper/API/sLoadModelCallbacks.h | 1 + 3 files changed, 6 insertions(+) (limited to 'Whisper/API') diff --git a/Whisper/API/MfStructs.h b/Whisper/API/MfStructs.h index cd27659..39255de 100644 --- a/Whisper/API/MfStructs.h +++ b/Whisper/API/MfStructs.h @@ -40,8 +40,11 @@ namespace Whisper Stalled = 0x80, }; + // Return S_OK to continue, or S_FALSE to stop the capture session using pfnShouldCancel = HRESULT( __stdcall* )( void* pv ) noexcept; + using pfnCaptureStatus = HRESULT( __stdcall* )( void* pv, eCaptureStatus status ) noexcept; + struct sCaptureCallbacks { pfnShouldCancel shouldCancel; diff --git a/Whisper/API/sFullParams.h b/Whisper/API/sFullParams.h index 0a1d352..42d48a4 100644 --- a/Whisper/API/sFullParams.h +++ b/Whisper/API/sFullParams.h @@ -14,6 +14,8 @@ namespace Whisper }; using pfnNewSegment = HRESULT( __cdecl* )( iContext* ctx, uint32_t n_new, void* user_data ) noexcept; + + // Return S_OK to proceed, or S_FALSE to stop the process and return S_OK from runFull / runStreamed method using pfnEncoderBegin = HRESULT( __cdecl* )( iContext* ctx, void* user_data ) noexcept; enum struct eFullParamsFlags : uint32_t diff --git a/Whisper/API/sLoadModelCallbacks.h b/Whisper/API/sLoadModelCallbacks.h index f5248c6..8f274c6 100644 --- a/Whisper/API/sLoadModelCallbacks.h +++ b/Whisper/API/sLoadModelCallbacks.h @@ -3,6 +3,7 @@ namespace Whisper { using pfnLoadProgress = HRESULT( __stdcall* )( double val, void* pv ) noexcept; + // Return S_OK to continue, or S_FALSE to fail with "The operation was canceled by the user" status code using pfnCancel = HRESULT( __stdcall* )( void* pv ) noexcept; struct sLoadModelCallbacks -- cgit v1.2.3