Commit 6fa8ff69 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfmediaengine: Send "ratechange" event for both default and playback rate changes.

parent 2814e5ce
......@@ -76,6 +76,8 @@ struct media_engine
IMFDXGIDeviceManager *dxgi_manager;
enum media_engine_mode mode;
unsigned int flags;
double playback_rate;
double default_playback_rate;
IMFMediaSession *session;
CRITICAL_SECTION cs;
};
......@@ -344,30 +346,70 @@ static BOOL WINAPI media_engine_IsPaused(IMFMediaEngine *iface)
static double WINAPI media_engine_GetDefaultPlaybackRate(IMFMediaEngine *iface)
{
FIXME("(%p): stub.\n", iface);
struct media_engine *engine = impl_from_IMFMediaEngine(iface);
double rate;
return 0.0;
TRACE("%p.\n", iface);
EnterCriticalSection(&engine->cs);
rate = engine->default_playback_rate;
LeaveCriticalSection(&engine->cs);
return rate;
}
static HRESULT WINAPI media_engine_SetDefaultPlaybackRate(IMFMediaEngine *iface, double rate)
{
FIXME("(%p, %f): stub.\n", iface, rate);
struct media_engine *engine = impl_from_IMFMediaEngine(iface);
HRESULT hr = S_OK;
return E_NOTIMPL;
TRACE("%p, %f.\n", iface, rate);
EnterCriticalSection(&engine->cs);
if (engine->flags & FLAGS_ENGINE_SHUT_DOWN)
hr = MF_E_SHUTDOWN;
else if (engine->default_playback_rate != rate)
{
engine->default_playback_rate = rate;
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_RATECHANGE, 0, 0);
}
LeaveCriticalSection(&engine->cs);
return hr;
}
static double WINAPI media_engine_GetPlaybackRate(IMFMediaEngine *iface)
{
FIXME("(%p): stub.\n", iface);
struct media_engine *engine = impl_from_IMFMediaEngine(iface);
double rate;
return 0.0;
TRACE("%p.\n", iface);
EnterCriticalSection(&engine->cs);
rate = engine->playback_rate;
LeaveCriticalSection(&engine->cs);
return rate;
}
static HRESULT WINAPI media_engine_SetPlaybackRate(IMFMediaEngine *iface, double rate)
{
FIXME("(%p, %f): stub.\n", iface, rate);
struct media_engine *engine = impl_from_IMFMediaEngine(iface);
HRESULT hr = S_OK;
return E_NOTIMPL;
TRACE("%p, %f.\n", iface, rate);
EnterCriticalSection(&engine->cs);
if (engine->flags & FLAGS_ENGINE_SHUT_DOWN)
hr = MF_E_SHUTDOWN;
else if (engine->playback_rate != rate)
{
engine->playback_rate = rate;
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_RATECHANGE, 0, 0);
}
LeaveCriticalSection(&engine->cs);
return hr;
}
static HRESULT WINAPI media_engine_GetPlayed(IMFMediaEngine *iface, IMFMediaTimeRange **played)
......@@ -672,6 +714,8 @@ static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct
engine->session_events.lpVtbl = &media_engine_session_events_vtbl;
engine->refcount = 1;
engine->flags = (flags & MF_MEDIA_ENGINE_CREATEFLAGS_MASK) | FLAGS_ENGINE_PAUSED;
engine->default_playback_rate = 1.0;
engine->playback_rate = 1.0;
InitializeCriticalSection(&engine->cs);
hr = IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, &IID_IMFMediaEngineNotify,
......
......@@ -310,15 +310,12 @@ todo_wine
ok(!!state, "Unexpected state %d.\n", state);
val = IMFMediaEngine_GetDefaultPlaybackRate(media_engine);
todo_wine
ok(val == 1.0, "Unexpected rate %f.\n", val);
hr = IMFMediaEngine_SetDefaultPlaybackRate(media_engine, 2.0);
todo_wine
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
val = IMFMediaEngine_GetPlaybackRate(media_engine);
todo_wine
ok(val == 1.0, "Unexpected rate %f.\n", val);
hr = IMFMediaEngine_GetPlayed(media_engine, &time_range);
......@@ -440,6 +437,34 @@ static void test_Play(void)
IMFMediaEngine_Release(media_engine);
}
static void test_playback_rate(void)
{
struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
IMFMediaEngineNotify *callback = &notify_impl.IMFMediaEngineNotify_iface;
IMFMediaEngine *media_engine;
double rate;
HRESULT hr;
media_engine = create_media_engine(callback);
rate = IMFMediaEngine_GetDefaultPlaybackRate(media_engine);
ok(rate == 1.0, "Unexpected default rate.\n");
rate = IMFMediaEngine_GetPlaybackRate(media_engine);
ok(rate == 1.0, "Unexpected default rate.\n");
hr = IMFMediaEngine_SetPlaybackRate(media_engine, 0.0);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
rate = IMFMediaEngine_GetPlaybackRate(media_engine);
ok(rate == 0.0, "Unexpected default rate.\n");
hr = IMFMediaEngine_SetDefaultPlaybackRate(media_engine, 0.0);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IMFMediaEngine_Release(media_engine);
}
START_TEST(mfmediaengine)
{
HRESULT hr;
......@@ -464,6 +489,7 @@ START_TEST(mfmediaengine)
test_CreateInstance();
test_Shutdown();
test_Play();
test_playback_rate();
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