mfplay: Shutdown sources when media items are released.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2022-02-16 11:53:53 +03:00 committed by Alexandre Julliard
parent decfb2b2ab
commit 3e4f4c020a
1 changed files with 16 additions and 2 deletions

View File

@ -61,6 +61,11 @@ static inline const char *debugstr_normalized_rect(const MFVideoNormalizedRect *
struct media_player; struct media_player;
enum media_item_flags
{
MEDIA_ITEM_SOURCE_NEEDS_SHUTDOWN = 0x1,
};
struct media_item struct media_item
{ {
IMFPMediaItem IMFPMediaItem_iface; IMFPMediaItem IMFPMediaItem_iface;
@ -73,6 +78,7 @@ struct media_item
IUnknown *object; IUnknown *object;
LONGLONG start_position; LONGLONG start_position;
LONGLONG stop_position; LONGLONG stop_position;
unsigned int flags;
}; };
struct media_player struct media_player
@ -359,7 +365,11 @@ static ULONG WINAPI media_item_Release(IMFPMediaItem *iface)
if (item->player) if (item->player)
IMFPMediaPlayer_Release(&item->player->IMFPMediaPlayer_iface); IMFPMediaPlayer_Release(&item->player->IMFPMediaPlayer_iface);
if (item->source) if (item->source)
{
if (item->flags & MEDIA_ITEM_SOURCE_NEEDS_SHUTDOWN)
IMFMediaSource_Shutdown(item->source);
IMFMediaSource_Release(item->source); IMFMediaSource_Release(item->source);
}
if (item->pd) if (item->pd)
IMFPresentationDescriptor_Release(item->pd); IMFPresentationDescriptor_Release(item->pd);
if (item->object) if (item->object)
@ -1189,6 +1199,7 @@ static HRESULT media_player_create_item_from_url(struct media_player *player,
IMFPMediaItem_Release(&item->IMFPMediaItem_iface); IMFPMediaItem_Release(&item->IMFPMediaItem_iface);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
item->flags |= MEDIA_ITEM_SOURCE_NEEDS_SHUTDOWN;
if (sync) if (sync)
{ {
@ -1244,11 +1255,11 @@ static HRESULT WINAPI media_player_CreateMediaItemFromURL(IMFPMediaPlayer *iface
static HRESULT media_player_create_item_from_object(struct media_player *player, static HRESULT media_player_create_item_from_object(struct media_player *player,
IUnknown *object, BOOL sync, DWORD_PTR user_data, IMFPMediaItem **ret) IUnknown *object, BOOL sync, DWORD_PTR user_data, IMFPMediaItem **ret)
{ {
IMFMediaSource *source = NULL;
IMFByteStream *stream = NULL;
struct media_item *item; struct media_item *item;
MF_OBJECT_TYPE obj_type; MF_OBJECT_TYPE obj_type;
HRESULT hr; HRESULT hr;
IMFByteStream *stream = NULL;
IMFMediaSource *source = NULL;
*ret = NULL; *ret = NULL;
@ -1268,6 +1279,9 @@ static HRESULT media_player_create_item_from_object(struct media_player *player,
return E_UNEXPECTED; return E_UNEXPECTED;
} }
if (source)
item->flags |= MEDIA_ITEM_SOURCE_NEEDS_SHUTDOWN;
if (sync) if (sync)
{ {
if (stream) if (stream)