fix(calls): camera opens again on Windows
- Windows reads the format list first and opens the picked format exactly (0.3 s) - the format probing loop stays as fallback; on MSMF it failed every probe and ended at 1 fps after 10 s Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -381,10 +381,34 @@ fn open_from_list(
381
381
accept_opened(&index, camera)
382
382
}
383
383
384
fn open_picked_format(
385
index: CameraIndex,
386
quality: VideoQuality,
387
) -> std::result::Result<(Camera, String), nokhwa::NokhwaError> {
388
let mut camera = Camera::new(
389
index,
390
RequestedFormat::new::<RgbAFormat>(RequestedFormatType::AbsoluteHighestFrameRate),
391
)?;
392
let formats = camera.compatible_camera_formats()?;
393
let format = pick_format(&formats, quality).ok_or_else(|| {
394
nokhwa::NokhwaError::GeneralError("no camera format at 30 fps".to_owned())
395
})?;
396
camera.set_camera_requset(RequestedFormat::new::<RgbAFormat>(
397
RequestedFormatType::Exact(format),
398
))?;
399
camera.open_stream()?;
400
Ok((camera, format_label(&format)))
401
}
402
384
403
fn open_camera(
385
404
index: CameraIndex,
386
405
quality: VideoQuality,
387
406
) -> std::result::Result<(Camera, String), nokhwa::NokhwaError> {
407
if cfg!(windows)
408
&& let Ok(opened) = open_picked_format(index.clone(), quality)
409
{
410
return Ok(opened);
411
}
388
412
// Probe the device list without committing to a slow Closest(NV12) open.
389
413
for probe in preferred_candidates(quality) {
390
414
let Ok(mut camera) = try_exact_or_closest(index.clone(), probe) else {
@@ -381,10 +381,34 @@ fn open_from_list(381
accept_opened(&index, camera)381
accept_opened(&index, camera)382
}382
}383
383
384
fn open_picked_format(385
index: CameraIndex,386
quality: VideoQuality,387
) -> std::result::Result<(Camera, String), nokhwa::NokhwaError> {388
let mut camera = Camera::new(389
index,390
RequestedFormat::new::<RgbAFormat>(RequestedFormatType::AbsoluteHighestFrameRate),391
)?;392
let formats = camera.compatible_camera_formats()?;393
let format = pick_format(&formats, quality).ok_or_else(|| {394
nokhwa::NokhwaError::GeneralError("no camera format at 30 fps".to_owned())395
})?;396
camera.set_camera_requset(RequestedFormat::new::<RgbAFormat>(397
RequestedFormatType::Exact(format),398
))?;399
camera.open_stream()?;400
Ok((camera, format_label(&format)))401
}402
384
fn open_camera(403
fn open_camera(385
index: CameraIndex,404
index: CameraIndex,386
quality: VideoQuality,405
quality: VideoQuality,387
) -> std::result::Result<(Camera, String), nokhwa::NokhwaError> {406
) -> std::result::Result<(Camera, String), nokhwa::NokhwaError> {407
if cfg!(windows)408
&& let Ok(opened) = open_picked_format(index.clone(), quality)409
{410
return Ok(opened);411
}388
// Probe the device list without committing to a slow Closest(NV12) open.412
// Probe the device list without committing to a slow Closest(NV12) open.389
for probe in preferred_candidates(quality) {413
for probe in preferred_candidates(quality) {390
let Ok(mut camera) = try_exact_or_closest(index.clone(), probe) else {414
let Ok(mut camera) = try_exact_or_closest(index.clone(), probe) else {