Skip to content

Fix formats-converter bug - #12029

Merged
Nir-Az merged 2 commits into
realsenseai:developmentfrom
OhadMeir:development
Jul 25, 2023
Merged

Fix formats-converter bug #12029
Nir-Az merged 2 commits into
realsenseai:developmentfrom
OhadMeir:development

Conversation

@OhadMeir

Copy link
Copy Markdown
Contributor

The bug happened when more than one raw profile have mapped to the same converted profile.
Saved shared_ptr object in map instead of actual profile values. Different shared_ptr objects did not map as the same key even when pointing to profiles of same values.

Comment thread src/proc/formats-converter.cpp Outdated

if( profile )
{
res += std::string( "(" ) + rs2_stream_to_string( profile->get_stream_type() ) + std::string( ")" );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be cleaner to just use ostringstream instead of all the std::string conversions? Or even an operator<<?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to operator<<

@OhadMeir
OhadMeir marked this pull request as ready for review July 25, 2023 07:14
}

std::string to_string( std::shared_ptr< stream_profile_interface > profile )
std::ostream & operator<<( std::ostream & os, const std::shared_ptr< stream_profile_interface > & profile )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you please add the required include on top?
So we will not be depending on other headers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added

}
}

std::ostream & operator<<( std::ostream & os, const std::shared_ptr< stream_profile_interface > & profile )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a very useful function and we keep re-implementing it in one way or another all over the place.
I suggest it be placed in a central place and not just here.
src/core/streaming.h is where stream_profile_interface is defined, I suggest the signature there and the body in a .cpp somwhere.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

p.s. we have to choose whether the syntax would be:
... << stm_ptr;
or
... << *stm_ptr;
I.e., do we pass the (SMART) POINTER to the stream interface, or a reference to it? I think we're not always going to have a smart ptr. I vote for a reference, if possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A reference will be problematic since it is an abstract class. Maybe we can pass a raw pointer but I don't think that we use it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A general operator for stream_profile_interface is implemented here. It does not print all the details I wanted so I added specifically here. Do you think we need it also elsewhere? No other implementations/uses that I was able to find.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A reference will be problematic since it is an abstract class. Maybe we can pass a raw pointer but I don't think that we use it.

A ref is just syntax, it doesn't mean anything. You can take its address, compare it to null, etc., same as any pointer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A general operator for stream_profile_interface is implemented here.

That's for stream_profiles. I vote for yours, and change that one to use it.

@Nir-Az

Nir-Az commented Jul 25, 2023

Copy link
Copy Markdown
Collaborator

We are waiting for this fix in several other branches, we cannot merge D457 changes for ADL-P safely
Let's first merge the fix, see we are back to safe and then think about the enhancement

@Nir-Az

Nir-Az commented Jul 25, 2023

Copy link
Copy Markdown
Collaborator

We are waiting for this fix in several other branches, we cannot merge D457 changes for ADL-P safely Let's first merge the fix, see we are back to safe and then think about the enhancement

@maloel note that we are blind in GHA DDS tests, we will not rerun until it will pass..

@maloel

maloel commented Jul 25, 2023

Copy link
Copy Markdown
Contributor

We are waiting for this fix in several other branches, we cannot merge D457 changes for ADL-P safely Let's first merge the fix, see we are back to safe and then think about the enhancement

¯\_(ツ)_/¯

I'm just commenting on something minor, up to you...

@Nir-Az
Nir-Az merged commit ab5dfbe into realsenseai:development Jul 25, 2023
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.

3 participants