From d545b77bd32ae3e91c92fb006da36e5c9f7c1cc3 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Thu, 2 Nov 2023 17:15:43 +0100 Subject: [PATCH] Playtime: Make pre-buffer be able to deal with time base "time" --- allocator/src/lib.rs | 16 ++++++++-------- playtime-api/src/persistence/mod.rs | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/allocator/src/lib.rs b/allocator/src/lib.rs index 4d7fe6d0f..24adcc6aa 100644 --- a/allocator/src/lib.rs +++ b/allocator/src/lib.rs @@ -183,15 +183,15 @@ impl HelgobossAllocator { let permit_count = ALLOC_PERMIT_COUNT.with(|p| p.get()); if forbid_count > 0 && permit_count == 0 { // Comment out if you want to ignore it TODO-high - // permit_alloc(|| { - // eprintln!( - // "Memory allocation of {} bytes failed from:\n{:?}", - // layout.size(), - // backtrace::Backtrace::new() - // ); - // }); + permit_alloc(|| { + eprintln!( + "Memory allocation of {} bytes failed from:\n{:?}", + layout.size(), + backtrace::Backtrace::new() + ); + }); // Comment out if you don't want to abort - std::alloc::handle_alloc_error(layout); + // std::alloc::handle_alloc_error(layout); } } } diff --git a/playtime-api/src/persistence/mod.rs b/playtime-api/src/persistence/mod.rs index 16d4bba82..27a8b5382 100644 --- a/playtime-api/src/persistence/mod.rs +++ b/playtime-api/src/persistence/mod.rs @@ -1252,7 +1252,17 @@ pub enum ClipTimeBase { Beat(BeatTimeBase), } -#[derive(Copy, Clone, PartialEq, Debug, Serialize, Deserialize, JsonSchema)] +impl ClipTimeBase { + pub fn is_time_based(&self) -> bool { + matches!(self, Self::Time) + } + + pub fn is_beat_based(&self) -> bool { + matches!(self, Self::Beat(_)) + } +} + +#[derive(Copy, Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema)] pub struct BeatTimeBase { #[deprecated(note = "moved to ClipAudioSettings#original_tempo")] #[serde(skip_serializing)] @@ -1304,6 +1314,15 @@ pub struct TimeSignature { pub denominator: u32, } +impl Default for TimeSignature { + fn default() -> Self { + Self { + numerator: 4, + denominator: 4, + } + } +} + #[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize, JsonSchema)] pub struct TrackId(String);