-
Notifications
You must be signed in to change notification settings - Fork 444
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
Replace NativeFile to use SDL IO functions. #2133
Conversation
f4f950a
to
c8e90f1
Compare
|
||
if (setvbuf(file, nullptr, vbufmode, (size_t) size) != 0) | ||
return false; | ||
// FIXME: SDL doesn't have option to set buffering. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should make an issue in their repo about this? I feel like it's pretty useful / important, but at the very least we'd get their opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That being said, for now we could probably implement BUFFER_LINE
ourselves (like what's done in physfs/File.cpp) and leave the rest as a todo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I opened ticket in SDL for this. libsdl-org/SDL#11832
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that SDL is just low-level wrapper to OS-specific API (such as Windows file HANDLE
or POSIX file descriptor) and there's no explicit way to set buffering mode on those handle/file descriptors, then the best but unfortunate way to solve this is to implement our own buffering.
One more thing I forgot to mention is the behavior of |
Our physfs File backend temporarily opens the file to determine its size in that situation: love/src/modules/filesystem/physfs/File.cpp Lines 178 to 184 in f0a7a19
|
Also remove Android-specific code from it as SDL is now able to handle them.
43a3cda
to
e95c3a2
Compare
Looks good, thanks! |
This removes any platform-specific code from
NativeFile
and rely on SDL3 IO functions diretly.One issue I found with this is that SDL3 doesn't expose any function to set the IO buffering mode. This is why this change goes into a PR to discuss how should the buffering function behaves.