iOS 1.0 RC 1: battery and heat work, version label, web player redraw tweaks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0fc35b13e8
commit
c0e33b5e3e
18 files changed
+143
-36
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import Foundation
|
||||
|
||||
/// Whether anyone is looking at the app: the phone UI in the foreground, or CarPlay connected.
|
||||
/// Work that only feeds a screen (stemd polling, a shallow output buffer for snappy faders)
|
||||
/// checks this, so a locked phone playing music does as little as it can.
|
||||
enum AppActivity {
|
||||
private static let lock = UnfairLock()
|
||||
nonisolated(unsafe) private static var phone = true
|
||||
nonisolated(unsafe) private static var car = false
|
||||
nonisolated(unsafe) private static var waiters: [CheckedContinuation<Void, Never>] = []
|
||||
|
||||
static var isActive: Bool { lock.with { phone || car } }
|
||||
|
||||
static func setPhone(_ on: Bool) { update { phone = on } }
|
||||
static func setCar(_ on: Bool) { update { car = on } }
|
||||
|
||||
private static func update(_ change: () -> Void) {
|
||||
let ready = lock.with { () -> [CheckedContinuation<Void, Never>] in
|
||||
change()
|
||||
guard phone || car else { return [] }
|
||||
defer { waiters = [] }
|
||||
return waiters
|
||||
}
|
||||
ready.forEach { $0.resume() }
|
||||
}
|
||||
|
||||
/// Returns once the app is active, at once if it already is.
|
||||
static func untilActive() async {
|
||||
await withCheckedContinuation { (c: CheckedContinuation<Void, Never>) in
|
||||
let now = lock.with { () -> Bool in
|
||||
if phone || car { return true }
|
||||
waiters.append(c)
|
||||
return false
|
||||
}
|
||||
if now { c.resume() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ final class Log: @unchecked Sendable {
|
||||
func export() -> URL {
|
||||
let b = Bundle.main
|
||||
let d = UIDevice.current
|
||||
var head = "Stemify \(b.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "?") "
|
||||
var head = "Stemify \((b.object(forInfoDictionaryKey: "StemifyVersionLabel") ?? b.object(forInfoDictionaryKey: "CFBundleShortVersionString")) as? String ?? "?") "
|
||||
head += "(\(b.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "?"))\n"
|
||||
head += "\(d.model) · \(d.systemName) \(d.systemVersion) · \(UIScreen.main.maximumFramesPerSecond) Hz\n"
|
||||
head += "Verbose logging: \(Log.verbose ? "on" : "off")\n"
|
||||
|
||||
Reference in new issue
Block a user