mfmediaengine: Send "ratechange" event for both default and playback rate changes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2814e5ce0b
commit
6fa8ff6930
|
@ -76,6 +76,8 @@ struct media_engine
|
||||||
IMFDXGIDeviceManager *dxgi_manager;
|
IMFDXGIDeviceManager *dxgi_manager;
|
||||||
enum media_engine_mode mode;
|
enum media_engine_mode mode;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
double playback_rate;
|
||||||
|
double default_playback_rate;
|
||||||
IMFMediaSession *session;
|
IMFMediaSession *session;
|
||||||
CRITICAL_SECTION cs;
|
CRITICAL_SECTION cs;
|
||||||
};
|
};
|
||||||
|
@ -344,30 +346,70 @@ static BOOL WINAPI media_engine_IsPaused(IMFMediaEngine *iface)
|
||||||
|
|
||||||
static double WINAPI media_engine_GetDefaultPlaybackRate(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)
|
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)
|
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)
|
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)
|
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->session_events.lpVtbl = &media_engine_session_events_vtbl;
|
||||||
engine->refcount = 1;
|
engine->refcount = 1;
|
||||||
engine->flags = (flags & MF_MEDIA_ENGINE_CREATEFLAGS_MASK) | FLAGS_ENGINE_PAUSED;
|
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);
|
InitializeCriticalSection(&engine->cs);
|
||||||
|
|
||||||
hr = IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, &IID_IMFMediaEngineNotify,
|
hr = IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, &IID_IMFMediaEngineNotify,
|
||||||
|
|
|
@ -310,15 +310,12 @@ 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);
|
||||||
todo_wine
|
|
||||||
ok(val == 1.0, "Unexpected rate %f.\n", val);
|
ok(val == 1.0, "Unexpected rate %f.\n", val);
|
||||||
|
|
||||||
hr = IMFMediaEngine_SetDefaultPlaybackRate(media_engine, 2.0);
|
hr = IMFMediaEngine_SetDefaultPlaybackRate(media_engine, 2.0);
|
||||||
todo_wine
|
|
||||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
val = IMFMediaEngine_GetPlaybackRate(media_engine);
|
val = IMFMediaEngine_GetPlaybackRate(media_engine);
|
||||||
todo_wine
|
|
||||||
ok(val == 1.0, "Unexpected rate %f.\n", val);
|
ok(val == 1.0, "Unexpected rate %f.\n", val);
|
||||||
|
|
||||||
hr = IMFMediaEngine_GetPlayed(media_engine, &time_range);
|
hr = IMFMediaEngine_GetPlayed(media_engine, &time_range);
|
||||||
|
@ -440,6 +437,34 @@ static void test_Play(void)
|
||||||
IMFMediaEngine_Release(media_engine);
|
IMFMediaEngine_Release(media_engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_playback_rate(void)
|
||||||
|
{
|
||||||
|
struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
|
||||||
|
IMFMediaEngineNotify *callback = ¬ify_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)
|
START_TEST(mfmediaengine)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -464,6 +489,7 @@ START_TEST(mfmediaengine)
|
||||||
test_CreateInstance();
|
test_CreateInstance();
|
||||||
test_Shutdown();
|
test_Shutdown();
|
||||||
test_Play();
|
test_Play();
|
||||||
|
test_playback_rate();
|
||||||
|
|
||||||
IMFMediaEngineClassFactory_Release(factory);
|
IMFMediaEngineClassFactory_Release(factory);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue