| Summary: | [patch] Android: Expose screen refresh rate | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jonas Kulla <ancurio_bugzilla> |
| Component: | video | Assignee: | Gabriel Jacobo <gabomdq> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | enhancement | ||
| Priority: | P2 | CC: | gabomdq, philipp.wiesemann |
| Version: | HG 2.1 | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
| Attachments: | patch | ||
Thank you for providing a patch. An idea: The new nativeSetRefreshRate() is only called close to onNativeResize(). Maybe the signature of onNativeResize() could be changed to include a parameter for the rate. Then nativeSetRefreshRate() would not be needed anymore (and the patch would be smaller :). Also the values passed to both functions are used together in Android_VideoInit() anyway. I have not tried it. Maybe I am missing something. A modified version of the patch was applied (see previous comment). https://hg.libsdl.org/SDL/rev/8d826bc39a45 Also there seems to be a bug in some Android devices where getRefreshRate() returns a float smaller 0. For SDL_DisplayMode this does not matter because such values are shortened from float to int and therefore (being 0) just mean "unspecified" (per contract). It makes nothing worse. :) I consciously tried to avoid changing the signature of existing native functions because I was worried about backwards compatibility; for example, let's say I copied the native activity Java code to my project and adjusted it to my needs (etc.); if later I only upgraded the native side of SDL2, the C function would take a garbage value out of some register/stack and report that as the refresh rate. I don't really know what your guys policy on compatibility in the Android backend and Java side is. If it is "any native side update must be accompanied by an equal Java side update", then of course your patch is fine, containing less code changes. We are eventually going to make it obvious that you are using an out of date Java file: https://bugzilla.libsdl.org/show_bug.cgi?id=2614 |
Created attachment 1968 [details] patch Display::getRefreshRate() is available on all API levels.