I've just spent the all day trying to find a solution regarding that problem, let me explain a bit:
I am developing a video tool on Windows using Visual 2013, Qt, OpenGL and Media Foundation in c++. I've got a IMFSourceReader that is grabbing video frame that I treat and display using openGL inside a QWindow.
Now I want to play the audio stream of the video file. I know how to grab a audio sample (using the same source reader). I also know how to enumerate all my audio devices:
IMMDeviceEnumerator *pEnum = NULL; // Audio device enumerator.
IMMDeviceCollection *pDevices = NULL; // Audio device collection.
IMMDevice *pDevice = NULL; // An audio device.
IMFAttributes *pAttributes = NULL; // Attribute store.
IMFMediaSink *pSink = NULL; // Streaming audio renderer (SAR)
LPWSTR wstrID = NULL; // Device ID.
// Create the device enumerator.
hr = CoCreateInstance(
__uuidof(MMDeviceEnumerator),
NULL,
CLSCTX_ALL,
__uuidof(IMMDeviceEnumerator),
(void**)&pEnum
);
// Enumerate the rendering devices.
if (SUCCEEDED(hr))
{
hr = pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pDevices);
}
// Get ID of the first device in the list.
if (SUCCEEDED(hr))
{
hr = pDevices->Item(0, &pDevice);
}
if (SUCCEEDED(hr))
{
hr = pDevice->GetId(&wstrID);
}
// Create an attribute store and set the device ID attribute.
if (SUCCEEDED(hr))
{
hr = MFCreateAttributes(&pAttributes, 2);
}
if (SUCCEEDED(hr))
{
hr = pAttributes->SetString(
MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID,
wstrID
);
}
// Create the audio renderer.
if (SUCCEEDED(hr))
{
hr = MFCreateAudioRenderer(pAttributes, &pSink);
}
SAFE_RELEASE(pEnum);
SAFE_RELEASE(pDevices);
SAFE_RELEASE(pDevice);
SAFE_RELEASE(pAttributes);
CoTaskMemFree(wstrID);
}
I think I have to go with a Streaming Audio Renderer but that is all. I can't find any thing on the web, I even went on the 11th page of a Google search...
You are my only hope SO...