Skip to content

Small audio.zig refactor#3367

Open
RanPix wants to merge 5 commits into
PixelGuys:masterfrom
RanPix:smallAudioZigRefactor
Open

Small audio.zig refactor#3367
RanPix wants to merge 5 commits into
PixelGuys:masterfrom
RanPix:smallAudioZigRefactor

Conversation

@RanPix

@RanPix RanPix commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

preparation for #3281 to reduce line count

@Wunka Wunka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an simple change, so will put in Easy to review

Comment thread src/audio.zig Outdated
@Wunka Wunka moved this to Easy to Review in PRs to review Jul 15, 2026
Comment thread src/audio.zig

const c = @import("c");

fn getMaError(err: c_int) anyerror {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you calling it MaError, when the error comes from stb vorbis?

Comment thread src/audio.zig
38 => error.VORBIS_ogg_skeleton_not_supported,
else => unreachable,
};
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to do it like I did in vulkan using an enum and enum conversion functions, the problem I have with the error approach is that the no_error case makes no sense as an error value.

Comment thread src/audio.zig
defer main.stackAllocator.free(path2);
if (c.stb_vorbis_open_filename(path2.ptr, &err, null)) |ogg_stream| return ogg_stream;
std.log.err("Couldn't find music with id \"{s}\". Searched path \"{s}\" and \"{s}\"", .{id, path1, path2});
std.log.err("Couldn't handle audio file. Error: {t}. ID: \"{s}\". Searched path: \"{s}\" and \"{s}\"", .{getMaError(err), id, path1, path2});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should print both errors, otherwise the user will in the worst case only see the file not found error and not the one that relates to their file.

Comment thread src/audio.zig
musicId: []const u8,
audioId: []const u8,
data: []f32 = &.{},
isMono: bool = false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isMono: bool = false,
type: enum {mono, stereo} = .stereo,

Comment thread src/audio.zig
};

var activeTasks: main.List([]const u8) = .empty;
var activeTasks: main.List([]const u8) = .empty; // MARK: MUSIC

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't SCREAM

Suggested change
var activeTasks: main.List([]const u8) = .empty; // MARK: MUSIC
var activeTasks: main.List([]const u8) = .empty; // MARK: Music

@IntegratedQuantum IntegratedQuantum moved this from Easy to Review to In review in PRs to review Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants