Skip to content

[Windows] File is never closed #1537

@llfbandit

Description

@llfbandit

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

When player has been disposed after playing a file, the input is still open.

Expected behaviour

File closed to not leak resources and be able to manipulate it.

Steps to reproduce

  1. play an input file.
  2. dispose the player.

Code sample

No response

Affected platforms

Windows

Platform details

Windows 11

AudioPlayers Version

4.1.0

Build mode

debug, release

Audio Files/URLs/Sources

No response

Screenshots

No response

Logs

HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION) : Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus. 

Related issues / more information

As far as I can tell regarding the code, the source is not released.
As IMFMediaSource is COM object, Release() should be called before setting the pointer to a null reference.

Maybe I'm wrong on the issue location:
https://github.com/bluefireteam/audioplayers/blob/92995357c4e29d63537d66f478dca8f655e99a08/packages/audioplayers_windows/windows/MediaEngineExtension.cpp#LL104C9-L104C25

For what it's worth I use those wrappers to release COM objects:

//////////////////////////////////////////////////////////////////////////
//  COM Safe release
//////////////////////////////////////////////////////////////////////////

template <class T> void SafeRelease(T** ppT)
{
	if (*ppT)
	{
		(*ppT)->Release();
		*ppT = NULL;
	}
}

template <class T> inline void SafeRelease(T*& pT)
{
	if (pT != NULL)
	{
		pT->Release();
		pT = NULL;
	}
}

Working on PR

no way

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions