From 1699d45ae4ec791522f0ae3ff976cc162660a5fc Mon Sep 17 00:00:00 2001 From: Jaby Date: Fri, 24 May 2024 21:08:54 +0200 Subject: [PATCH] Support Auto LBAs for steaming files --- src/Tools/psxcdgen_ex/src/types/mod.rs | 7 +++++++ src/Tools/psxcdgen_ex/src/types/overlay/mod.rs | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Tools/psxcdgen_ex/src/types/mod.rs b/src/Tools/psxcdgen_ex/src/types/mod.rs index 836f90b2..53c55392 100644 --- a/src/Tools/psxcdgen_ex/src/types/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/mod.rs @@ -273,6 +273,13 @@ impl File { Self::new_from_content(file_name, FileType::XAAudio(content), highest_size*channel_count) } + pub fn is_streaming_file(&self) -> bool { + match &self.content { + FileType::XAAudio(_) => true, + _ => false + } + } + pub fn get_track_rel_lba(&self) -> usize { self.properties.lba.get_track_relative() } diff --git a/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs b/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs index 106c8955..d2049b11 100644 --- a/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs @@ -83,7 +83,16 @@ fn for_each_lba_name Result<(), Error>> for lba_name in lba_names { if let Some(file) = file_map.get(lba_name) { let file_ref = format_if_error_drop_cause!(file.try_borrow(), "Failed accessing file \"{}\" for writing LBA information.\nNote: You can not inject the LBA information of a file into itself.", lba_name)?; - let (lba, bytes) = (file_ref.get_absolute_lba(), length_func(&Layout::File(file.clone())).bytes); + let (lba, bytes) = (file_ref.get_absolute_lba(), { + if file_ref.is_streaming_file() { + // Streaming files do not have a size restriction + Some(0) + } + + else { + length_func(&Layout::File(file.clone())).bytes + } + }); let is_lz4 = file_ref.properties.is_lz4; functor(idx, (lba, bytes.ok_or(Error::from_text(format!("{} does not contain a size!", lba_name)))?), is_lz4)?;