Commit 41af1d1e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfmediaengine: Send "play" event on Play().

parent f465187f
...@@ -61,6 +61,8 @@ enum media_engine_flags ...@@ -61,6 +61,8 @@ enum media_engine_flags
FLAGS_ENGINE_SHUT_DOWN = 0x20, FLAGS_ENGINE_SHUT_DOWN = 0x20,
FLAGS_ENGINE_AUTO_PLAY = 0x40, FLAGS_ENGINE_AUTO_PLAY = 0x40,
FLAGS_ENGINE_LOOP = 0x80, FLAGS_ENGINE_LOOP = 0x80,
FLAGS_ENGINE_PAUSED = 0x100,
FLAGS_ENGINE_WAITING = 0x200,
}; };
struct media_engine struct media_engine
...@@ -328,9 +330,16 @@ static double WINAPI media_engine_GetDuration(IMFMediaEngine *iface) ...@@ -328,9 +330,16 @@ static double WINAPI media_engine_GetDuration(IMFMediaEngine *iface)
static BOOL WINAPI media_engine_IsPaused(IMFMediaEngine *iface) static BOOL WINAPI media_engine_IsPaused(IMFMediaEngine *iface)
{ {
FIXME("(%p): stub.\n", iface); struct media_engine *engine = impl_from_IMFMediaEngine(iface);
BOOL value;
return FALSE; TRACE("%p.\n", iface);
EnterCriticalSection(&engine->cs);
value = !!(engine->flags & FLAGS_ENGINE_PAUSED);
LeaveCriticalSection(&engine->cs);
return value;
} }
static double WINAPI media_engine_GetDefaultPlaybackRate(IMFMediaEngine *iface) static double WINAPI media_engine_GetDefaultPlaybackRate(IMFMediaEngine *iface)
...@@ -438,9 +447,31 @@ static HRESULT WINAPI media_engine_SetLoop(IMFMediaEngine *iface, BOOL loop) ...@@ -438,9 +447,31 @@ static HRESULT WINAPI media_engine_SetLoop(IMFMediaEngine *iface, BOOL loop)
static HRESULT WINAPI media_engine_Play(IMFMediaEngine *iface) static HRESULT WINAPI media_engine_Play(IMFMediaEngine *iface)
{ {
FIXME("(%p): stub.\n", iface); struct media_engine *engine = impl_from_IMFMediaEngine(iface);
PROPVARIANT var;
return E_NOTIMPL; TRACE("%p.\n", iface);
EnterCriticalSection(&engine->cs);
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PURGEQUEUEDEVENTS, 0, 0);
if (!(engine->flags & FLAGS_ENGINE_WAITING))
{
engine->flags &= ~FLAGS_ENGINE_PAUSED;
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PLAY, 0, 0);
var.vt = VT_EMPTY;
IMFMediaSession_Start(engine->session, &GUID_NULL, &var);
engine->flags |= FLAGS_ENGINE_WAITING;
}
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_WAITING, 0, 0);
LeaveCriticalSection(&engine->cs);
return S_OK;
} }
static HRESULT WINAPI media_engine_Pause(IMFMediaEngine *iface) static HRESULT WINAPI media_engine_Pause(IMFMediaEngine *iface)
...@@ -623,7 +654,7 @@ static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct ...@@ -623,7 +654,7 @@ static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct
engine->IMFMediaEngine_iface.lpVtbl = &media_engine_vtbl; engine->IMFMediaEngine_iface.lpVtbl = &media_engine_vtbl;
engine->session_events.lpVtbl = &media_engine_session_events_vtbl; engine->session_events.lpVtbl = &media_engine_session_events_vtbl;
engine->refcount = 1; engine->refcount = 1;
engine->flags = flags & MF_MEDIA_ENGINE_CREATEFLAGS_MASK; engine->flags = (flags & MF_MEDIA_ENGINE_CREATEFLAGS_MASK) | FLAGS_ENGINE_PAUSED;
InitializeCriticalSection(&engine->cs); InitializeCriticalSection(&engine->cs);
hr = IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, &IID_IMFMediaEngineNotify, hr = IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, &IID_IMFMediaEngineNotify,
......
...@@ -307,7 +307,6 @@ todo_wine ...@@ -307,7 +307,6 @@ todo_wine
ok(val == 0.0, "Unexpected time %f.\n", val); ok(val == 0.0, "Unexpected time %f.\n", val);
state = IMFMediaEngine_IsPaused(media_engine); state = IMFMediaEngine_IsPaused(media_engine);
todo_wine
ok(!!state, "Unexpected state %d.\n", state); ok(!!state, "Unexpected state %d.\n", state);
val = IMFMediaEngine_GetDefaultPlaybackRate(media_engine); val = IMFMediaEngine_GetDefaultPlaybackRate(media_engine);
...@@ -393,6 +392,37 @@ todo_wine ...@@ -393,6 +392,37 @@ todo_wine
IMFMediaEngine_Release(media_engine); IMFMediaEngine_Release(media_engine);
} }
static void test_Play(void)
{
struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
IMFMediaEngineNotify *callback = &notify_impl.IMFMediaEngineNotify_iface;
IMFMediaEngine *media_engine;
HRESULT hr;
BOOL ret;
media_engine = create_media_engine(callback);
ret = IMFMediaEngine_IsPaused(media_engine);
ok(ret, "Unexpected state %d.\n", ret);
hr = IMFMediaEngine_Play(media_engine);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ret = IMFMediaEngine_IsPaused(media_engine);
ok(!ret, "Unexpected state %d.\n", ret);
hr = IMFMediaEngine_Play(media_engine);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaEngine_Shutdown(media_engine);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ret = IMFMediaEngine_IsPaused(media_engine);
ok(!ret, "Unexpected state %d.\n", ret);
IMFMediaEngine_Release(media_engine);
}
START_TEST(mfmediaengine) START_TEST(mfmediaengine)
{ {
HRESULT hr; HRESULT hr;
...@@ -416,6 +446,7 @@ START_TEST(mfmediaengine) ...@@ -416,6 +446,7 @@ START_TEST(mfmediaengine)
test_factory(); test_factory();
test_CreateInstance(); test_CreateInstance();
test_Shutdown(); test_Shutdown();
test_Play();
IMFMediaEngineClassFactory_Release(factory); IMFMediaEngineClassFactory_Release(factory);
......
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