Nikolay Sivov : mfplay: Partially implement GetDuration().
Alexandre Julliard
julliard at winehq.org
Mon Oct 25 16:30:07 CDT 2021
Module: wine
Branch: master
Commit: 9d6fc061c97a247ffce7134d429d10fc13a9d9c9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9d6fc061c97a247ffce7134d429d10fc13a9d9c9
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Oct 25 13:04:20 2021 +0300
mfplay: Partially implement GetDuration().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mfplay/player.c | 22 +++++++++++++++++++---
dlls/mfplay/tests/mfplay.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplay/player.c b/dlls/mfplay/player.c
index adb88fff053..0e33dcbd649 100644
--- a/dlls/mfplay/player.c
+++ b/dlls/mfplay/player.c
@@ -909,11 +909,27 @@ static HRESULT WINAPI media_player_GetPosition(IMFPMediaPlayer *iface, REFGUID p
return E_NOTIMPL;
}
-static HRESULT WINAPI media_player_GetDuration(IMFPMediaPlayer *iface, REFGUID postype, PROPVARIANT *position)
+static HRESULT WINAPI media_player_GetDuration(IMFPMediaPlayer *iface, REFGUID postype, PROPVARIANT *duration)
{
- FIXME("%p, %s, %p.\n", iface, debugstr_guid(postype), position);
+ struct media_player *player = impl_from_IMFPMediaPlayer(iface);
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("%p, %s, %p.\n", iface, debugstr_guid(postype), duration);
+
+ if (!postype || !duration)
+ return E_POINTER;
+
+ EnterCriticalSection(&player->cs);
+ if (player->state == MFP_MEDIAPLAYER_STATE_SHUTDOWN)
+ hr = MF_E_SHUTDOWN;
+ else if (!player->item)
+ hr = MF_E_INVALIDREQUEST;
+ else
+ /* FIXME: use start/stop markers for resulting duration */
+ hr = IMFPMediaItem_GetDuration(player->item, postype, duration);
+ LeaveCriticalSection(&player->cs);
+
+ return hr;
}
static HRESULT WINAPI media_player_SetRate(IMFPMediaPlayer *iface, float rate)
diff --git a/dlls/mfplay/tests/mfplay.c b/dlls/mfplay/tests/mfplay.c
index f18e041a4d0..cfa689c189e 100644
--- a/dlls/mfplay/tests/mfplay.c
+++ b/dlls/mfplay/tests/mfplay.c
@@ -148,6 +148,7 @@ static void test_shutdown(void)
IMFPMediaPlayer *player;
float slowest, fastest;
IMFPMediaItem *item;
+ PROPVARIANT propvar;
COLORREF color;
HWND window;
DWORD mode;
@@ -217,6 +218,15 @@ todo_wine
hr = IMFPMediaPlayer_GetVideoWindow(player, &window);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IMFPMediaPlayer_GetDuration(player, NULL, NULL);
+ ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, NULL);
+ ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, &propvar);
+ ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
+
hr = IMFPMediaPlayer_Shutdown(player);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
@@ -345,10 +355,33 @@ todo_wine
DestroyWindow(window);
}
+static void test_duration(void)
+{
+ IMFPMediaPlayer *player;
+ PROPVARIANT propvar;
+ HRESULT hr;
+
+ hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ /* No media item. */
+ hr = IMFPMediaPlayer_GetDuration(player, NULL, NULL);
+ ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, NULL);
+ ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, &propvar);
+ ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
+
+ IMFPMediaPlayer_Release(player);
+}
+
START_TEST(mfplay)
{
test_create_player();
test_shutdown();
test_media_item();
test_video_control();
+ test_duration();
}
More information about the wine-cvs
mailing list