From b23cc50d6c79361b959319c3325a83bdf82eef18 Mon Sep 17 00:00:00 2001 From: Alex P Date: Tue, 16 Sep 2025 15:14:00 +0300 Subject: [PATCH] [WIP] Cleanup: removed redundant code --- internal/audio/mgmt_base_manager.go | 10 -------- internal/audio/output_supervisor.go | 37 +++++++++-------------------- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/internal/audio/mgmt_base_manager.go b/internal/audio/mgmt_base_manager.go index 3023fd32..fb8d0a7d 100644 --- a/internal/audio/mgmt_base_manager.go +++ b/internal/audio/mgmt_base_manager.go @@ -77,17 +77,7 @@ func (bam *BaseAudioManager) getBaseMetrics() BaseAudioMetrics { } } -// recordFrameProcessed records a processed frame with simplified tracking -func (bam *BaseAudioManager) recordFrameProcessed(bytes int) { -} -// recordFrameDropped records a dropped frame with simplified tracking -func (bam *BaseAudioManager) recordFrameDropped() { -} - -// updateLatency updates the average latency -func (bam *BaseAudioManager) updateLatency(latency time.Duration) { -} // logComponentStart logs component start with consistent format func (bam *BaseAudioManager) logComponentStart(component string) { diff --git a/internal/audio/output_supervisor.go b/internal/audio/output_supervisor.go index a0483508..2d7a8408 100644 --- a/internal/audio/output_supervisor.go +++ b/internal/audio/output_supervisor.go @@ -17,22 +17,7 @@ const ( AudioOutputSupervisorComponent = "audio-output-supervisor" ) -// Restart configuration is now retrieved from centralized config -func getMaxRestartAttempts() int { - return Config.MaxRestartAttempts -} -func getRestartWindow() time.Duration { - return Config.RestartWindow -} - -func getRestartDelay() time.Duration { - return Config.RestartDelay -} - -func getMaxRestartDelay() time.Duration { - return Config.MaxRestartDelay -} // AudioOutputSupervisor manages the audio output server subprocess lifecycle type AudioOutputSupervisor struct { @@ -175,10 +160,10 @@ func (s *AudioOutputSupervisor) supervisionLoop() { ProcessType: "audio output server", Timeout: Config.OutputSupervisorTimeout, EnableRestart: true, - MaxRestartAttempts: getMaxRestartAttempts(), - RestartWindow: getRestartWindow(), - RestartDelay: getRestartDelay(), - MaxRestartDelay: getMaxRestartDelay(), + MaxRestartAttempts: Config.MaxRestartAttempts, + RestartWindow: Config.RestartWindow, + RestartDelay: Config.RestartDelay, + MaxRestartDelay: Config.MaxRestartDelay, } // Configure callbacks @@ -255,13 +240,13 @@ func (s *AudioOutputSupervisor) shouldRestart() bool { now := time.Now() var recentAttempts []time.Time for _, attempt := range s.restartAttempts { - if now.Sub(attempt) < getRestartWindow() { + if now.Sub(attempt) < Config.RestartWindow { recentAttempts = append(recentAttempts, attempt) } } s.restartAttempts = recentAttempts - return len(s.restartAttempts) < getMaxRestartAttempts() + return len(s.restartAttempts) < Config.MaxRestartAttempts } // recordRestartAttempt records a restart attempt @@ -280,17 +265,17 @@ func (s *AudioOutputSupervisor) calculateRestartDelay() time.Duration { // Exponential backoff based on recent restart attempts attempts := len(s.restartAttempts) if attempts == 0 { - return getRestartDelay() + return Config.RestartDelay } // Calculate exponential backoff: 2^attempts * base delay - delay := getRestartDelay() - for i := 0; i < attempts && delay < getMaxRestartDelay(); i++ { + delay := Config.RestartDelay + for i := 0; i < attempts && delay < Config.MaxRestartDelay; i++ { delay *= 2 } - if delay > getMaxRestartDelay() { - delay = getMaxRestartDelay() + if delay > Config.MaxRestartDelay { + delay = Config.MaxRestartDelay } return delay