8000 Fix CPU is consumed by OSC while hidden, #3601 by low-batt · Pull Request #3602 · iina/iina · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix CPU is consumed by OSC while hidden, #3601 #3602

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

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions iina/MainWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,8 @@ class MainWindowController: PlayerWindowController {
return
}

// Follow energy efficiency best practices and stop the timer that updates the OSC.
player.invalidateTimer()
animationState = .willHide
fadeableViews.forEach { (v) in
v.isHidden = false
Expand Down Expand Up @@ -1532,9 +1534,9 @@ class MainWindowController: PlayerWindowController {
fadeableViews.forEach { (v) in
v.isHidden = false
}
if !player.isInMiniPlayer && fsState.isFullscreen && displayTimeAndBatteryInFullScreen {
player.syncUI(.additionalInfo)
}
// The OSC was not updated while it was hidden to avoid wasting energy. Update it now.
player.syncUITime()
player.createSyncUITimer()
standardWindowButtons.forEach { $0.isEnabled = true }
NSAnimationContext.runAnimationGroup({ (context) in
context.duration = UIAnimationDuration
Expand Down
6 changes: 3 additions & 3 deletions iina/PlaybackInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class PlaybackInfo {
var cachedWindowScale: Double = 1.0

func constrainVideoPosition() {
guard let duration = videoDuration else { return }
if videoPosition!.second < 0 { videoPosition!.second = 0 }
if videoPosition!.second > duration.second { videoPosition!.second = duration.second }
guard let duration = videoDuration, let position = videoPosition else { return }
if position.second < 0 { position.second = 0 }
if position.second > duration.second { position.second = duration.second }
}

var isSeeking: Bool = false
Expand Down
0