Skip to content

Commit

Permalink
Nikon put_viewfinder down should do a busy check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Govero authored and msmeissn committed Jul 7, 2023
1 parent 4692712 commit 839a1bc
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions camlibs/ptp2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -8196,6 +8196,8 @@ _put_Nikon_ViewFinder(CONFIG_PUT_ARGS) {
if (!ptp_operation_issupported(params, PTP_OC_NIKON_StartLiveView))
return GP_ERROR_NOT_SUPPORTED;

C_PTP_REP (ptp_nikon_device_ready(params));

CR (gp_widget_get_value (widget, &val));
if (val) {
PTPPropertyValue value;
Expand Down Expand Up @@ -8231,7 +8233,7 @@ _put_Nikon_ViewFinder(CONFIG_PUT_ARGS) {
}
}

if (!value.u8) {
if (!value.u8) {
value.u8 = 1;
LOG_ON_PTP_E (ptp_setdevicepropvalue (params, PTP_DPC_NIKON_RecordingMedia, &value, PTP_DTC_UINT8));
C_PTP_REP_MSG (ptp_nikon_start_liveview (params),
Expand All @@ -8241,8 +8243,19 @@ _put_Nikon_ViewFinder(CONFIG_PUT_ARGS) {
params->inliveview = 1;
}
} else {
if (ptp_operation_issupported(params, PTP_OC_NIKON_EndLiveView))
C_PTP (ptp_nikon_end_liveview (params));
if (ptp_operation_issupported(params, PTP_OC_NIKON_EndLiveView)) {
// busy check here needed for some nikons to
// prevent bad camera state
C_PTP_REP (ptp_nikon_device_ready(params));

uint16_t res = ptp_nikon_end_liveview (params);
// printf("Live view end code: %d\n", res);
if (res == 0xa004) {
// PTP_C(ptp_nikon_device_ready(params));
return GP_ERROR_CAMERA_BUSY;
}
C_PTP(res);
}
params->inliveview = 0;
}
return GP_OK;
Expand Down

0 comments on commit 839a1bc

Please sign in to comment.