join GetScreenSizeChangeChannel.
This commit is contained in:
parent
6e62b796fc
commit
f3080713ce
@ -55,12 +55,15 @@ func (manager *CaptureManagerCtx) Start() {
|
||||
|
||||
go func() {
|
||||
for {
|
||||
_, ok := <-manager.desktop.GetBeforeScreenSizeChangeChannel()
|
||||
before, ok := <-manager.desktop.GetScreenSizeChangeChannel()
|
||||
if !ok {
|
||||
manager.logger.Info().Msg("before screen size change channel was closed")
|
||||
manager.logger.Info().Msg("screen size change channel was closed")
|
||||
return
|
||||
}
|
||||
|
||||
if before {
|
||||
// before screen size change, we need to destroy all pipelines
|
||||
|
||||
if manager.video.Started() {
|
||||
manager.video.destroyPipeline()
|
||||
}
|
||||
@ -68,16 +71,8 @@ func (manager *CaptureManagerCtx) Start() {
|
||||
if manager.broadcast.Started() {
|
||||
manager.broadcast.destroyPipeline()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
_, ok := <-manager.desktop.GetAfterScreenSizeChangeChannel()
|
||||
if !ok {
|
||||
manager.logger.Info().Msg("after screen size change channel was closed")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// after screen size change, we need to recreate all pipelines
|
||||
|
||||
if manager.video.Started() {
|
||||
err := manager.video.createPipeline()
|
||||
@ -93,6 +88,7 @@ func (manager *CaptureManagerCtx) Start() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
|
@ -19,18 +19,18 @@ type DesktopManagerCtx struct {
|
||||
logger zerolog.Logger
|
||||
wg sync.WaitGroup
|
||||
shutdown chan struct{}
|
||||
beforeScreenSizeChangeChannel chan bool
|
||||
afterScreenSizeChangeChannel chan int16
|
||||
config *config.Desktop
|
||||
|
||||
screenSizeChangeChannel chan bool
|
||||
}
|
||||
|
||||
func New(config *config.Desktop) *DesktopManagerCtx {
|
||||
return &DesktopManagerCtx{
|
||||
logger: log.With().Str("module", "desktop").Logger(),
|
||||
shutdown: make(chan struct{}),
|
||||
beforeScreenSizeChangeChannel: make(chan bool),
|
||||
afterScreenSizeChangeChannel: make(chan int16),
|
||||
config: config,
|
||||
|
||||
screenSizeChangeChannel: make(chan bool),
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,18 +84,15 @@ func (manager *DesktopManagerCtx) Start() {
|
||||
}()
|
||||
}
|
||||
|
||||
func (manager *DesktopManagerCtx) GetBeforeScreenSizeChangeChannel() chan bool {
|
||||
return manager.beforeScreenSizeChangeChannel
|
||||
}
|
||||
|
||||
func (manager *DesktopManagerCtx) GetAfterScreenSizeChangeChannel() chan int16 {
|
||||
return manager.afterScreenSizeChangeChannel
|
||||
func (manager *DesktopManagerCtx) GetScreenSizeChangeChannel() chan bool {
|
||||
return manager.screenSizeChangeChannel
|
||||
}
|
||||
|
||||
func (manager *DesktopManagerCtx) Shutdown() error {
|
||||
manager.logger.Info().Msgf("desktop shutting down")
|
||||
|
||||
close(manager.shutdown)
|
||||
close(manager.screenSizeChangeChannel)
|
||||
manager.wg.Wait()
|
||||
|
||||
xorg.DisplayClose()
|
||||
|
@ -72,10 +72,10 @@ func (manager *DesktopManagerCtx) ScreenConfigurations() map[int]types.ScreenCon
|
||||
|
||||
func (manager *DesktopManagerCtx) SetScreenSize(size types.ScreenSize) error {
|
||||
mu.Lock()
|
||||
manager.GetBeforeScreenSizeChangeChannel() <- true
|
||||
manager.GetScreenSizeChangeChannel() <- true
|
||||
|
||||
defer func() {
|
||||
manager.GetAfterScreenSizeChangeChannel() <- size.Rate
|
||||
manager.GetScreenSizeChangeChannel() <- false
|
||||
mu.Unlock()
|
||||
}()
|
||||
|
||||
|
@ -43,8 +43,7 @@ type DesktopErrorMessage struct {
|
||||
type DesktopManager interface {
|
||||
Start()
|
||||
Shutdown() error
|
||||
GetBeforeScreenSizeChangeChannel() chan bool
|
||||
GetAfterScreenSizeChangeChannel() chan int16
|
||||
GetScreenSizeChangeChannel() (before chan bool) // true - before, false - after
|
||||
|
||||
// clipboard
|
||||
ReadClipboard() string
|
||||
@ -73,8 +72,6 @@ type DesktopManager interface {
|
||||
|
||||
// xevent
|
||||
GetCursorChangedChannel() chan uint64
|
||||
GetClipboardUpdatedChannel() chan bool
|
||||
GetFileChooserDialogOpenedChannel() chan bool
|
||||
GetFileChooserDialogClosedChannel() chan bool
|
||||
GetClipboardUpdatedChannel() chan struct{}
|
||||
GetEventErrorChannel() chan DesktopErrorMessage
|
||||
}
|
||||
|
Reference in New Issue
Block a user