I am having a problem on windows 10 (not an issue on server 2016) where IMFSourceReader->ReadSample (reader->ReadSample in the code below) will never return if the device was unplugged during capture. This causes errors to not be raised when a device is unplugged during capture. Everything works fine if no device is unplugged. I would expect something like MF_E_INVALIDREQUEST to be returned but instead it just hangs forever. Any thoughts on what might be the issue or guidance would be highly appreciated.
capture::Sample *capture::MfDeviceSampleProvider::GetNextSample(bool video) {
Sample *sample = NULL;
IMFSample *mfSample = NULL;
DWORD streamFlags;
if (reader) {
HRESULT hr = reader->ReadSample(streamIndex, 0, NULL, &streamFlags, NULL, &mfSample);
LOG_IF_FAILED(hr, "Unable to read sample from device.");
if (SUCCEEDED(hr)) {
if (streamFlags == 0) {
if (type == DeviceBase::Type::Video) {
sample = new MFVideoSample(prop.type, mfSample, prop.size.width, prop.size.height);
} else if (type == DeviceBase::Type::Audio) {
sample = new MFAudioSample(mfSample);
}
} else if (streamFlags & MF_SOURCE_READERF_STREAMTICK) {
return GetNextSample(video);
}
}
SafeRelease(&mfSample);
return sample;
}
`