Skip to content

[RSDK-13311] - Simplify gstreamer state#37

Merged
seanavery merged 6 commits intoviam-modules:mainfrom
seanavery:RSDK-13311
Feb 12, 2026
Merged

[RSDK-13311] - Simplify gstreamer state#37
seanavery merged 6 commits intoviam-modules:mainfrom
seanavery:RSDK-13311

Conversation

@seanavery
Copy link
Collaborator

@seanavery seanavery commented Feb 2, 2026

Description

Simple PR to reduce the amount of state in the core CSICamera class.

Tests

  • build ✅
  • unit tests ✅
  • manual test on Pi5 ✅

Reviews

small change, 1 approval

csi_camera.cpp Outdated
GstMessage* msg = gst_bus_pop(bus);
if (msg != nullptr) {
catch_pipeline();
catch_pipeline(msg);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can catch_pipeline throw an exception? If it does we will leak memory here since gst_message_unref below wouldn't be called.

Copy link

@SebastianMunozP SebastianMunozP Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] You cold create a RAII msg wrapper class that takes care of this, so that it its destructor the gst_message_unref function is called. But really up to you if the added complexity makes sense here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call out, added try/catch that handles unref. Went with try/catch over an RAII wrapper since there's only one call site, didn't feel worth adding a new class for it.


std::vector<unsigned char> CSICamera::buff_to_vec(GstBuffer* buff) {
if (buff == nullptr) {
throw Exception("Cannot convert null buffer to vector");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would std::runtime_error be more appropriate than a bare Exception?

Copy link
Collaborator Author

@seanavery seanavery Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure, I have been using the utility from viam/sdk/common/exception.hpp so the SDK wrapper can bubble up as a gRPC error message. Why should we consider std::runtime_error here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh just a best practice callout. In general, the more precise we can be with the error type, the easier it is to debug. But I think if it bubbles up as a gRPC error in RDK logs, then it's optional

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok gotcha, this code path is hit from Images so we get the err msg out through the gRPC call.

@seanavery seanavery merged commit 7e214d5 into viam-modules:main Feb 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants