mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-05-19 13:56:06 -04:00
mac-avcapture: Use fallback frame rate by default for new devices
When a new device is selected, a best-possible frame rate is chosen for the initial configuration of the device. This has to be set in the source settings, as those are the "source of truth" for the properties and the device configuration. The object has to be created explicitly first before setting the frame rate value. The source then has to be updated explicitly as well to ensure that the change will be picked up by the next iteration of the render thread to "tick" the source and thus make it configure a capture session with the fallback framerate set.
This commit is contained in:
@@ -417,6 +417,23 @@ static const UInt32 kMaxFrameRateRangesInDescription = 10;
|
||||
OBSAVCaptureMediaFPS fps;
|
||||
if (!obs_data_get_frames_per_second(self.captureInfo->settings, "frame_rate", &fps, NULL)) {
|
||||
[self AVCaptureLog:LOG_DEBUG withFormat:@"No valid framerate found in settings"];
|
||||
|
||||
AVCaptureDeviceFormat *lastFormat = [self.deviceInput.device.formats lastObject];
|
||||
|
||||
fps = [OBSAVCapture fallbackFrameRateForFormat:lastFormat];
|
||||
|
||||
if (lastFormat.videoSupportedFrameRateRanges.count == 0) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
obs_data_set_obj(self.captureInfo->settings, "frame_rate", NULL);
|
||||
|
||||
obs_data_item_t *frameRateSetting = obs_data_item_byname(self.captureInfo->settings, "frame_rate");
|
||||
|
||||
obs_data_item_set_frames_per_second(&frameRateSetting, fps, NULL);
|
||||
|
||||
obs_source_update(self.captureInfo->source, self.captureInfo->settings);
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user