mirror of https://github.com/jetkvm/kvm.git
fix: stop video stream before enabling sleep mode
This commit is contained in:
parent
79cb2aa5ef
commit
24ec74a441
|
|
@ -539,6 +539,7 @@ void *run_video_stream(void *arg)
|
|||
if (r == 0)
|
||||
{
|
||||
log_info("select timeout");
|
||||
ensure_sleep_mode_disabled();
|
||||
break;
|
||||
}
|
||||
if (r == -1)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,13 @@ func (n *Native) setSleepMode(enabled bool) error {
|
|||
bEnabled := "0"
|
||||
if enabled {
|
||||
bEnabled = "1"
|
||||
if err := n.VideoStop(); err != nil {
|
||||
return fmt.Errorf("video stop failed, won't enable sleep mode: %w", err)
|
||||
}
|
||||
// wait few seconds to ensure the video stream is stopped
|
||||
time.Sleep(3 * time.Second)
|
||||
}
|
||||
|
||||
return os.WriteFile(sleepModeFile, []byte(bEnabled), 0644)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue