v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-17 08:10:22 -07:00
eeeXun cbd985b599 refactor: make Language, TTSLock and EngineName to struct in Translator
GetSrcLang, GetDstLang, SetSrcLang, SetDstLang, SwapLang are reusable
functions from translator to translator. So make Language struct.

GetEngineName is also a reusable function. So make EngineName struct.

Finally, let Translator to inherit those functions in these three
(Language, TTSLock, EngineName) structs. No need to write the duplicated
functions for each Translator.
2023-03-10 23:37:08 +08:00

36 lines
489 B
Go

package core
type TTSLock struct {
stop bool
threadCount int8
}
func NewTTSLock() *TTSLock {
return &TTSLock{
stop: true,
threadCount: 0,
}
}
func (l *TTSLock) LockAvailable() bool {
return l.stop && l.threadCount == 0
}
func (l *TTSLock) AcquireLock() {
l.stop = false
l.threadCount++
}
func (l *TTSLock) IsStopped() bool {
return l.stop
}
func (l *TTSLock) StopTTS() {
l.stop = true
}
func (l *TTSLock) ReleaseLock() {
l.stop = true
l.threadCount--
}