Small audio.zig refactor#3367
Open
RanPix wants to merge 5 commits into
Open
Conversation
7 tasks
Wunka
suggested changes
Jul 15, 2026
Wunka
left a comment
Contributor
There was a problem hiding this comment.
This seems like an simple change, so will put in Easy to review
IntegratedQuantum
requested changes
Jul 15, 2026
|
|
||
| const c = @import("c"); | ||
|
|
||
| fn getMaError(err: c_int) anyerror { |
Member
There was a problem hiding this comment.
Why are you calling it MaError, when the error comes from stb vorbis?
| 38 => error.VORBIS_ogg_skeleton_not_supported, | ||
| else => unreachable, | ||
| }; | ||
| } |
Member
There was a problem hiding this comment.
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.
| 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}); |
Member
There was a problem hiding this comment.
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.
| musicId: []const u8, | ||
| audioId: []const u8, | ||
| data: []f32 = &.{}, | ||
| isMono: bool = false, |
Member
There was a problem hiding this comment.
Suggested change
| isMono: bool = false, | |
| type: enum {mono, stereo} = .stereo, |
| }; | ||
|
|
||
| var activeTasks: main.List([]const u8) = .empty; | ||
| var activeTasks: main.List([]const u8) = .empty; // MARK: MUSIC |
Member
There was a problem hiding this comment.
We don't SCREAM
Suggested change
| var activeTasks: main.List([]const u8) = .empty; // MARK: MUSIC | |
| var activeTasks: main.List([]const u8) = .empty; // MARK: Music |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
preparation for #3281 to reduce line count