-
Notifications
You must be signed in to change notification settings - Fork 21
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
Remove the requirement for std::io::Seek
for PacketReader etc.
#12
Comments
That's why Seek is required. |
So, is seek required when returning to beginning of the header that was found while recovering from corrupt? Then, isn't it enough to store merely thirty-or-something page header buffer? Maybe I am just misunderstanding your explanation. Could you show me the code for the processed you described? |
Lines 752 to 773 in 1da041d
|
After reading the code for n hours, I finally understand why Seek is needed. When searching for header, if there wasn't a magic within the first 27 bytes, it reads the succeeding output in a (maximum of) 1024-byte chunk each. This is repeated until But I think this can be done by reading byte-by-byte from the reader while matching against the magic pattern. Then it no longer require What do you think? If my idea seems to be good, I'll refactor the |
Yup that's correct.
That would work from a functionality standpoint, but note that it would then call the read function many many times. If the implementation calls a syscall inside, it would be quite slow from a performance standpoint. This can be fixed by using a |
I know that there is a concern of By the way, when it comes to adopt my idea, which do you think is better: require |
That'd be the best option imo. I'm not that convinced that the |
I'm wondering which of those two:
is better, and I want your opinion. (Sorry for my confusing text.) I think that it'd be better to remove |
I have recently run into this issue myself. Do I understand correctly that seeking can only occur in
Unless I am missing something, this should still yield the same behavior for types implementing An alternative fix would be to expose the size of the internal buffer to allow users to implement a custom buffering I might be missing something here, but if any of these ideas sound good, I can attempt an implementation myself. |
@florian1345 that proposal sounds good! You are welcome to file a PR :). |
Implemented my proposal to resolve RustAudio#12 .
Currently, readers like
PacketReader
requiresstd::io::Seek
. But the parsing process of Ogg container is actually streamable. Therefore, it may be more useful to remove those constraints for most of functions, except forseek_bytes
andseek_absgp
, which truly demandSeek
.The text was updated successfully, but these errors were encountered: