diff --git a/src/detection/media/media_windows.cpp b/src/detection/media/media_windows.cpp index aaf9da919..f0ebd35f8 100644 --- a/src/detection/media/media_windows.cpp +++ b/src/detection/media/media_windows.cpp @@ -16,8 +16,6 @@ extern "C" { #include #include - #define FF_BIND_FRONT(method, pobject) std::bind_front(&std::remove_cvref_t::method, (pobject)) - using winrt::impl::abi_t; using winrt::Windows::Foundation::IAsyncOperation; using winrt::Windows::Foundation::IAsyncOperationWithProgress; @@ -82,10 +80,10 @@ static HRESULT ffWaitForAsyncOperation(TOperationAbi* operation, TResultAbi** re return operation->GetResults((void**) result); } -template -static HRESULT ffRunAndWait(TOperation&& operation, abi_t** result, TArgs&&... args) { +template +static HRESULT ffRunAndWait(TOperation&& operation, abi_t** result) { abi_t>* FF_AUTO_RELEASE_COM_OBJECT opResult = NULL; - HRESULT hr = operation(std::forward(args)..., reinterpret_cast(&opResult)); + HRESULT hr = operation(reinterpret_cast(&opResult)); if (FAILED(hr) || !opResult) { return hr; } @@ -93,12 +91,12 @@ static HRESULT ffRunAndWait(TOperation&& operation, abi_t** r return ffWaitForAsyncOperation(opResult, result); } -template -static HRESULT ffRunAndWait2(TOperation&& operation, abi_t** result, TArgs&&... args) { +template +static HRESULT ffRunAndWait2(TOperation&& operation, abi_t** result) { *result = NULL; abi_t>* FF_AUTO_RELEASE_COM_OBJECT opResult = NULL; - HRESULT hr = operation(std::forward(args)..., reinterpret_cast(&opResult)); + HRESULT hr = operation(reinterpret_cast(&opResult)); if (FAILED(hr) || !opResult) { return hr; } @@ -110,7 +108,10 @@ static HRESULT ffSaveThumbnailToTempPath( abi_t* thumbnail, FFstrbuf* destination) { abi_t* FF_AUTO_RELEASE_COM_OBJECT contentStream = NULL; - HRESULT hr = ffRunAndWait(FF_BIND_FRONT(OpenReadAsync, thumbnail), &contentStream); + HRESULT hr = ffRunAndWait([=](void** result) { + return thumbnail->OpenReadAsync(result); + }, + &contentStream); if (FAILED(hr) || !contentStream) { return FAILED(hr) ? hr : E_FAIL; } @@ -150,7 +151,10 @@ static HRESULT ffSaveThumbnailToTempPath( } abi_t* FF_AUTO_RELEASE_COM_OBJECT readBuffer = NULL; - hr = ffRunAndWait2(FF_BIND_FRONT(ReadAsync, inputStream), &readBuffer, buffer, (uint32_t) size, static_cast(winrt::Windows::Storage::Streams::InputStreamOptions::None)); + hr = ffRunAndWait2([=](void** result) { + return inputStream->ReadAsync(buffer, (uint32_t) size, (uint32_t) winrt::Windows::Storage::Streams::InputStreamOptions::None, result); + }, + &readBuffer); if (FAILED(hr) || !readBuffer) { return FAILED(hr) ? hr : E_FAIL; } @@ -221,7 +225,10 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } abi_t* FF_AUTO_RELEASE_COM_OBJECT manager = NULL; - hr = ffRunAndWait(FF_BIND_FRONT(RequestAsync, managerStatics), &manager); + hr = ffRunAndWait([=](void** result) { + return managerStatics->RequestAsync(result); + }, + &manager); if (FAILED(hr) || !manager) { error = "winrt: RequestAsync().GetResults() failed"; break; @@ -288,7 +295,10 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } abi_t* FF_AUTO_RELEASE_COM_OBJECT mediaProps = NULL; - hr = ffRunAndWait(FF_BIND_FRONT(TryGetMediaPropertiesAsync, session), &mediaProps); + hr = ffRunAndWait([=](void** result) { + return session->TryGetMediaPropertiesAsync(result); + }, + &mediaProps); if (FAILED(hr) || !mediaProps) { error = "winrt: TryGetMediaPropertiesAsync().GetResults() failed"; break;