From 3c778816d9d6caea68ddb4ffdfea18b9e5db1c59 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 12 May 2024 16:23:38 +0200 Subject: [PATCH] examples: improve play-opus code quality a bit Signed-off-by: Stephen Gutekanst --- examples/play-opus/App.zig | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/play-opus/App.zig b/examples/play-opus/App.zig index ae9d8ff0..c905ab78 100644 --- a/examples/play-opus/App.zig +++ b/examples/play-opus/App.zig @@ -41,13 +41,12 @@ fn init( app.schedule(.after_init); const bgm_fbs = std.io.fixedBufferStream(assets.bgm.bit_bit_loop); + const bgm_sound_stream = std.io.StreamSource{ .const_buffer = bgm_fbs }; + const bgm = try mach.Audio.Opus.decodeStream(gpa.allocator(), bgm_sound_stream); + const sfx_fbs = std.io.fixedBufferStream(assets.sfx.sword1); - - var sound_stream = std.io.StreamSource{ .const_buffer = bgm_fbs }; - const bgm = try mach.Audio.Opus.decodeStream(gpa.allocator(), sound_stream); - - sound_stream = std.io.StreamSource{ .const_buffer = sfx_fbs }; - const sfx = try mach.Audio.Opus.decodeStream(gpa.allocator(), sound_stream); + const sfx_sound_stream = std.io.StreamSource{ .const_buffer = sfx_fbs }; + const sfx = try mach.Audio.Opus.decodeStream(gpa.allocator(), sfx_sound_stream); // Initialize module state app.init(.{ .sfx = sfx });