Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catching the shutdown error, and closing resources #8775

Merged
merged 2 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions common/opengl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down
36 changes: 28 additions & 8 deletions src/mf/mf-uvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}
}
}
1 change: 1 addition & 0 deletions src/mf/mf-uvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace librealsense
void stop_stream_cleanup(const stream_profile& profile, std::vector<profile_and_callback>::iterator& elem);
void flush(int sIndex);
void check_connection() const;
void close_all();
IKsControl* get_ks_control(const extension_unit& xu) const;
CComPtr<IMFAttributes> create_device_attrs();
CComPtr<IMFAttributes> create_reader_attrs();
Expand Down