USB audio device unplugged and replug, make program block at speaker.Init
microidea opened this issue · 0 comments
microidea commented
I have an USB audio device which has poor contact, when replugged I have to call speaker.Init() again to make the speaker work again.
But it's stuck at here:
Line 129 in 98afada
Since it's in a for loop, the whole loop is blocked:
Lines 48 to 57 in 98afada
the done channel cannot be consumed, when I call speaker.Init again, it calls speaker.Close first, then it's stuck at here:
Line 69 in 98afada
As a result when my USB audio device replugged I cannot call speaker.Init() again, it's always stuck.
So right now I change the done channel into a buffered chan, it looks good so far, but I'm not sure whether it will cause other problem.
Is it necessary to make the done channel an unbuffered chan? How to handle the replug situation properly?