Fix: linter errors

This commit is contained in:
Alex P 2025-08-22 22:23:50 +00:00
parent 3c1e9b8dc2
commit 1e1677b35a
2 changed files with 42 additions and 42 deletions

View File

@ -16,9 +16,9 @@ import (
const (
inputMagicNumber uint32 = 0x4A4B4D49 // "JKMI" (JetKVM Microphone Input)
inputSocketName = "audio_input.sock"
maxFrameSize = 4096 // Maximum Opus frame size
maxFrameSize = 4096 // Maximum Opus frame size
writeTimeout = 5 * time.Millisecond // Non-blocking write timeout
maxDroppedFrames = 100 // Maximum consecutive dropped frames before reconnect
maxDroppedFrames = 100 // Maximum consecutive dropped frames before reconnect
)
// InputMessageType represents the type of IPC message
@ -62,10 +62,10 @@ type AudioInputServer struct {
running bool
// Triple-goroutine architecture
messageChan chan *InputIPCMessage // Buffered channel for incoming messages
processChan chan *InputIPCMessage // Buffered channel for processing queue
stopChan chan struct{} // Stop signal for all goroutines
wg sync.WaitGroup // Wait group for goroutine coordination
messageChan chan *InputIPCMessage // Buffered channel for incoming messages
processChan chan *InputIPCMessage // Buffered channel for processing queue
stopChan chan struct{} // Stop signal for all goroutines
wg sync.WaitGroup // Wait group for goroutine coordination
}
// NewAudioInputServer creates a new audio input server
@ -316,9 +316,9 @@ type AudioInputClient struct {
droppedFrames int64 // Atomic counter for dropped frames
totalFrames int64 // Atomic counter for total frames
conn net.Conn
mtx sync.Mutex
running bool
conn net.Conn
mtx sync.Mutex
running bool
}
// NewAudioInputClient creates a new audio input client
@ -644,7 +644,7 @@ func (ais *AudioInputServer) startMonitorGoroutine() {
}
}
adaptiveBuffering:
adaptiveBuffering:
// Adaptive buffer sizing based on processing time
avgTime := atomic.LoadInt64(&ais.processingTime)
currentSize := atomic.LoadInt64(&ais.bufferSize)

View File

@ -10,9 +10,9 @@ import (
// with reduced contention using atomic operations and conditional locking
type MicrophoneContentionManager struct {
// Atomic fields (must be 64-bit aligned on 32-bit systems)
lastOpNano int64 // Unix nanoseconds of last operation
cooldownNanos int64 // Cooldown duration in nanoseconds
operationID int64 // Incremental operation ID for tracking
lastOpNano int64 // Unix nanoseconds of last operation
cooldownNanos int64 // Cooldown duration in nanoseconds
operationID int64 // Incremental operation ID for tracking
// Lock-free state flags (using atomic.Pointer for lock-free updates)
lockPtr unsafe.Pointer // *sync.Mutex - conditionally allocated
@ -27,9 +27,9 @@ func NewMicrophoneContentionManager(cooldown time.Duration) *MicrophoneContentio
// OperationResult represents the result of attempting a microphone operation
type OperationResult struct {
Allowed bool
Allowed bool
RemainingCooldown time.Duration
OperationID int64
OperationID int64
}
// TryOperation attempts to perform a microphone operation with optimized contention handling
@ -46,9 +46,9 @@ func (mcm *MicrophoneContentionManager) TryOperation() OperationResult {
if atomic.CompareAndSwapInt64(&mcm.lastOpNano, lastOp, now) {
opID := atomic.AddInt64(&mcm.operationID, 1)
return OperationResult{
Allowed: true,
Allowed: true,
RemainingCooldown: 0,
OperationID: opID,
OperationID: opID,
}
}
}
@ -63,9 +63,9 @@ func (mcm *MicrophoneContentionManager) TryOperation() OperationResult {
if atomic.CompareAndSwapInt64(&mcm.lastOpNano, currentLastOp, now) {
opID := atomic.AddInt64(&mcm.operationID, 1)
return OperationResult{
Allowed: true,
Allowed: true,
RemainingCooldown: 0,
OperationID: opID,
OperationID: opID,
}
}
// If CAS failed, fall through to cooldown calculation
@ -79,9 +79,9 @@ func (mcm *MicrophoneContentionManager) TryOperation() OperationResult {
}
return OperationResult{
Allowed: false,
Allowed: false,
RemainingCooldown: remaining,
OperationID: atomic.LoadInt64(&mcm.operationID),
OperationID: atomic.LoadInt64(&mcm.operationID),
}
}