mfplay: Handle shutdown state in CreateMediaItemFromURL().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-04-13 09:03:31 +03:00 committed by Alexandre Julliard
parent 71d532249b
commit 58d0cb0de0
2 changed files with 78 additions and 6 deletions

View File

@ -806,18 +806,17 @@ static HRESULT WINAPI media_player_GetState(IMFPMediaPlayer *iface, MFP_MEDIAPLA
return S_OK; return S_OK;
} }
static HRESULT WINAPI media_player_CreateMediaItemFromURL(IMFPMediaPlayer *iface, static HRESULT media_player_create_item_from_url(struct media_player *player,
const WCHAR *url, BOOL sync, DWORD_PTR user_data, IMFPMediaItem **ret) const WCHAR *url, BOOL sync, DWORD_PTR user_data, IMFPMediaItem **ret)
{ {
struct media_player *player = impl_from_IMFPMediaPlayer(iface);
struct media_item *item; struct media_item *item;
MF_OBJECT_TYPE obj_type; MF_OBJECT_TYPE obj_type;
IUnknown *object; IUnknown *object;
HRESULT hr; HRESULT hr;
TRACE("%p, %s, %d, %lx, %p.\n", iface, debugstr_w(url), sync, user_data, ret); *ret = NULL;
if (FAILED(hr = create_media_item(iface, user_data, &item))) if (FAILED(hr = create_media_item(&player->IMFPMediaPlayer_iface, user_data, &item)))
return hr; return hr;
if (url && !(item->url = wcsdup(url))) if (url && !(item->url = wcsdup(url)))
@ -828,8 +827,6 @@ static HRESULT WINAPI media_player_CreateMediaItemFromURL(IMFPMediaPlayer *iface
if (sync) if (sync)
{ {
*ret = NULL;
if (SUCCEEDED(hr = IMFSourceResolver_CreateObjectFromURL(player->resolver, url, MF_RESOLUTION_MEDIASOURCE, if (SUCCEEDED(hr = IMFSourceResolver_CreateObjectFromURL(player->resolver, url, MF_RESOLUTION_MEDIASOURCE,
player->propstore, &obj_type, &object))) player->propstore, &obj_type, &object)))
{ {
@ -853,6 +850,24 @@ static HRESULT WINAPI media_player_CreateMediaItemFromURL(IMFPMediaPlayer *iface
return hr; return hr;
} }
static HRESULT WINAPI media_player_CreateMediaItemFromURL(IMFPMediaPlayer *iface,
const WCHAR *url, BOOL sync, DWORD_PTR user_data, IMFPMediaItem **ret)
{
struct media_player *player = impl_from_IMFPMediaPlayer(iface);
HRESULT hr;
TRACE("%p, %s, %d, %lx, %p.\n", iface, debugstr_w(url), sync, user_data, ret);
EnterCriticalSection(&player->cs);
if (player->state == MFP_MEDIAPLAYER_STATE_SHUTDOWN)
hr = MF_E_SHUTDOWN;
else
hr = media_player_create_item_from_url(player, url, sync, user_data, ret);
LeaveCriticalSection(&player->cs);
return hr;
}
static HRESULT WINAPI media_player_CreateMediaItemFromObject(IMFPMediaPlayer *iface, static HRESULT WINAPI media_player_CreateMediaItemFromObject(IMFPMediaPlayer *iface,
IUnknown *object, BOOL sync, DWORD_PTR user_data, IMFPMediaItem **item) IUnknown *object, BOOL sync, DWORD_PTR user_data, IMFPMediaItem **item)
{ {

View File

@ -23,6 +23,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "mfplay.h" #include "mfplay.h"
#include "mferror.h"
#include "wine/test.h" #include "wine/test.h"
@ -119,7 +120,63 @@ static void test_create_player(void)
IMFPMediaPlayer_Release(player); IMFPMediaPlayer_Release(player);
} }
static void test_shutdown(void)
{
IMFPMediaPlayer *player;
float slowest, fastest;
HRESULT hr;
MFP_MEDIAPLAYER_STATE state;
IMFPMediaItem *item;
HWND window;
hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetState(player, &state);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(state == MFP_MEDIAPLAYER_STATE_EMPTY, "Unexpected state %d.\n", state);
hr = IMFPMediaPlayer_Shutdown(player);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
/* Check methods in shutdown state. */
hr = IMFPMediaPlayer_Play(player);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_Pause(player);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_Stop(player);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetSupportedRates(player, TRUE, &slowest, &fastest);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetState(player, &state);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(state == MFP_MEDIAPLAYER_STATE_SHUTDOWN, "Unexpected state %d.\n", state);
hr = IMFPMediaPlayer_CreateMediaItemFromURL(player, L"url", TRUE, 0, &item);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_ClearMediaItem(player);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetMediaItem(player, &item);
todo_wine
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetVideoWindow(player, &window);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_Shutdown(player);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IMFPMediaPlayer_Release(player);
}
START_TEST(mfplay) START_TEST(mfplay)
{ {
test_create_player(); test_create_player();
test_shutdown();
} }