MCPcopy Create free account
hub / github.com/cinder/Cinder / startBusWatch

Method startBusWatch

src/cinder/CaptureImplGStreamer.cpp:1048–1096  ·  view source on GitHub ↗

Starts background thread to monitor pipeline messages. GStreamer "bus" is the message system for errors, state changes, etc.

Source from the content-addressed store, hash-verified

1046
1047// Starts background thread to monitor pipeline messages. GStreamer "bus" is the message system for errors, state changes, etc.
1048void CaptureImplGStreamer::startBusWatch()
1049{
1050 if( ! mBus || mRunBusWatch )
1051 return;
1052
1053 if( mBusWatchThread.joinable() )
1054 mBusWatchThread.join();
1055
1056 mRunBusWatch = true;
1057 mBusWatchThread = std::thread( [this]() {
1058 while( mRunBusWatch ) {
1059 GstMessage* message = gst_bus_timed_pop( mBus, GST_MSECOND * 100 );
1060 if( ! message )
1061 continue;
1062
1063 switch( GST_MESSAGE_TYPE( message ) ) {
1064 case GST_MESSAGE_ERROR:
1065 {
1066 GError* err = nullptr;
1067 gchar* dbg = nullptr;
1068 gst_message_parse_error( message, &err, &dbg );
1069 if( err && err->message )
1070 CI_LOG_E( "Capture error: " << err->message );
1071 if( dbg )
1072 CI_LOG_E( "Debug info: " << dbg );
1073
1074 // Mark as not capturing when pipeline errors occur
1075 // This handles device disconnection and other critical failures
1076 mIsCapturing = false;
1077 CI_LOG_W( "Device disconnection or pipeline failure detected - marking capture as stopped" );
1078
1079 if( err )
1080 g_error_free( err );
1081 if( dbg )
1082 g_free( dbg );
1083 mRunBusWatch = false;
1084 break;
1085 }
1086 case GST_MESSAGE_EOS:
1087 mRunBusWatch = false;
1088 break;
1089 default:
1090 break;
1091 }
1092
1093 gst_message_unref( message );
1094 }
1095 } );
1096}
1097
1098// Stops bus monitoring thread and waits for it to finish.
1099void CaptureImplGStreamer::stopBusWatch()

Callers

nothing calls this directly

Calls 2

threadClass · 0.85
joinMethod · 0.45

Tested by

no test coverage detected