Nikolay Sivov : mfplay: Implement GetPosition().

Alexandre Julliard julliard at winehq.org
Mon Oct 25 16:30:07 CDT 2021


Module: wine
Branch: master
Commit: dd1a603a1f0447c980f41606aba5f6aa7717643e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=dd1a603a1f0447c980f41606aba5f6aa7717643e

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Oct 25 13:04:21 2021 +0300

mfplay: Implement GetPosition().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mfplay/player.c       | 40 +++++++++++++++++++++++++++++++++++++---
 dlls/mfplay/tests/mfplay.c | 24 ++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/dlls/mfplay/player.c b/dlls/mfplay/player.c
index 0e33dcbd649..a34973f8e36 100644
--- a/dlls/mfplay/player.c
+++ b/dlls/mfplay/player.c
@@ -904,9 +904,40 @@ static HRESULT WINAPI media_player_SetPosition(IMFPMediaPlayer *iface, REFGUID p
 
 static HRESULT WINAPI media_player_GetPosition(IMFPMediaPlayer *iface, REFGUID postype, PROPVARIANT *position)
 {
-    FIXME("%p, %s, %p.\n", iface, debugstr_guid(postype), position);
+    struct media_player *player = impl_from_IMFPMediaPlayer(iface);
+    IMFPresentationClock *presentation_clock;
+    IMFClock *clock;
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    TRACE("%p, %s, %p.\n", iface, debugstr_guid(postype), position);
+
+    if (!position)
+        return E_POINTER;
+
+    if (!IsEqualGUID(postype, &MFP_POSITIONTYPE_100NS))
+        return E_INVALIDARG;
+
+    EnterCriticalSection(&player->cs);
+    if (player->state == MFP_MEDIAPLAYER_STATE_SHUTDOWN)
+        hr = MF_E_SHUTDOWN;
+    else if (!player->item)
+        hr = MF_E_INVALIDREQUEST;
+    else
+    {
+        if (SUCCEEDED(hr = IMFMediaSession_GetClock(player->session, &clock)))
+        {
+            if (SUCCEEDED(hr = IMFClock_QueryInterface(clock, &IID_IMFPresentationClock, (void **)&presentation_clock)))
+            {
+                position->vt = VT_UI8;
+                hr = IMFPresentationClock_GetTime(presentation_clock, (MFTIME *)&position->uhVal.QuadPart);
+                IMFPresentationClock_Release(presentation_clock);
+            }
+            IMFClock_Release(clock);
+        }
+    }
+    LeaveCriticalSection(&player->cs);
+
+    return hr;
 }
 
 static HRESULT WINAPI media_player_GetDuration(IMFPMediaPlayer *iface, REFGUID postype, PROPVARIANT *duration)
@@ -916,9 +947,12 @@ static HRESULT WINAPI media_player_GetDuration(IMFPMediaPlayer *iface, REFGUID p
 
     TRACE("%p, %s, %p.\n", iface, debugstr_guid(postype), duration);
 
-    if (!postype || !duration)
+    if (!duration)
         return E_POINTER;
 
+    if (!IsEqualGUID(postype, &MFP_POSITIONTYPE_100NS))
+        return E_INVALIDARG;
+
     EnterCriticalSection(&player->cs);
     if (player->state == MFP_MEDIAPLAYER_STATE_SHUTDOWN)
         hr = MF_E_SHUTDOWN;
diff --git a/dlls/mfplay/tests/mfplay.c b/dlls/mfplay/tests/mfplay.c
index cfa689c189e..1daaa3af1d5 100644
--- a/dlls/mfplay/tests/mfplay.c
+++ b/dlls/mfplay/tests/mfplay.c
@@ -227,6 +227,15 @@ todo_wine
     hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, &propvar);
     ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
 
+    hr = IMFPMediaPlayer_GetPosition(player, NULL, NULL);
+    ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+    hr = IMFPMediaPlayer_GetPosition(player, &MFP_POSITIONTYPE_100NS, NULL);
+    ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+    hr = IMFPMediaPlayer_GetPosition(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);
 
@@ -371,9 +380,24 @@ static void test_duration(void)
     hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, NULL);
     ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
 
+    hr = IMFPMediaPlayer_GetDuration(player, &IID_IUnknown, &propvar);
+    ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
     hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, &propvar);
     ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
 
+    hr = IMFPMediaPlayer_GetPosition(player, NULL, NULL);
+    ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+    hr = IMFPMediaPlayer_GetPosition(player, &MFP_POSITIONTYPE_100NS, NULL);
+    ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+    hr = IMFPMediaPlayer_GetPosition(player, &IID_IUnknown, &propvar);
+    ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+    hr = IMFPMediaPlayer_GetPosition(player, &MFP_POSITIONTYPE_100NS, &propvar);
+    ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
+
     IMFPMediaPlayer_Release(player);
 }
 




More information about the wine-cvs mailing list