This commit is contained in:
cxh 2025-11-20 11:06:02 +08:00
parent 4a2b6f94d4
commit 465d87ce0a
2 changed files with 13 additions and 11 deletions

View File

@ -100,16 +100,12 @@ int main()
if (ENABLE_RTSP_THREAD)
{
RTSPManager::stop();
auto stop_deadline = std::chrono::steady_clock::now() + std::chrono::seconds(10);
while (RTSPManager::is_any_streaming() && std::chrono::steady_clock::now() < stop_deadline)
{
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
RTSPManager::stop(); // 只负责让 g_main_loop_run 跳出
if (rtsp_thread.joinable())
rtsp_thread.join();
LOG_INFO("[MAIN] RTSP thread finished and joined.");
}
// 重置 MQTT 线程等待的截止时间

View File

@ -283,10 +283,16 @@ void RTSPManager::stop()
// 退出 main loop
if (loop)
{
g_main_context_invoke(main_context, [](gpointer data) -> gboolean
{
g_main_loop_quit(static_cast<GMainLoop *>(data));
return G_SOURCE_REMOVE; }, loop);
g_main_context_invoke(
main_context,
[](gpointer data) -> gboolean
{
GMainLoop *lp = static_cast<GMainLoop *>(data);
if (lp)
g_main_loop_quit(lp);
return G_SOURCE_REMOVE;
},
loop);
}
}