mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Fix FPS setting and crash in reapplying settings.
This commit is contained in:
@@ -88,8 +88,9 @@ llvm::ArrayRef<int> SourceImpl::EnumerateProperties(
|
||||
if (!m_properties_cached && !CacheProperties(status))
|
||||
return llvm::ArrayRef<int>{};
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
for (int i = 0; i < static_cast<int>(m_propertyData.size()); ++i)
|
||||
vec.push_back(i + 1);
|
||||
for (int i = 0; i < static_cast<int>(m_propertyData.size()); ++i) {
|
||||
if (m_propertyData[i]) vec.push_back(i + 1);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
||||
@@ -636,7 +636,7 @@ void USBCameraImpl::DeviceConnect() {
|
||||
std::unique_lock<std::mutex> lock2(m_mutex);
|
||||
for (std::size_t i = 0; i < m_propertyData.size(); ++i) {
|
||||
const auto& prop = m_propertyData[i];
|
||||
if (!prop->valueSet) continue;
|
||||
if (!prop || !prop->valueSet) continue;
|
||||
if (!DeviceSetProperty(lock2, static_cast<const PropertyData&>(*prop)))
|
||||
WARNING("USB " << m_path << ": failed to set property " << prop->name);
|
||||
}
|
||||
@@ -786,7 +786,11 @@ void USBCameraImpl::DeviceProcessCommands() {
|
||||
} else if (newMode.fps != m_mode.fps) {
|
||||
m_mode = newMode;
|
||||
lock.unlock();
|
||||
// Need to stop streaming to set FPS
|
||||
bool wasStreaming = m_streaming;
|
||||
if (wasStreaming) DeviceStreamOff();
|
||||
DeviceSetFPS();
|
||||
if (wasStreaming) DeviceStreamOn();
|
||||
Notifier::GetInstance().NotifySource(*this,
|
||||
CS_SOURCE_VIDEOMODE_CHANGED);
|
||||
lock.lock();
|
||||
|
||||
Reference in New Issue
Block a user