diff --git a/src/frame-validator.cpp b/src/frame-validator.cpp index 765c9e1304..176e3cfb25 100644 --- a/src/frame-validator.cpp +++ b/src/frame-validator.cpp @@ -9,23 +9,28 @@ namespace librealsense { void frame_validator::on_frame(rs2_frame * f) { - if (!_stopped && propagate((frame_interface*)f)) + if (!_stopped && propagate((frame_interface*)f) + && is_user_requested_frame((frame_interface*)f)) { - if(is_user_requested_frame((frame_interface*)f)) _user_callback->on_frame(f); } + else + { + // No RAII - explicit release is required + ((frame_interface*)f)->release(); + } } void frame_validator::release() {} frame_validator::frame_validator(std::shared_ptr sensor, frame_callback_ptr user_callback, stream_profiles current_requests, stream_profiles validator_requests) : - _sensor(sensor), - _user_callback(user_callback), + _stopped(false), + _validated(false), + _user_callback(user_callback), _user_requests(current_requests), _validator_requests(validator_requests), - _stopped(false), - _validated(false) + _sensor(sensor) {} frame_validator::~frame_validator() diff --git a/src/frame-validator.h b/src/frame-validator.h index e3e2ff4d16..06c506f3b0 100644 --- a/src/frame-validator.h +++ b/src/frame-validator.h @@ -35,7 +35,7 @@ namespace librealsense { public: explicit frame_validator(std::shared_ptr sensor, frame_callback_ptr user_callback, stream_profiles user_requests, stream_profiles validator_requests); - virtual ~frame_validator(); + virtual ~frame_validator() override; void on_frame(rs2_frame * f) override; void release() override;