mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Fix some cases when refresh rate switching didn't work/timed out (#901)
## Description An attempt to fix #769 1. Always fetch the `DisplayManager` when switching refresh rates 2. Use the Activity context instead of Application context ### Related issues Fixes #769 ### Testing I still haven't reproduced #769 myself, but this change works fine on my shield + LG C2 ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
0276c5f49b
commit
dc3c6dc739
3 changed files with 24 additions and 19 deletions
|
|
@ -28,21 +28,6 @@ class RefreshRateService
|
|||
constructor(
|
||||
@param:ApplicationContext private val context: Context,
|
||||
) {
|
||||
private val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||
private val display get() = displayManager.getDisplay(Display.DEFAULT_DISPLAY)
|
||||
|
||||
val supportedDisplayModes get() = display.supportedModes.orEmpty()
|
||||
|
||||
private val displayModes: List<DisplayMode> by lazy {
|
||||
display.supportedModes
|
||||
.orEmpty()
|
||||
.map { DisplayMode(it) }
|
||||
.sortedWith(
|
||||
compareByDescending<DisplayMode>({ it.physicalWidth * it.physicalHeight })
|
||||
.thenBy { it.refreshRateRounded },
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the best display mode for the given stream and signal to change to it
|
||||
*/
|
||||
|
|
@ -55,6 +40,18 @@ class RefreshRateService
|
|||
Timber.v("Not switching either refresh rate nor resolution")
|
||||
return@withContext
|
||||
}
|
||||
val displayManager =
|
||||
MainActivity.instance.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||
val display = displayManager.getDisplay(Display.DEFAULT_DISPLAY)
|
||||
val displayModes =
|
||||
display.supportedModes
|
||||
.orEmpty()
|
||||
.map { DisplayMode(it) }
|
||||
.sortedWith(
|
||||
compareByDescending<DisplayMode>({ it.physicalWidth * it.physicalHeight })
|
||||
.thenBy { it.refreshRateRounded },
|
||||
)
|
||||
|
||||
val currentDisplayMode = display.mode
|
||||
require(stream.type == MediaStreamType.VIDEO) { "Stream is not video" }
|
||||
val width = stream.width
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue