diff options
Diffstat (limited to 'src/wav')
| -rw-r--r-- | src/wav/wav.odin | 16 | ||||
| -rw-r--r-- | src/wav/xml/xml_reader.odin | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/wav/wav.odin b/src/wav/wav.odin index 0d148c7..dc5923f 100644 --- a/src/wav/wav.odin +++ b/src/wav/wav.odin @@ -29,7 +29,7 @@ Wav :: struct { audio : [][]f32, // Internals - handle : os.Handle, + handle : ^os.File, load_head : int, // Metadata @@ -120,9 +120,7 @@ read :: proc(path : string, allocator := context.allocator) -> (Wav, bool) #opti load_err : os.Error file.handle, load_err = os.open(path) - defer os.close(file.handle) - defer file.handle = 0 - if load_err != os.General_Error.None { + if load_err != nil { fmt.eprintfln("ERROR %v: Unable to load file \"%v\"", load_err, path) return {}, false } @@ -471,7 +469,8 @@ read :: proc(path : string, allocator := context.allocator) -> (Wav, bool) #opti naming_channel := 0 description := string(temp_bext[:256]) - for line in strings.split_lines(description) { + lines := strings.split_lines(description) + for line in lines { if len(line)<1 do continue if file.channel_names[naming_channel] == "" && (strings.starts_with(line, "sTRK") || strings.starts_with(line, "zTRK")) { @@ -512,6 +511,7 @@ read :: proc(path : string, allocator := context.allocator) -> (Wav, bool) #opti } } } + delete(lines) head := 0 when VERBOSE do fmt.printf("Description: \n%v\n", string(temp_bext[head:256])) head += 256 @@ -548,6 +548,9 @@ read :: proc(path : string, allocator := context.allocator) -> (Wav, bool) #opti // just here to make some printing prettier temp_bext = nil + os.close(file.handle) + file.handle = nil + return file, true } @@ -640,8 +643,7 @@ tprint_timecode :: proc(file : Wav) -> string { } print_timecode :: proc(file : Wav, allocator := context.allocator) -> string { tc := get_timecode(file) - using tc - return fmt.aprintf("%02d:%02d:%02d:%02d",hour,minute,second,frame, + return fmt.aprintf("%02d:%02d:%02d:%02d", tc.hour, tc.minute, tc.second, tc.frame, allocator=allocator) } get_timecode :: proc(file : Wav) -> (output:Timecode) { diff --git a/src/wav/xml/xml_reader.odin b/src/wav/xml/xml_reader.odin index c19cbf6..b277a5e 100644 --- a/src/wav/xml/xml_reader.odin +++ b/src/wav/xml/xml_reader.odin @@ -377,8 +377,8 @@ load_from_file :: proc(filename: string, options := DEFAULT_OPTIONS, error_handl context.allocator = allocator options := options - data, data_ok := os.read_entire_file(filename) - if !data_ok { return {}, .File_Error } + data, data_err := os.read_entire_file(filename, context.allocator) + if data_err != nil { return {}, .File_Error } options.flags += { .Input_May_Be_Modified } |