Update from NavidromePlayer.zip (2026-04-05 12:12)
This commit is contained in:
parent
75a4343ad1
commit
32ab1a0e9a
1 changed files with 11 additions and 8 deletions
|
|
@ -174,16 +174,19 @@ struct MitsuhaVisualizerView: View {
|
|||
var body: some View {
|
||||
Group {
|
||||
if settings.enabled {
|
||||
// audioPlayer.levelTick is @Published and changes every time setLevels()
|
||||
// is called in AudioPlayer — i.e. on every actual audio data delivery.
|
||||
// Reading it here gives SwiftUI a concrete dependency: body re-evaluates
|
||||
// exactly when new level data arrives, Canvas re-executes, wave updates.
|
||||
// When paused the timers stop so levelTick stops changing — Canvas holds
|
||||
// last frame (correct). On resume the timers restart and levelTick resumes
|
||||
// incrementing — Canvas immediately reacts.
|
||||
let _ = audioPlayer.levelTick
|
||||
// levelTick is @Published on AudioPlayer — it increments every time
|
||||
// setLevels() is called (every timer tick / FFT frame).
|
||||
// Assigning to a NAMED local (not let _ =) guarantees SwiftUI registers
|
||||
// a real @Published dependency and re-evaluates body on every tick.
|
||||
// The tick value is then captured by Canvas so the drawing closure
|
||||
// executes on every re-evaluation — no separate display link needed.
|
||||
// Canvas accesses _audioLevels via the nonisolated(unsafe) currentLevels()
|
||||
// which avoids the unsafeForcedSync warning that occurs when accessing
|
||||
// @MainActor properties from the Canvas render thread.
|
||||
let tick = audioPlayer.levelTick
|
||||
|
||||
Canvas { context, size in
|
||||
_ = tick // capture forces Canvas closure re-execution each tick
|
||||
let now = CACurrentMediaTime()
|
||||
let rawLevels: [Float] = isPlaying
|
||||
? (previewLevels ?? audioPlayer.currentLevels())
|
||||
|
|
|
|||
Loading…
Reference in a new issue