Share via

IMFSourceReader::ReadSample hangs randomly on ARM64

Ianier Munoz 5 Reputation points
2024-02-25T14:14:17.4133333+00:00

IMFSourceReader::ReadSample hangs randomly on ARM64. This happens very infrequently, but can be easily reproduced with the code below (be patient and let it run for a while). On x64 it seems to work fine, so you really need to compile it for ARM64 and run it on WOA hardware. The issue occurs with any .mp3 or .mp4 media file I have tried.

#include <iostream>

#include <mfapi.h>
#include <mftransform.h>
#include <mfidl.h>
#include <mferror.h>
#include <Mfreadwrite.h>

#include <wrl/client.h>
using namespace Microsoft::WRL;

#pragma comment(lib, "mfreadwrite")
#pragma comment(lib, "mf")
#pragma comment(lib, "mfplat")
#pragma comment(lib, "mfuuid")

void ReadAllSamples(LPCWSTR path)
{
	ComPtr<IMFSourceReader> reader;
	HRESULT hr = MFCreateSourceReaderFromURL(path, nullptr, reader.GetAddressOf());

	ComPtr<IMFMediaType> partialType;
	MFCreateMediaType(partialType.GetAddressOf());
	partialType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);
	partialType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM);
	hr = reader->SetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, nullptr, partialType.Get());

	bool done = false;
	for (int s = 0; !done; s++)
	{
		ComPtr<IMFSample> sample;
		DWORD flags = 0;
		LONGLONG timestamp = 0;
		hr = reader->ReadSample(MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, nullptr, &flags, &timestamp, sample.GetAddressOf());
		if (FAILED(hr) || ((flags & MF_SOURCE_READERF_ENDOFSTREAM) != 0))
			done = true;
		sample.Reset();

		std::cout << s << "\n";
	}
}

int main()
{
	HRESULT hr = MFStartup(0);

	while (true)
	{
		ReadAllSamples(L"aniversario.mp3");
	}
}


Windows development | Windows API - Win32
0 comments No comments

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,736 Reputation points Microsoft External Staff
    2024-02-26T02:05:42.5233333+00:00

    Hello @Ianier Munoz, If the issue has a big impact to you and you are seeking any workaround, you can open an incident at https://developer.microsoft.com/en-us/windows/support/?tabs=Contact-us so that our engineer can work with you closely and please choose the 'Graphics and Multimedia development - Media Foundation API' for Windows SDK for this issue. In-addition, if the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged.

    I have submitted new feedback https://aka.ms/AApb524.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.