Skip to content

Commit

Permalink
Second try
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Dec 31, 2024
1 parent 34c1323 commit 9ba5369
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/dds/rs-dds-sensor-proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ void dds_sensor_proxy::start( rs2_frame_callback_sptr callback )
add_frame_metadata( static_cast< frame * >( fh.get() ), *md, streaming );
LOG_INFO( dds_stream->name() << " calling invoke_new_frame, last frame number " << streaming.last_frame_number );
invoke_new_frame( static_cast< frame * >( fh.release() ), nullptr, nullptr );
LOG_INFO( dds_stream->name() << "invoke_new_frame returned, last frame number " << streaming.last_frame_number );
LOG_INFO( dds_stream->name() << " invoke_new_frame returned, last frame number " << streaming.last_frame_number );
}
} );
streaming.syncer.start();
Expand Down Expand Up @@ -537,8 +537,6 @@ void dds_sensor_proxy::start( rs2_frame_callback_sptr callback )

void dds_sensor_proxy::stop()
{
_is_streaming = false; // Don't handle new frames

for( auto & profile : sensor_base::get_active_streams() )
{
auto streamit = _streams.find( sid_index( profile->get_unique_id(), profile->get_stream_index() ) );
Expand Down
4 changes: 3 additions & 1 deletion third-party/realdds/include/realdds/dds-metadata-syncer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <memory>
#include <mutex>
#include <functional>
#include <atomic>


namespace realdds {
Expand Down Expand Up @@ -83,7 +84,7 @@ class dds_metadata_syncer
void enqueue_metadata( key_type, metadata_type const & );

void on_frame_release( on_frame_release_callback cb ) { _on_frame_release = cb; }
void on_frame_ready( on_frame_ready_callback cb ) { _on_frame_ready = cb; }
void on_frame_ready( on_frame_ready_callback cb );
void on_metadata_dropped( on_metadata_dropped_callback cb ) { _on_metadata_dropped = cb; }

// Helper to create frame_holder
Expand All @@ -104,6 +105,7 @@ class dds_metadata_syncer
bool drop_metadata( std::unique_lock< std::mutex > & );

std::atomic< bool > _started;
std::mutex _frame_ready_mutex;
};


Expand Down
11 changes: 9 additions & 2 deletions third-party/realdds/src/dds-metadata-syncer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ void dds_metadata_syncer::enqueue_metadata( key_type id, metadata_type const & m
search_for_match( lock );
}

void dds_metadata_syncer::on_frame_ready( on_frame_ready_callback cb )
{
std::lock_guard< std::mutex > lock( _frame_ready_mutex );
_on_frame_ready = cb;
}

void dds_metadata_syncer::search_for_match( std::unique_lock< std::mutex > & lock )
{
Expand Down Expand Up @@ -122,7 +127,8 @@ bool dds_metadata_syncer::handle_match( std::unique_lock< std::mutex > & lock )
_metadata_queue.pop_front();
_frame_queue.pop_front();

if( _on_frame_ready && _started)
std::lock_guard< std::mutex > lock( _frame_ready_mutex );
if( _on_frame_ready )
{
LOG_INFO( "dds_metadata_syncer::handle_match opening lock" );
lock.unlock();
Expand Down Expand Up @@ -150,7 +156,8 @@ bool dds_metadata_syncer::handle_frame_without_metadata( std::unique_lock< std::
frame_holder fh = std::move( _frame_queue.front().second );
_frame_queue.pop_front();

if( _on_frame_ready && _started )
std::lock_guard< std::mutex > lock( _frame_ready_mutex );
if( _on_frame_ready )
{
LOG_INFO( "dds_metadata_syncer::handle_frame_without_metadata opening lock" );
lock.unlock();
Expand Down

0 comments on commit 9ba5369

Please sign in to comment.