amerkoleci/Vortice.Windows

Help needed, to play a mp3 file with Vortice.XAudio2

shellohunter opened this issue · 0 comments

I spent another day trying to play a mp3 file with Vortice.XAudio2, no luck yet.

Here's my source code: https://gist.github.com/shellohunter/8158a170b479f17b0d93cf57eacb533e

It uses Vortice.MediaFoundation as the decoder, then submits decoded data to XAudio2.
I picked up some code from: https://github.com/walbourn/directx-sdk-samples/tree/main/XAudio2/XAudio2MFStream
which is written in cpp. There's a lot of macros I cannot find in vortice, so I have to made it myself.

AFAK, I should call SetCurrentMediaType on IMFSourceReader to specify the audio format I needed. the reader will load corresponding decoder internally, and give me the expected pcm stream. then I can submit pcm data to Xaudio2.

I haven't go far yet, since the program always went wrong at this line:

IMFMediaType expectedType = MFCreateMediaType(); // SOMETHING WENT WRONG HERE !!!!!!!!

Vortice.MediaFoundation.MediaFactory.MFCreateMediaType throws SharpGen.Runtime.SharpGenException

These API are mystery for me. I've no idea how to debug. I googled around, and found barely nothing helpful. :-(