use crate::sys::*;
use crate::PluginInstance;
unsafe extern "C" fn update_param_ui(
effect_ref: PF_ProgPtr,
param_index: PF_ParamIndex,
defP: *const PF_ParamDef,
) -> PF_Err {
crate::core::ffi::guard("update_param_ui", || {
if effect_ref.is_null() || defP.is_null() {
return PF_Err_BAD_CALLBACK_PARAM;
}
let Some(mut instance) = PluginInstance::get_instance_ptr(effect_ref) else {
log::error!("PF_UpdateParamUI: no plugin instance for effect_ref");
return PF_Err_BAD_CALLBACK_PARAM;
};
let def = unsafe { &*defP };
unsafe { instance.as_mut() }.update_param_ui(param_index as usize, def);
PF_Err_NONE
})
}
unsafe extern "C" fn get_current_state(
_effect_ref: PF_ProgPtr,
_param_index: PF_ParamIndex,
_startPT0: *const A_Time,
_durationPT0: *const A_Time,
stateP: *mut PF_State,
) -> PF_Err {
crate::core::ffi::guard("get_current_state", || {
if stateP.is_null() {
return PF_Err_BAD_CALLBACK_PARAM;
}
unsafe { std::ptr::write_bytes(stateP, 0, 1) };
PF_Err_NONE
})
}
unsafe extern "C" fn are_states_identical(
_effect_ref: PF_ProgPtr,
_state1P: *const PF_State,
_state2P: *const PF_State,
samePB: *mut A_Boolean,
) -> PF_Err {
crate::core::ffi::guard("are_states_identical", || {
if samePB.is_null() {
return PF_Err_BAD_CALLBACK_PARAM;
}
unsafe { *samePB = 1 };
PF_Err_NONE
})
}
unsafe extern "C" fn is_identical_checkout(
_effect_ref: PF_ProgPtr,
_param_index: PF_ParamIndex,
_what_time1: A_long,
_time_step1: A_long,
_time_scale1: A_u_long,
_what_time2: A_long,
_time_step2: A_long,
_time_scale2: A_u_long,
identicalPB: *mut PF_Boolean,
) -> PF_Err {
crate::core::ffi::guard("is_identical_checkout", || {
if identicalPB.is_null() {
return PF_Err_BAD_CALLBACK_PARAM;
}
unsafe { *identicalPB = 1 };
PF_Err_NONE
})
}
unsafe extern "C" fn find_keyframe_time(
_effect_ref: PF_ProgPtr,
_param_index: PF_ParamIndex,
_what_time: A_long,
_time_scale: A_u_long,
_time_dir: PF_TimeDir,
foundPB: *mut PF_Boolean,
_key_indexP0: *mut PF_KeyIndex,
_key_timeP0: *mut A_long,
_key_timescaleP0: *mut A_u_long,
) -> PF_Err {
crate::core::ffi::guard("find_keyframe_time", || {
if !foundPB.is_null() {
unsafe { *foundPB = 0 };
}
PF_Err_NONE
})
}
unsafe extern "C" fn get_keyframe_count(
_effect_ref: PF_ProgPtr,
_param_index: PF_ParamIndex,
key_countP: *mut PF_KeyIndex,
) -> PF_Err {
crate::core::ffi::guard("get_keyframe_count", || {
if key_countP.is_null() {
return PF_Err_BAD_CALLBACK_PARAM;
}
unsafe { *key_countP = 0 };
PF_Err_NONE
})
}
unsafe extern "C" fn checkout_keyframe(
_effect_ref: PF_ProgPtr,
_param_index: PF_ParamIndex,
_key_index: PF_KeyIndex,
_key_timeP0: *mut A_long,
_key_timescaleP0: *mut A_u_long,
_paramP0: *mut PF_ParamDef,
) -> PF_Err {
crate::core::ffi::guard("checkout_keyframe", || PF_Err_BAD_CALLBACK_PARAM)
}
unsafe extern "C" fn checkin_keyframe(_effect_ref: PF_ProgPtr, _paramP: *mut PF_ParamDef) -> PF_Err {
crate::core::ffi::guard("checkin_keyframe", || PF_Err_NONE)
}
unsafe extern "C" fn key_index_to_time(
_effect_ref: PF_ProgPtr,
_param_index: PF_ParamIndex,
_key_indexP: PF_KeyIndex,
key_timeP: *mut A_long,
key_timescaleP: *mut A_u_long,
) -> PF_Err {
crate::core::ffi::guard("key_index_to_time", || {
if !key_timeP.is_null() {
unsafe { *key_timeP = 0 };
}
if !key_timescaleP.is_null() {
unsafe { *key_timescaleP = 1 };
}
PF_Err_NONE
})
}
pub const fn create_param_utils_suite_3() -> PF_ParamUtilsSuite3 {
PF_ParamUtilsSuite3 {
PF_UpdateParamUI: Some(update_param_ui),
PF_GetCurrentState: Some(get_current_state),
PF_AreStatesIdentical: Some(are_states_identical),
PF_IsIdenticalCheckout: Some(is_identical_checkout),
PF_FindKeyframeTime: Some(find_keyframe_time),
PF_GetKeyframeCount: Some(get_keyframe_count),
PF_CheckoutKeyframe: Some(checkout_keyframe),
PF_CheckinKeyframe: Some(checkin_keyframe),
PF_KeyIndexToTime: Some(key_index_to_time),
}
}