remove xorg ValidScreenSize double checking.

This commit is contained in:
Miroslav Šedivý 2020-10-30 19:32:52 +01:00
parent dc32e64190
commit b4a233ef2e
2 changed files with 6 additions and 29 deletions

View File

@ -53,9 +53,7 @@ func (manager *RemoteManager) Start() {
Str("screen_resolution", fmt.Sprintf("%dx%d@%d", manager.config.ScreenWidth, manager.config.ScreenHeight, manager.config.ScreenRate)). Str("screen_resolution", fmt.Sprintf("%dx%d@%d", manager.config.ScreenWidth, manager.config.ScreenHeight, manager.config.ScreenRate)).
Msgf("Setting screen resolution...") Msgf("Setting screen resolution...")
if !xorg.ValidScreenSize(manager.config.ScreenWidth, manager.config.ScreenHeight, manager.config.ScreenRate) { if err := xorg.ChangeScreenSize(manager.config.ScreenWidth, manager.config.ScreenHeight, manager.config.ScreenRate); err != nil {
manager.logger.Warn().Msgf("invalid screen option %dx%d@%d", manager.config.ScreenWidth, manager.config.ScreenHeight, manager.config.ScreenRate)
} else if err := xorg.ChangeScreenSize(manager.config.ScreenWidth, manager.config.ScreenHeight, manager.config.ScreenRate); err != nil {
manager.logger.Warn().Err(err).Msg("unable to change screen size") manager.logger.Warn().Err(err).Msg("unable to change screen size")
} }
@ -167,26 +165,19 @@ func (manager *RemoteManager) createAudioPipeline() {
} }
func (manager *RemoteManager) ChangeResolution(width int, height int, rate int) error { func (manager *RemoteManager) ChangeResolution(width int, height int, rate int) error {
if !xorg.ValidScreenSize(width, height, rate) {
return fmt.Errorf("unknown configuration")
}
manager.video.DestroyPipeline() manager.video.DestroyPipeline()
manager.broadcast.Stop() manager.broadcast.Stop()
defer func() { defer func() {
manager.createVideoPipeline()
manager.video.Start() manager.video.Start()
manager.broadcast.Start() manager.broadcast.Start()
manager.logger.Info().Msg("starting video pipeline...") manager.logger.Info().Msg("starting video pipeline...")
}() }()
if err := xorg.ChangeScreenSize(width, height, rate); err != nil { return xorg.ChangeScreenSize(width, height, rate)
return err
}
manager.createVideoPipeline()
return nil
} }
func (manager *RemoteManager) Move(x, y int) { func (manager *RemoteManager) Move(x, y int) {

View File

@ -165,20 +165,6 @@ func CheckKeys(duration time.Duration) {
} }
} }
func ValidScreenSize(width int, height int, rate int) bool {
for _, size := range ScreenConfigurations {
if size.Width == width && size.Height == height {
for _, fps := range size.Rates {
if int16(rate) == fps {
return true
}
}
}
}
return false
}
func ChangeScreenSize(width int, height int, rate int) error { func ChangeScreenSize(width int, height int, rate int) error {
mu.Lock() mu.Lock()
defer mu.Unlock() defer mu.Unlock()
@ -194,7 +180,7 @@ func ChangeScreenSize(width int, height int, rate int) error {
} }
} }
return fmt.Errorf("unknown configuration") return fmt.Errorf("Unknown screen configuration %dx%d@%d.", width, height, rate)
} }
func GetScreenSize() *types.ScreenSize { func GetScreenSize() *types.ScreenSize {