2024-06-11 22:57:04 +02:00
|
|
|
package flac_example
|
|
|
|
|
|
|
|
|
|
import "core:fmt"
|
2024-06-15 01:29:48 +02:00
|
|
|
import "core:mem"
|
|
|
|
|
import "core:mem/virtual"
|
2024-06-11 22:57:04 +02:00
|
|
|
import "core:os"
|
|
|
|
|
import "core:time"
|
|
|
|
|
|
|
|
|
|
import "../"
|
|
|
|
|
|
|
|
|
|
main :: proc() {
|
2024-06-15 01:29:48 +02:00
|
|
|
if len(os.args) < 2 {
|
2024-06-11 22:57:04 +02:00
|
|
|
fmt.eprintln("Please provide a path to a flac file.")
|
|
|
|
|
os.exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-15 01:29:48 +02:00
|
|
|
arena: virtual.Arena
|
|
|
|
|
arena_err := virtual.arena_init_static(&arena, mem.Megabyte * 8)
|
|
|
|
|
if arena_err != nil {
|
|
|
|
|
fmt.eprintln("Failed to alloc memory")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
allocator := virtual.arena_allocator(&arena)
|
|
|
|
|
|
|
|
|
|
start := time.now()
|
2024-06-15 03:39:53 +02:00
|
|
|
flac_data, err := flac.load_from_file(os.args[1], allocator = allocator)
|
2024-06-11 22:57:04 +02:00
|
|
|
if err != nil {
|
|
|
|
|
fmt.eprintln(err)
|
|
|
|
|
os.exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
end := time.now()
|
|
|
|
|
|
|
|
|
|
elapsed := time.diff(start, end)
|
|
|
|
|
fmt.println("Decoding took", elapsed)
|
|
|
|
|
}
|