Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
529
Issue boards
Milestones
Wiki
Code
Merge requests
15
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
17b6c5bc
Commit
17b6c5bc
authored
2 years ago
by
Nicolas Pomepuy
Browse files
Options
Downloads
Patches
Plain Diff
FrameRateManager: refactor the DisplayManager retrieval
parent
50ab62f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1510
FrameRateManager: prevent play to be called wrongfully
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/vlc-android/src/org/videolan/vlc/util/FrameRateManager.kt
+9
-6
9 additions, 6 deletions
...vlc-android/src/org/videolan/vlc/util/FrameRateManager.kt
with
9 additions
and
6 deletions
application/vlc-android/src/org/videolan/vlc/util/FrameRateManager.kt
+
9
−
6
View file @
17b6c5bc
...
...
@@ -11,7 +11,6 @@ import android.view.SurfaceView
import
android.view.Window
import
android.view.WindowManager
import
androidx.annotation.RequiresApi
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.getSystemService
import
org.videolan.vlc.BuildConfig
import
org.videolan.vlc.PlaybackService
...
...
@@ -44,10 +43,16 @@ class FrameRateManager(var context: Context, var service: PlaybackService) {
}
}
val
displayManager
=
context
.
getSystemService
(
Context
.
DISPLAY_SERVICE
)
as
DisplayManager
displayManager
.
registerDisplayListener
(
displayListener
,
Handler
(
Looper
.
getMainLooper
()))
getDisplayManager
().
registerDisplayListener
(
displayListener
,
Handler
(
Looper
.
getMainLooper
()))
}
/**
* Retrieve the [DisplayManager]
*
* @return the current [DisplayManager]
*/
private
fun
getDisplayManager
()
=
(
context
.
getSystemService
(
Context
.
DISPLAY_SERVICE
)
as
DisplayManager
)
fun
matchFrameRate
(
surfaceView
:
SurfaceView
,
window
:
Window
)
{
/* automatic frame rate switching for displays/HDMI
most media will be either 23.976, 24, 25, 29.97, 30, 48, 50, 59.94, and 60 fps */
...
...
@@ -85,8 +90,6 @@ class FrameRateManager(var context: Context, var service: PlaybackService) {
}
else
{
//detect if a non-seamless refresh rate switch is about to happen
var
seamless
=
false
val
androidDisplayManager
:
DisplayManager
=
context
.
getSystemService
(
AppCompatActivity
.
DISPLAY_SERVICE
)
as
DisplayManager
display
?.
mode
?.
alternativeRefreshRates
?.
let
{
refreshRates
->
for
(
rate
in
refreshRates
)
{
if
((
videoFrameRate
.
toString
().
startsWith
(
rate
.
toString
()))
||
(
rate
.
toString
().
startsWith
(
videoFrameRate
.
toString
()))
||
rate
%
videoFrameRate
==
0F
)
{
...
...
@@ -99,7 +102,7 @@ class FrameRateManager(var context: Context, var service: PlaybackService) {
if
(
seamless
)
{
//switch will be seamless
surface
.
setFrameRate
(
videoFrameRate
,
Surface
.
FRAME_RATE_COMPATIBILITY_FIXED_SOURCE
,
Surface
.
CHANGE_FRAME_RATE_ALWAYS
)
}
else
if
(!
seamless
&&
(
android
DisplayManager
.
matchContentFrameRateUserPreference
==
DisplayManager
.
MATCH_CONTENT_FRAMERATE_ALWAYS
))
{
}
else
if
(!
seamless
&&
(
get
DisplayManager
()
.
matchContentFrameRateUserPreference
==
DisplayManager
.
MATCH_CONTENT_FRAMERATE_ALWAYS
))
{
//switch will be non seamless, check if user has opted in for this at the OS level
//TODO: only included this here because Android guide makes it sound like seamless-behavior includes stuff like HDMI switching
//may have to remove this block since we intend to switch only if it will be seamless
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment