Commit 4d56ed9d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfmediaengine: Implement error property.

parent 9aec1ef3
......@@ -84,6 +84,7 @@ struct media_engine
double default_playback_rate;
double volume;
double duration;
MF_MEDIA_ENGINE_ERR error_code;
IMFMediaSession *session;
IMFSourceResolver *resolver;
CRITICAL_SECTION cs;
......@@ -512,16 +513,44 @@ static ULONG WINAPI media_engine_Release(IMFMediaEngine *iface)
static HRESULT WINAPI media_engine_GetError(IMFMediaEngine *iface, IMFMediaError **error)
{
FIXME("(%p, %p): stub.\n", iface, error);
struct media_engine *engine = impl_from_IMFMediaEngine(iface);
HRESULT hr = S_OK;
return E_NOTIMPL;
TRACE("%p, %p.\n", iface, error);
*error = NULL;
EnterCriticalSection(&engine->cs);
if (engine->flags & FLAGS_ENGINE_SHUT_DOWN)
hr = MF_E_SHUTDOWN;
else if (engine->error_code)
{
if (SUCCEEDED(hr = create_media_error(error)))
IMFMediaError_SetErrorCode(*error, engine->error_code);
}
LeaveCriticalSection(&engine->cs);
return hr;
}
static HRESULT WINAPI media_engine_SetErrorCode(IMFMediaEngine *iface, MF_MEDIA_ENGINE_ERR error)
static HRESULT WINAPI media_engine_SetErrorCode(IMFMediaEngine *iface, MF_MEDIA_ENGINE_ERR code)
{
FIXME("(%p, %d): stub.\n", iface, error);
struct media_engine *engine = impl_from_IMFMediaEngine(iface);
HRESULT hr = S_OK;
return E_NOTIMPL;
TRACE("%p, %u.\n", iface, code);
if ((unsigned int)code > MF_MEDIA_ENGINE_ERR_ENCRYPTED)
return E_INVALIDARG;
EnterCriticalSection(&engine->cs);
if (engine->flags & FLAGS_ENGINE_SHUT_DOWN)
hr = MF_E_SHUTDOWN;
else
engine->error_code = code;
LeaveCriticalSection(&engine->cs);
return hr;
}
static HRESULT WINAPI media_engine_SetSourceElements(IMFMediaEngine *iface, IMFMediaEngineSrcElements *elements)
......
......@@ -503,45 +503,47 @@ static void test_error(void)
eo = (void *)0xdeadbeef;
hr = IMFMediaEngine_GetError(media_engine, &eo);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!eo, "Unexpected instance.\n");
}
hr = IMFMediaEngine_SetErrorCode(media_engine, MF_MEDIA_ENGINE_ERR_ENCRYPTED + 1);
todo_wine
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMFMediaEngine_SetErrorCode(media_engine, MF_MEDIA_ENGINE_ERR_ABORTED);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
eo = NULL;
hr = IMFMediaEngine_GetError(media_engine, &eo);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!!eo, "Unexpected instance.\n");
}
eo2 = NULL;
hr = IMFMediaEngine_GetError(media_engine, &eo2);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(eo2 != eo, "Unexpected instance.\n");
}
if (eo2)
IMFMediaError_Release(eo2);
if (eo)
IMFMediaError_Release(eo);
IMFMediaError_Release(eo2);
IMFMediaError_Release(eo);
hr = IMFMediaEngine_SetErrorCode(media_engine, MF_MEDIA_ENGINE_ERR_NOERROR);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
eo = (void *)0xdeadbeef;
hr = IMFMediaEngine_GetError(media_engine, &eo);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!eo, "Unexpected instance.\n");
}
hr = IMFMediaEngine_Shutdown(media_engine);
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
eo = (void *)0xdeadbeef;
hr = IMFMediaEngine_GetError(media_engine, &eo);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
ok(!eo, "Unexpected instance.\n");
hr = IMFMediaEngine_SetErrorCode(media_engine, MF_MEDIA_ENGINE_ERR_NOERROR);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
IMFMediaEngine_Release(media_engine);
/* Error object. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment