Gui #2
+48
-19
@@ -534,13 +534,20 @@ func main() {
|
|||||||
sdl.SetWindowFullscreen(windowHandler, true)
|
sdl.SetWindowFullscreen(windowHandler, true)
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
fps float64
|
||||||
lastIndex uint64
|
lastIndex uint64
|
||||||
dropped uint64
|
dropped uint64
|
||||||
frameCount uint64
|
frameCount uint64
|
||||||
lastReport time.Time
|
lastReport time.Time
|
||||||
lastFrame time.Time
|
lastFrame time.Time
|
||||||
|
// ImGui stats
|
||||||
|
domainStr string = args.Domain
|
||||||
|
videoStr string = args.VideoFlowId
|
||||||
|
audioStr string = args.AudioFlowId
|
||||||
|
showStats bool = true
|
||||||
)
|
)
|
||||||
lastFrame = time.Now()
|
lastFrame = time.Now()
|
||||||
|
|
||||||
for running {
|
for running {
|
||||||
frameStart := time.Now()
|
frameStart := time.Now()
|
||||||
var event [128]byte
|
var event [128]byte
|
||||||
@@ -560,6 +567,8 @@ func main() {
|
|||||||
fullscreen = !fullscreen
|
fullscreen = !fullscreen
|
||||||
sdl.SetWindowFullscreen(windowHandler, fullscreen)
|
sdl.SetWindowFullscreen(windowHandler, fullscreen)
|
||||||
resized = true
|
resized = true
|
||||||
|
case sdl.KeyF1:
|
||||||
|
showStats = !showStats
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gui.ProcessEvent(&event)
|
gui.ProcessEvent(&event)
|
||||||
@@ -600,12 +609,48 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stats
|
||||||
|
if lastIndex != 0 && shownIndex > lastIndex {
|
||||||
|
if g := shownIndex - lastIndex - 1; g > 0 {
|
||||||
|
dropped += g
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastIndex = shownIndex
|
||||||
|
frameCount++
|
||||||
|
if now := time.Now(); now.Sub(lastReport) >= time.Second {
|
||||||
|
dt := now.Sub(lastReport).Seconds()
|
||||||
|
fps = float64(frameCount) / dt
|
||||||
|
fmt.Printf("fps=%.1f dropped=%d idx=%d frameTime=%.2fms\n",
|
||||||
|
fps, dropped, shownIndex, float64(now.Sub(frameStart).Microseconds())/1000.0)
|
||||||
|
frameCount = 0
|
||||||
|
dropped = 0
|
||||||
|
lastReport = now
|
||||||
|
}
|
||||||
|
// end of stats
|
||||||
if r != nil {
|
if r != nil {
|
||||||
gui.BeginFrame(time.Since(lastFrame), int32(r.Extent().Width), int32(r.Extent().Height))
|
gui.BeginFrame(time.Since(lastFrame), int32(r.Extent().Width), int32(r.Extent().Height))
|
||||||
// test widget
|
// test widget
|
||||||
cimgui.Begin("Test")
|
// cimgui.Begin("Test")
|
||||||
imguiLabel := fmt.Sprintf("%dx%d", 1920, 1080)
|
if showStats {
|
||||||
cimgui.SeparatorText(imguiLabel)
|
cimgui.SetNextWindowPos(cimgui.Vec2{X: 10, Y: 10})
|
||||||
|
cimgui.SetNextWindowSize(cimgui.Vec2{X: 300, Y: 300})
|
||||||
|
cimgui.BeginV("Stats", &showStats,
|
||||||
|
cimgui.WindowFlagsNoTitleBar|cimgui.WindowFlagsNoBackground|cimgui.WindowFlagsNoResize|cimgui.WindowFlagsNoScrollbar)
|
||||||
|
cimgui.Text(fmt.Sprintf("FPS: %.1f", fps))
|
||||||
|
cimgui.Text(fmt.Sprintf("Dropped: %d", dropped))
|
||||||
|
cimgui.Text(fmt.Sprintf("Index: %d", shownIndex))
|
||||||
|
if syncSrc != nil {
|
||||||
|
cimgui.Text(fmt.Sprintf("Video: %dx%d %.2fp", syncSrc.Width(), syncSrc.Height(),
|
||||||
|
float32(syncSrc.Rate().Num/syncSrc.AudioRate().Den)))
|
||||||
|
cimgui.Text(fmt.Sprintf("Audio: %dch %dkHz", syncSrc.Channels(), syncSrc.AudioRate().Num))
|
||||||
|
}
|
||||||
|
cimgui.End()
|
||||||
|
}
|
||||||
|
cimgui.Begin("Connection")
|
||||||
|
cimgui.InputTextWithHint("Domain", "/dev/shm/mxl", &domainStr, 0, nil)
|
||||||
|
cimgui.InputTextWithHint("Video UUID", "", &videoStr, 0, nil)
|
||||||
|
cimgui.InputTextWithHint("Audio UUID", "", &audioStr, 0, nil)
|
||||||
|
cimgui.Checkbox("Show stats", &showStats)
|
||||||
cimgui.End()
|
cimgui.End()
|
||||||
gui.EndFrame()
|
gui.EndFrame()
|
||||||
lastFrame = time.Now()
|
lastFrame = time.Now()
|
||||||
@@ -631,22 +676,6 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastIndex != 0 && shownIndex > lastIndex {
|
|
||||||
if g := shownIndex - lastIndex - 1; g > 0 {
|
|
||||||
dropped += g
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lastIndex = shownIndex
|
|
||||||
frameCount++
|
|
||||||
if now := time.Now(); now.Sub(lastReport) >= time.Second {
|
|
||||||
dt := now.Sub(lastReport).Seconds()
|
|
||||||
fps := float64(frameCount) / dt
|
|
||||||
fmt.Printf("fps=%.1f dropped=%d idx=%d frameTime=%.2fms\n",
|
|
||||||
fps, dropped, shownIndex, float64(now.Sub(frameStart).Microseconds())/1000.0)
|
|
||||||
frameCount = 0
|
|
||||||
dropped = 0
|
|
||||||
lastReport = now
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,17 @@ Size=400,400
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Test]
|
[Window][Test]
|
||||||
Pos=352,204
|
Pos=60,60
|
||||||
Size=554,180
|
Size=251,92
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Stats]
|
||||||
|
Pos=10,10
|
||||||
|
Size=300,300
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Connection]
|
||||||
|
Pos=676,497
|
||||||
|
Size=413,137
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ const (
|
|||||||
|
|
||||||
KeyEscape uint32 = 0x1B
|
KeyEscape uint32 = 0x1B
|
||||||
KeyF uint32 = 0x66
|
KeyF uint32 = 0x66
|
||||||
|
KeyF1 uint32 = 0x4000003A
|
||||||
|
|
||||||
InitAudio uint32 = 0x00000010
|
InitAudio uint32 = 0x00000010
|
||||||
AudioDeviceDefaultPlayback uint32 = 0xFFFFFFFF
|
AudioDeviceDefaultPlayback uint32 = 0xFFFFFFFF
|
||||||
|
|||||||
Reference in New Issue
Block a user