-
Notifications
You must be signed in to change notification settings - Fork 0
Improve gif player performance with vsync support and frame rate control #42
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -46,11 +46,16 @@ int emu_close(int) | |||||
| // Function to read data from the memory-mapped file | ||||||
| int emu_read(int, void *buffer, size_t len) | ||||||
| { | ||||||
| if (!emu_memory) | ||||||
| if (!emu_memory || !buffer || len == 0) | ||||||
| { | ||||||
| return -1; | ||||||
| } | ||||||
|
|
||||||
| if (emu_offset >= emu_size) | ||||||
| { | ||||||
| return 0; // EOF | ||||||
| } | ||||||
|
|
||||||
| size_t read_length = ((emu_size - 1) < emu_offset + len) ? emu_size - emu_offset : len; | ||||||
| memcpy(buffer, emu_memory + emu_offset, read_length); | ||||||
| emu_offset += read_length; | ||||||
|
|
@@ -155,6 +160,14 @@ gd_GIF *gd_open_gif(const char *fname) | |||||
| width = read_num(fd); | ||||||
| height = read_num(fd); | ||||||
|
|
||||||
| // Validate dimensions to prevent excessive memory allocation | ||||||
| if (width == 0 || height == 0 || width > 4096 || height > 4096) | ||||||
|
||||||
| if (width == 0 || height == 0 || width > 4096 || height > 4096) | |
| if (width == 0 || height == 0 || width > kMaxGifDimension || height > kMaxGifDimension) |
Copilot
AI
Jun 17, 2025
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.
Accessing _enable_vsync and _max_fps from both the main thread and the render thread can cause data races. Use std::atomic or a mutex to synchronize these shared fields.
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.
[nitpick] Returning
-1forlen == 0may be misleading since reading zero bytes usually returns 0. Consider returning 0 to represent EOF or no bytes read.