fix(camera): keep streaming active during recording

This commit is contained in:
linbo 2026-08-12 15:46:55 +08:00
parent ffd89c27c4
commit 2596a82c2c

View File

@ -1178,10 +1178,22 @@ bool UVCCamera::startStreaming()
stream_thread_.reset();
}
}
// A recording session may already own the encoder worker. The streaming
// state still has to reflect the new client lease so stopping recording
// does not terminate the worker while clients are consuming frames.
state_.is_streaming = true;
//开启流采集线程
if (!stream_thread_) {
state_.is_streaming = true;
try {
stream_thread_ = make_shared<thread>(&UVCCamera::streaming_worker_, this);
} catch (const std::exception& e) {
state_.is_streaming = stream_count_ > 0;
state_.is_error = true;
state_.error_message = "failed to start streaming worker: " + std::string(e.what());
CMVR_LOG(ERROR) << "[UVCCamera] (startStreaming): " << state_.error_message;
return false;
}
//延时100ms,等待流线程获取图像
std::this_thread::sleep_for(std::chrono::milliseconds(100));