mirror of https://github.com/jetkvm/kvm.git
Fix: audio subprocess handling, avg atency audio metric
This commit is contained in:
parent
62d4ec2f89
commit
3c1e9b8dc2
|
@ -38,13 +38,13 @@ type BatchAudioProcessor struct {
|
|||
|
||||
type BatchAudioStats struct {
|
||||
// int64 fields MUST be first for ARM32 alignment
|
||||
BatchedReads int64
|
||||
SingleReads int64
|
||||
BatchedFrames int64
|
||||
SingleFrames int64
|
||||
CGOCallsReduced int64
|
||||
OSThreadPinTime time.Duration // time.Duration is int64 internally
|
||||
LastBatchTime time.Time
|
||||
BatchedReads int64
|
||||
SingleReads int64
|
||||
BatchedFrames int64
|
||||
SingleFrames int64
|
||||
CGOCallsReduced int64
|
||||
OSThreadPinTime time.Duration // time.Duration is int64 internally
|
||||
LastBatchTime time.Time
|
||||
}
|
||||
|
||||
type batchReadRequest struct {
|
||||
|
@ -153,8 +153,6 @@ func (bap *BatchAudioProcessor) BatchReadEncode(buffer []byte) (int, error) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// batchReadProcessor processes batched read operations
|
||||
func (bap *BatchAudioProcessor) batchReadProcessor() {
|
||||
defer bap.logger.Debug().Msg("batch read processor stopped")
|
||||
|
@ -191,8 +189,6 @@ func (bap *BatchAudioProcessor) batchReadProcessor() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// processBatchRead processes a batch of read requests efficiently
|
||||
func (bap *BatchAudioProcessor) processBatchRead(batch []batchReadRequest) {
|
||||
if len(batch) == 0 {
|
||||
|
@ -236,8 +232,6 @@ func (bap *BatchAudioProcessor) processBatchRead(batch []batchReadRequest) {
|
|||
bap.stats.LastBatchTime = time.Now()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GetStats returns current batch processor statistics
|
||||
func (bap *BatchAudioProcessor) GetStats() BatchAudioStats {
|
||||
return BatchAudioStats{
|
||||
|
@ -258,7 +252,7 @@ func (bap *BatchAudioProcessor) IsRunning() bool {
|
|||
|
||||
// Global batch processor instance
|
||||
var (
|
||||
globalBatchProcessor unsafe.Pointer // *BatchAudioProcessor
|
||||
globalBatchProcessor unsafe.Pointer // *BatchAudioProcessor
|
||||
batchProcessorInitialized int32
|
||||
)
|
||||
|
||||
|
@ -308,4 +302,4 @@ func BatchCGOAudioReadEncode(buffer []byte) (int, error) {
|
|||
return processor.BatchReadEncode(buffer)
|
||||
}
|
||||
return CGOAudioReadEncode(buffer)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,4 +65,4 @@ func GetAudioControlBuffer() []byte {
|
|||
// PutAudioControlBuffer returns a buffer to the control pool
|
||||
func PutAudioControlBuffer(buf []byte) {
|
||||
audioControlPool.Put(buf)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package audio
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -286,7 +287,7 @@ func (aeb *AudioEventBroadcaster) startMetricsBroadcasting() {
|
|||
BytesProcessed: audioMetrics.BytesProcessed,
|
||||
LastFrameTime: audioMetrics.LastFrameTime.Format("2006-01-02T15:04:05.000Z"),
|
||||
ConnectionDrops: audioMetrics.ConnectionDrops,
|
||||
AverageLatency: audioMetrics.AverageLatency.String(),
|
||||
AverageLatency: fmt.Sprintf("%.1fms", float64(audioMetrics.AverageLatency.Nanoseconds())/1e6),
|
||||
},
|
||||
}
|
||||
aeb.broadcast(audioMetricsEvent)
|
||||
|
@ -304,7 +305,7 @@ func (aeb *AudioEventBroadcaster) startMetricsBroadcasting() {
|
|||
BytesProcessed: micMetrics.BytesProcessed,
|
||||
LastFrameTime: micMetrics.LastFrameTime.Format("2006-01-02T15:04:05.000Z"),
|
||||
ConnectionDrops: micMetrics.ConnectionDrops,
|
||||
AverageLatency: micMetrics.AverageLatency.String(),
|
||||
AverageLatency: fmt.Sprintf("%.1fms", float64(micMetrics.AverageLatency.Nanoseconds())/1e6),
|
||||
},
|
||||
}
|
||||
aeb.broadcast(micMetricsEvent)
|
||||
|
|
|
@ -154,7 +154,6 @@ func (aim *AudioInputIPCManager) GetDetailedMetrics() (AudioInputMetrics, map[st
|
|||
// Get server statistics if available
|
||||
serverStats := make(map[string]interface{})
|
||||
if aim.supervisor.IsRunning() {
|
||||
|
||||
serverStats["status"] = "running"
|
||||
} else {
|
||||
serverStats["status"] = "stopped"
|
||||
|
|
Loading…
Reference in New Issue