mirror of https://github.com/jetkvm/kvm.git
[WIP] Cleanup: removed redundant code
This commit is contained in:
parent
b23cc50d6c
commit
a8b58b5d34
|
@ -298,8 +298,6 @@ func (c *AudioConfigCache) GetBufferTooLargeError() error {
|
|||
return c.bufferTooLargeDecodeWrite
|
||||
}
|
||||
|
||||
// Removed duplicate config caching system - using AudioConfigCache instead
|
||||
|
||||
// updateCacheIfNeeded updates cache only if expired to avoid overhead
|
||||
func updateCacheIfNeeded(cache *AudioConfigCache) {
|
||||
if cache.initialized.Load() {
|
||||
|
@ -464,7 +462,6 @@ var (
|
|||
batchProcessingCount atomic.Int64
|
||||
batchFrameCount atomic.Int64
|
||||
batchProcessingTime atomic.Int64
|
||||
// Batch time tracking removed
|
||||
)
|
||||
|
||||
// GetBufferFromPool gets a buffer from the pool with at least the specified capacity
|
||||
|
@ -613,12 +610,12 @@ func cgoAudioDecodeWriteWithBuffers(opusData []byte, pcmBuffer []byte) (int, err
|
|||
|
||||
// Optimized CGO function aliases - use direct function calls to reduce overhead
|
||||
// These are now direct function aliases instead of variable assignments
|
||||
func CGOAudioInit() error { return cgoAudioInit() }
|
||||
func CGOAudioClose() { cgoAudioClose() }
|
||||
func CGOAudioReadEncode(buf []byte) (int, error) { return cgoAudioReadEncode(buf) }
|
||||
func CGOAudioPlaybackInit() error { return cgoAudioPlaybackInit() }
|
||||
func CGOAudioPlaybackClose() { cgoAudioPlaybackClose() }
|
||||
func CGOAudioDecodeWriteLegacy(buf []byte) (int, error) { return cgoAudioDecodeWrite(buf) }
|
||||
func CGOAudioInit() error { return cgoAudioInit() }
|
||||
func CGOAudioClose() { cgoAudioClose() }
|
||||
func CGOAudioReadEncode(buf []byte) (int, error) { return cgoAudioReadEncode(buf) }
|
||||
func CGOAudioPlaybackInit() error { return cgoAudioPlaybackInit() }
|
||||
func CGOAudioPlaybackClose() { cgoAudioPlaybackClose() }
|
||||
|
||||
func CGOAudioDecodeWrite(opusData []byte, pcmBuffer []byte) (int, error) {
|
||||
return cgoAudioDecodeWriteWithBuffers(opusData, pcmBuffer)
|
||||
}
|
||||
|
|
|
@ -70,9 +70,6 @@ func (aim *AudioInputManager) Stop() {
|
|||
|
||||
aim.logComponentStop(AudioInputManagerComponent)
|
||||
|
||||
// Flush any pending sampled metrics before stopping
|
||||
aim.flushPendingMetrics()
|
||||
|
||||
// Stop the IPC-based audio input
|
||||
aim.ipcManager.Stop()
|
||||
|
||||
|
@ -120,8 +117,6 @@ func (aim *AudioInputManager) WriteOpusFrame(frame []byte) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
aim.recordFrameProcessed(len(frame))
|
||||
aim.updateLatency(processingTime)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -164,8 +159,6 @@ func (aim *AudioInputManager) WriteOpusFrameZeroCopy(frame *ZeroCopyAudioFrame)
|
|||
|
||||
// Update metrics
|
||||
atomic.AddInt64(&aim.framesSent, 1)
|
||||
aim.recordFrameProcessed(frame.Length())
|
||||
aim.updateLatency(processingTime)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -59,12 +59,6 @@ func (bam *BaseAudioManager) resetMetrics() {
|
|||
bam.metrics.AverageLatency = 0
|
||||
}
|
||||
|
||||
// flushPendingMetrics is now a no-op since we use direct atomic updates
|
||||
func (bam *BaseAudioManager) flushPendingMetrics() {
|
||||
// No-op: metrics are now updated directly without local buffering
|
||||
// This function is kept for API compatibility
|
||||
}
|
||||
|
||||
// getBaseMetrics returns a copy of the base metrics
|
||||
func (bam *BaseAudioManager) getBaseMetrics() BaseAudioMetrics {
|
||||
return BaseAudioMetrics{
|
||||
|
@ -77,8 +71,6 @@ func (bam *BaseAudioManager) getBaseMetrics() BaseAudioMetrics {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// logComponentStart logs component start with consistent format
|
||||
func (bam *BaseAudioManager) logComponentStart(component string) {
|
||||
bam.logger.Debug().Str("component", component).Msg("starting component")
|
||||
|
|
|
@ -104,19 +104,11 @@ func (aom *AudioOutputIPCManager) WriteOpusFrame(frame *ZeroCopyAudioFrame) erro
|
|||
return fmt.Errorf("output frame validation failed: %w", err)
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
// Send frame to IPC server
|
||||
if err := aom.server.SendFrame(frame.Data()); err != nil {
|
||||
aom.recordFrameDropped()
|
||||
return err
|
||||
}
|
||||
|
||||
// Update metrics
|
||||
processingTime := time.Since(start)
|
||||
aom.recordFrameProcessed(frame.Length())
|
||||
aom.updateLatency(processingTime)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -130,22 +122,14 @@ func (aom *AudioOutputIPCManager) WriteOpusFrameZeroCopy(frame *ZeroCopyAudioFra
|
|||
return fmt.Errorf("audio output server not initialized")
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
// Extract frame data
|
||||
frameData := frame.Data()
|
||||
|
||||
// Send frame to IPC server (zero-copy not available, use regular send)
|
||||
if err := aom.server.SendFrame(frameData); err != nil {
|
||||
aom.recordFrameDropped()
|
||||
return err
|
||||
}
|
||||
|
||||
// Update metrics
|
||||
processingTime := time.Since(start)
|
||||
aom.recordFrameProcessed(len(frameData))
|
||||
aom.updateLatency(processingTime)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@ import (
|
|||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
// Removed unused AudioOutputStreamer struct - actual streaming uses direct functions
|
||||
|
||||
var (
|
||||
outputStreamingRunning int32
|
||||
outputStreamingCancel context.CancelFunc
|
||||
|
|
|
@ -17,8 +17,6 @@ const (
|
|||
AudioOutputSupervisorComponent = "audio-output-supervisor"
|
||||
)
|
||||
|
||||
|
||||
|
||||
// AudioOutputSupervisor manages the audio output server subprocess lifecycle
|
||||
type AudioOutputSupervisor struct {
|
||||
*BaseSupervisor
|
||||
|
|
|
@ -163,5 +163,4 @@ func RecordSocketBufferMetrics(conn net.Conn, component string) {
|
|||
}
|
||||
|
||||
// Socket buffer sizes recorded for debugging if needed
|
||||
// Removed detailed metrics as they weren't being used
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue