Zeugma440 / atldotnet

Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
MIT License
442 stars 60 forks source link

Async support - Custom BinaryWriter #162

Closed Zeugma440 closed 1 year ago

Zeugma440 commented 1 year ago

Try writing a custom, async-compatible BinaryWriter with the same API as the standard one

CooPzZ commented 1 year ago

In case you missed it - someone had done it in the thread you referenced, although I don't know if it will work and has what you'll need. https://github.com/ronnieoverby/AsyncBinaryReaderWriter

Zeugma440 commented 1 year ago

Yup, I've seen it (5 years old, unanswered issues, no release...)

I got more than enough in StreamUtils to make my own, tbh. If I do go that way, I'll have to benchmark a couple variants to see which one performs better.

Right now I'm reducing the library's dependency to BinaryWriter by replacing it with Stream when possible. Results are very encouraging.

Zeugma440 commented 1 year ago

After refactoring, Stream is available where we need it most, i.e. where the file is being resized.

BinaryWriter is only used locally when needed to write bytes where they belong, which is much less I/O-hungry.

=> Writing a custom, async-compatible BinaryWriter is no longer required to implement async support.