Skip to content

Commit

Permalink
revert reordering lockDevice with beginConfigurationForSession
Browse files Browse the repository at this point in the history
  • Loading branch information
misos1 committed Sep 5, 2024
1 parent 5e1f249 commit 8de5b00
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import <OCMock/OCMock.h>
#import "CameraTestUtils.h"

static const FCPPlatformResolutionPreset gTestResolutionPreset = FCPPlatformResolutionPresetMedium;
static const FCPPlatformResolutionPreset gTestResolutionPreset = FCPPlatformResolutionPresetMediumFCPPlatformResolutionPresetMedium;
static const int gTestFramesPerSecond = 15;
static const int gTestVideoBitrate = 200000;
static const int gTestAudioBitrate = 32000;
Expand Down Expand Up @@ -148,9 +148,9 @@ - (void)testSettings_shouldPassConfigurationToCameraDeviceAndWriter {

// Expect FPS configuration is passed to camera device.
[self waitForExpectations:@[
injectedWrapper.beginConfigurationExpectation, injectedWrapper.lockExpectation,
injectedWrapper.lockExpectation, injectedWrapper.beginConfigurationExpectation,
injectedWrapper.minFrameDurationExpectation, injectedWrapper.maxFrameDurationExpectation,
injectedWrapper.unlockExpectation, injectedWrapper.commitConfigurationExpectation
injectedWrapper.commitConfigurationExpectation, injectedWrapper.unlockExpectation
]
timeout:1
enforceOrder:YES];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,21 @@ - (instancetype)initWithMediaSettings:(FCPPlatformMediaSettings *)mediaSettings
[_motionManager startAccelerometerUpdates];

if (_mediaSettings.framesPerSecond) {
[_mediaSettingsAVWrapper beginConfigurationForSession:_videoCaptureSession];

// Possible values for presets are hard-coded in FLT interface having
// corresponding AVCaptureSessionPreset counterparts.
// If _resolutionPreset is not supported by camera there is
// fallback to lower resolution presets.
// If none can be selected there is error condition.
if (![self setCaptureSessionPreset:_mediaSettings.resolutionPreset withError:error]) {
[_videoCaptureSession commitConfiguration];
return nil;
}

// The frame rate can be changed only on a locked for configuration device.
if ([mediaSettingsAVWrapper lockDevice:_captureDevice error:error]) {
[_mediaSettingsAVWrapper beginConfigurationForSession:_videoCaptureSession];

// Possible values for presets are hard-coded in FLT interface having
// corresponding AVCaptureSessionPreset counterparts.
// If _resolutionPreset is not supported by camera there is
// fallback to lower resolution presets.
// If none can be selected there is error condition.
if (![self setCaptureSessionPreset:_mediaSettings.resolutionPreset withError:error]) {
[_videoCaptureSession commitConfiguration];
[_captureDevice unlockForConfiguration];
return nil;
}

selectBestFormatForRequestedFrameRate(_captureDevice, _mediaSettings, videoDimensionsForFormat);

// Set frame rate with 1/10 precision allowing not integral values.
Expand All @@ -234,11 +235,8 @@ - (instancetype)initWithMediaSettings:(FCPPlatformMediaSettings *)mediaSettings
[mediaSettingsAVWrapper setMinFrameDuration:duration onDevice:_captureDevice];
[mediaSettingsAVWrapper setMaxFrameDuration:duration onDevice:_captureDevice];

[_mediaSettingsAVWrapper unlockDevice:_captureDevice];
[_mediaSettingsAVWrapper commitConfigurationForSession:_videoCaptureSession];
} else {
[_mediaSettingsAVWrapper commitConfigurationForSession:_videoCaptureSession];
return nil;
[_mediaSettingsAVWrapper unlockDevice:_captureDevice];
}
} else {
// If the frame rate is not important fall to a less restrictive
Expand Down

0 comments on commit 8de5b00

Please sign in to comment.