This commit is contained in:
Nonoo 2020-10-30 17:25:09 +01:00
parent 5435fb600c
commit 218c37f1f2

View file

@ -126,7 +126,7 @@ func (a *audioStruct) playLoopToDefaultSoundcard(deinitNeededChan, deinitFinishe
} }
} }
func (a *audioStruct) playLoop(deinitNeededChan, deinitFinishedChan chan bool) { func (a *audioStruct) playLoopToVirtualSoundcard(deinitNeededChan, deinitFinishedChan chan bool) {
for { for {
select { select {
case <-a.virtualSoundcardStream.canPlay: case <-a.virtualSoundcardStream.canPlay:
@ -219,10 +219,11 @@ func (a *audioStruct) recLoop(deinitNeededChan, deinitFinishedChan chan bool) {
func (a *audioStruct) loop() { func (a *audioStruct) loop() {
playLoopDeinitNeededChan := make(chan bool) playLoopDeinitNeededChan := make(chan bool)
playLoopDeinitFinishedChan := make(chan bool) playLoopDeinitFinishedChan := make(chan bool)
go a.playLoop(playLoopDeinitNeededChan, playLoopDeinitFinishedChan) go a.playLoopToVirtualSoundcard(playLoopDeinitNeededChan, playLoopDeinitFinishedChan)
playLoopToDefaultSoundcardDeinitNeededChan := make(chan bool) playLoopToDefaultSoundcardDeinitNeededChan := make(chan bool)
playLoopToDefaultSoundcardDeinitFinishedChan := make(chan bool) playLoopToDefaultSoundcardDeinitFinishedChan := make(chan bool)
go a.playLoopToDefaultSoundcard(playLoopToDefaultSoundcardDeinitNeededChan, playLoopToDefaultSoundcardDeinitFinishedChan) go a.playLoopToDefaultSoundcard(playLoopToDefaultSoundcardDeinitNeededChan, playLoopToDefaultSoundcardDeinitFinishedChan)
recLoopDeinitNeededChan := make(chan bool) recLoopDeinitNeededChan := make(chan bool)
recLoopDeinitFinishedChan := make(chan bool) recLoopDeinitFinishedChan := make(chan bool)
go a.recLoop(recLoopDeinitNeededChan, recLoopDeinitFinishedChan) go a.recLoop(recLoopDeinitNeededChan, recLoopDeinitFinishedChan)
@ -342,13 +343,15 @@ func (a *audioStruct) initIfNeeded(devName string) error {
if a.virtualSoundcardStream.playBuf == nil { if a.virtualSoundcardStream.playBuf == nil {
log.Print("opened device " + a.virtualSoundcardStream.source.Name) log.Print("opened device " + a.virtualSoundcardStream.source.Name)
a.play = make(chan []byte)
a.rec = make(chan []byte)
a.virtualSoundcardStream.playBuf = bytes.NewBuffer([]byte{}) a.virtualSoundcardStream.playBuf = bytes.NewBuffer([]byte{})
a.defaultSoundcardStream.playBuf = bytes.NewBuffer([]byte{}) a.defaultSoundcardStream.playBuf = bytes.NewBuffer([]byte{})
a.play = make(chan []byte)
a.virtualSoundcardStream.canPlay = make(chan bool) a.virtualSoundcardStream.canPlay = make(chan bool)
a.defaultSoundcardStream.canPlay = make(chan bool) a.defaultSoundcardStream.canPlay = make(chan bool)
a.rec = make(chan []byte)
a.defaultSoundcardStream.togglePlaybackChan = make(chan bool) a.defaultSoundcardStream.togglePlaybackChan = make(chan bool)
a.deinitNeededChan = make(chan bool) a.deinitNeededChan = make(chan bool)
a.deinitFinishedChan = make(chan bool) a.deinitFinishedChan = make(chan bool)
go a.loop() go a.loop()