diff options
Diffstat (limited to 'src/wav')
| -rw-r--r-- | src/wav/wav.odin | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/wav/wav.odin b/src/wav/wav.odin index bfa11b1..0d148c7 100644 --- a/src/wav/wav.odin +++ b/src/wav/wav.odin @@ -9,6 +9,7 @@ import "xml" /* TODO: Support RF64 +TODO: Test on files from SD788t TODO: Support music metadata */ @@ -110,7 +111,7 @@ main :: proc() { /* Reads in the wav file metadata, without loading the sound data into ram. */ -read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #optional_ok { +read :: proc(path : string, allocator := context.allocator) -> (Wav, bool) #optional_ok { file : Wav file.path = path file.take = -1 @@ -126,11 +127,10 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option return {}, false } - - temp_buf := new([BUFFER_SIZE]u8)[:] + temp_buf := make([]u8, BUFFER_SIZE) + defer delete(temp_buf) temp_bext : []u8 temp_ixml : string - defer delete(temp_buf) os.read(file.handle, temp_buf) @@ -318,7 +318,7 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option */ interleave_set := false - xml_recurse :: proc(doc: ^xml.Document, element_id: xml.Element_ID, file: ^Wav, naming_channel: ^int, interleave_set: ^bool, allocator:=context.allocator, indent := 0) { + xml_recurse :: proc(doc: ^xml.Document, element_id: xml.Element_ID, file: ^Wav, naming_channel: ^int, interleave_set: ^bool, allocator:type_of(context.allocator), indent := 0) { naming_channel := naming_channel interleave_set := interleave_set @@ -448,6 +448,9 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option parsed_ixml : ^xml.Document + prev_alloc := context.allocator + defer context.allocator = prev_alloc + context.allocator = context.temp_allocator parsed_ixml, _ = xml.parse(temp_ixml, xml.Options{ flags={.Ignore_Unsupported}, expected_doctype = "", @@ -469,7 +472,7 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option description := string(temp_bext[:256]) for line in strings.split_lines(description) { - + if len(line)<1 do continue if file.channel_names[naming_channel] == "" && (strings.starts_with(line, "sTRK") || strings.starts_with(line, "zTRK")) { eq_index := strings.index(line, "=") @@ -545,7 +548,6 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option // just here to make some printing prettier temp_bext = nil - temp_buf = nil return file, true } |