[WIP] Cleanup: removed redundant code

This commit is contained in:
Alex P 2025-09-16 15:14:00 +03:00
parent 1f88dab95f
commit b23cc50d6c
2 changed files with 11 additions and 36 deletions

View File

@ -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 // logComponentStart logs component start with consistent format
func (bam *BaseAudioManager) logComponentStart(component string) { func (bam *BaseAudioManager) logComponentStart(component string) {

View File

@ -17,22 +17,7 @@ const (
AudioOutputSupervisorComponent = "audio-output-supervisor" 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 // AudioOutputSupervisor manages the audio output server subprocess lifecycle
type AudioOutputSupervisor struct { type AudioOutputSupervisor struct {
@ -175,10 +160,10 @@ func (s *AudioOutputSupervisor) supervisionLoop() {
ProcessType: "audio output server", ProcessType: "audio output server",
Timeout: Config.OutputSupervisorTimeout, Timeout: Config.OutputSupervisorTimeout,
EnableRestart: true, EnableRestart: true,
MaxRestartAttempts: getMaxRestartAttempts(), MaxRestartAttempts: Config.MaxRestartAttempts,
RestartWindow: getRestartWindow(), RestartWindow: Config.RestartWindow,
RestartDelay: getRestartDelay(), RestartDelay: Config.RestartDelay,
MaxRestartDelay: getMaxRestartDelay(), MaxRestartDelay: Config.MaxRestartDelay,
} }
// Configure callbacks // Configure callbacks
@ -255,13 +240,13 @@ func (s *AudioOutputSupervisor) shouldRestart() bool {
now := time.Now() now := time.Now()
var recentAttempts []time.Time var recentAttempts []time.Time
for _, attempt := range s.restartAttempts { for _, attempt := range s.restartAttempts {
if now.Sub(attempt) < getRestartWindow() { if now.Sub(attempt) < Config.RestartWindow {
recentAttempts = append(recentAttempts, attempt) recentAttempts = append(recentAttempts, attempt)
} }
} }
s.restartAttempts = recentAttempts s.restartAttempts = recentAttempts
return len(s.restartAttempts) < getMaxRestartAttempts() return len(s.restartAttempts) < Config.MaxRestartAttempts
} }
// recordRestartAttempt records a restart attempt // recordRestartAttempt records a restart attempt
@ -280,17 +265,17 @@ func (s *AudioOutputSupervisor) calculateRestartDelay() time.Duration {
// Exponential backoff based on recent restart attempts // Exponential backoff based on recent restart attempts
attempts := len(s.restartAttempts) attempts := len(s.restartAttempts)
if attempts == 0 { if attempts == 0 {
return getRestartDelay() return Config.RestartDelay
} }
// Calculate exponential backoff: 2^attempts * base delay // Calculate exponential backoff: 2^attempts * base delay
delay := getRestartDelay() delay := Config.RestartDelay
for i := 0; i < attempts && delay < getMaxRestartDelay(); i++ { for i := 0; i < attempts && delay < Config.MaxRestartDelay; i++ {
delay *= 2 delay *= 2
} }
if delay > getMaxRestartDelay() { if delay > Config.MaxRestartDelay {
delay = getMaxRestartDelay() delay = Config.MaxRestartDelay
} }
return delay return delay