Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wavbrro improvements #69

Merged
merged 7 commits into from
Nov 14, 2023
Merged

Wavbrro improvements #69

merged 7 commits into from
Nov 14, 2023

Conversation

cjrolo
Copy link
Collaborator

@cjrolo cjrolo commented Nov 9, 2023

After running a couple of tests and benchmarks, this PR uniforms error control in uncompressed vs compressed files.

WAVBRO now has a proper error type
And a misc change on FFT that has not much to do with anything but I landed it here.

Copy link
Contributor

@rukai rukai left a comment

Choose a reason for hiding this comment

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

My approach to writing errors for applications is:

When writing a library I should always use https://docs.rs/thiserror/latest/thiserror/

process_single_file(path, arguments)?;
match process_single_file(path.clone(), arguments) {
Ok (_) => continue,
//TODO: Files are created while this walks the dir, gives a funny output
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what this means lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When you walk a dir with std::fs::read_dir it will call the underlying OS function, and if new files are created while you're walking the dir, they will be returned. Since the compressor is creating files, entry will be one of the created files here and there, and there will be an output WARN/ERROR message.
A check has to be created for this case and ignore those files.

// Error class is based on https://codeberg.org/ruuda/hound/src/branch/master given the similarities
// between the formats (WAV and WAVBRRO).
#[derive(Debug)]
pub enum Error {
Copy link
Contributor

Choose a reason for hiding this comment

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

https://docs.rs/thiserror/latest/thiserror/ can be helpful when writing error enums

@cjrolo cjrolo merged commit a1dd95c into main Nov 14, 2023
2 checks passed
@cjrolo cjrolo deleted the wavbrro-improvements branch November 14, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants