Commit 58d0cb0d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplay: Handle shutdown state in CreateMediaItemFromURL().

parent 71d53224
......@@ -806,18 +806,17 @@ static HRESULT WINAPI media_player_GetState(IMFPMediaPlayer *iface, MFP_MEDIAPLA
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)
{
struct media_player *player = impl_from_IMFPMediaPlayer(iface);
struct media_item *item;
MF_OBJECT_TYPE obj_type;
IUnknown *object;
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;
if (url && !(item->url = wcsdup(url)))
......@@ -828,8 +827,6 @@ static HRESULT WINAPI media_player_CreateMediaItemFromURL(IMFPMediaPlayer *iface
if (sync)
{
*ret = NULL;
if (SUCCEEDED(hr = IMFSourceResolver_CreateObjectFromURL(player->resolver, url, MF_RESOLUTION_MEDIASOURCE,
player->propstore, &obj_type, &object)))
{
......@@ -853,6 +850,24 @@ static HRESULT WINAPI media_player_CreateMediaItemFromURL(IMFPMediaPlayer *iface
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,
IUnknown *object, BOOL sync, DWORD_PTR user_data, IMFPMediaItem **item)
{
......
......@@ -23,6 +23,7 @@
#include "windef.h"
#include "winbase.h"
#include "mfplay.h"
#include "mferror.h"
#include "wine/test.h"
......@@ -119,7 +120,63 @@ static void test_create_player(void)
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)
{
test_create_player();
test_shutdown();
}
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