1
This commit is contained in:
parent
4a2b6f94d4
commit
465d87ce0a
10
src/main.cpp
10
src/main.cpp
@ -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 线程等待的截止时间
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user