Preserve session repairs and frame grid boundaries

This commit is contained in:
Dylan M. Taylor committed 2026-11-13 09:21:57 +00:00
1 parent 68ad072e4a
commit b32e55a956
1 file changed
+12
+12
View File
@@ -348,6 +348,7 @@ impl AutoName {
pub struct Session {
pub format_version: u32,
pub name: String,
#[serde(deserialize_with = "sample_rate_or_default")]
pub sample_rate: SampleRate,
pub bit_depth: BitDepthSetting,
pub frame_rate: FrameRate,
@@ -384,6 +385,17 @@ pub struct Session {
pub folder: Option<std::path::PathBuf>,
}
/// Older SoundCraft builds repaired an in-range but invalid sample rate after reading a session.
/// `craft-time` validates `SampleRate` during serde, so keep that file compatibility at this
/// domain boundary while retaining strict serde validation for direct `SampleRate` use.
fn sample_rate_or_default<'de, D>(deserializer: D) -> Result<SampleRate, D::Error>
where
D: serde::Deserializer<'de>,
{
let hz = <u32 as serde::Deserialize>::deserialize(deserializer)?;
Ok(SampleRate::new(hz).unwrap_or_default())
}
impl Default for Session {
fn default() -> Self {
Session::new("Untitled", SampleRate::HZ_48000)