diff --git a/common/opengl3.cpp b/common/opengl3.cpp index 6d8eeb0534..9ec2b044cf 100644 --- a/common/opengl3.cpp +++ b/common/opengl3.cpp @@ -689,7 +689,6 @@ std::string fbo::get_status() void _check_gl_error(const char *file, int line) { -#ifdef _DEBUG GLenum err (glGetError()); std::stringstream ss; @@ -718,7 +717,6 @@ void _check_gl_error(const char *file, int line) auto error = ss.str(); throw std::runtime_error(error); } -#endif } void clear_gl_errors() diff --git a/src/mf/mf-uvc.cpp b/src/mf/mf-uvc.cpp index 7d4a1966da..cf296829a2 100644 --- a/src/mf/mf-uvc.cpp +++ b/src/mf/mf-uvc.cpp @@ -46,6 +46,7 @@ The library will be compiled without the metadata support!\n") #define did_guid MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK #define DEVICE_NOT_READY_ERROR _HRESULT_TYPEDEF_(0x80070015L) +#define MF_E_SHUTDOWN_ERROR _HRESULT_TYPEDEF_(0xC00D3E85) #define MAX_PINS 5 @@ -165,14 +166,22 @@ namespace librealsense STDMETHODIMP source_reader_callback::OnReadSample(HRESULT hrStatus, DWORD dwStreamIndex, - DWORD /*dwStreamFlags*/, + DWORD dwStreamFlags, LONGLONG llTimestamp, IMFSample *sample) { auto owner = _owner.lock(); if (owner && owner->_reader) { - if (FAILED(hrStatus)) owner->_readsample_result = hrStatus; + if (FAILED(hrStatus)) + { + owner->_readsample_result = hrStatus; + if (dwStreamFlags == MF_SOURCE_READERF_ERROR) + { + owner->close_all(); + return S_OK; + } + } owner->_has_started.set(); LOG_HR(owner->_reader->ReadSample(dwStreamIndex, 0, nullptr, nullptr, nullptr, nullptr)); @@ -1064,12 +1073,7 @@ namespace librealsense } catch (...) { - for (auto& elem : _streams) - if (elem.callback) - close(elem.profile); - - _profiles.clear(); - _frame_callbacks.clear(); + close_all(); throw; } @@ -1163,5 +1167,21 @@ namespace librealsense if (!is_connected(_info)) throw std::runtime_error("Camera is no longer connected!"); } + + void wmf_uvc_device::close_all() + { + for (auto& elem : _streams) + if (elem.callback) + { + try + { + close(elem.profile); + } + catch (...) {} + } + + _profiles.clear(); + _frame_callbacks.clear(); + } } } diff --git a/src/mf/mf-uvc.h b/src/mf/mf-uvc.h index 62c12ac593..9a35e81fe7 100644 --- a/src/mf/mf-uvc.h +++ b/src/mf/mf-uvc.h @@ -111,6 +111,7 @@ namespace librealsense void stop_stream_cleanup(const stream_profile& profile, std::vector::iterator& elem); void flush(int sIndex); void check_connection() const; + void close_all(); IKsControl* get_ks_control(const extension_unit& xu) const; CComPtr create_device_attrs(); CComPtr create_reader_attrs();