From 4f923996603e8881b5afbcd791b1939a43eba4a4 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 25 Oct 2021 13:04:19 +0300 Subject: [PATCH] mfplay: Fix output argument handling in CreateMediaItemFromURL(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mfplay/player.c | 15 +++++++++++++-- dlls/mfplay/tests/mfplay.c | 11 +++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dlls/mfplay/player.c b/dlls/mfplay/player.c index 2ccee418b72..adb88fff053 100644 --- a/dlls/mfplay/player.c +++ b/dlls/mfplay/player.c @@ -968,8 +968,6 @@ static HRESULT media_player_create_item_from_url(struct media_player *player, IUnknown *object; HRESULT hr; - *ret = NULL; - if (FAILED(hr = create_media_item(&player->IMFPMediaPlayer_iface, user_data, &item))) return hr; @@ -981,6 +979,11 @@ static HRESULT media_player_create_item_from_url(struct media_player *player, if (sync) { + if (!ret) + return E_POINTER; + + *ret = NULL; + if (SUCCEEDED(hr = IMFSourceResolver_CreateObjectFromURL(player->resolver, url, MF_RESOLUTION_MEDIASOURCE, player->propstore, &obj_type, &object))) { @@ -1000,6 +1003,14 @@ static HRESULT media_player_create_item_from_url(struct media_player *player, } else { + if (!player->callback) + { + WARN("Asynchronous item creation is not supported without user callback.\n"); + return MF_E_INVALIDREQUEST; + } + + if (ret) *ret = NULL; + hr = IMFSourceResolver_BeginCreateObjectFromURL(player->resolver, url, MF_RESOLUTION_MEDIASOURCE, player->propstore, NULL, &player->resolver_callback, (IUnknown *)&item->IMFPMediaItem_iface); diff --git a/dlls/mfplay/tests/mfplay.c b/dlls/mfplay/tests/mfplay.c index 70fde9160c8..f18e041a4d0 100644 --- a/dlls/mfplay/tests/mfplay.c +++ b/dlls/mfplay/tests/mfplay.c @@ -226,6 +226,7 @@ todo_wine static void test_media_item(void) { IMFPMediaPlayer *player; + IMFPMediaItem *item; HRESULT hr; hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player); @@ -234,6 +235,16 @@ static void test_media_item(void) hr = IMFPMediaPlayer_SetMediaItem(player, NULL); ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + /* Async mode, no callback was specified. */ + hr = IMFPMediaPlayer_CreateMediaItemFromURL(player, L"url", FALSE, 0, &item); + ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr); + + hr = IMFPMediaPlayer_CreateMediaItemFromURL(player, L"url", FALSE, 0, NULL); + ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr); + + hr = IMFPMediaPlayer_CreateMediaItemFromURL(player, L"url", TRUE, 0, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + IMFPMediaPlayer_Release(player); }