to be continued

This commit is contained in:
TonyChyi
2022-10-10 19:12:26 +08:00
parent 4844944c37
commit 07d3ae3717
6 changed files with 28 additions and 8 deletions

View File

@@ -68,12 +68,14 @@ func (w *PCMStreamDriver) AudioRecord(p prop.Media) (audio.Reader, error) {
reader := func() (wave.Audio, func(), error) {
a := wave.NewInt16Interleaved(chunkInfo)
ticker := time.NewTicker(p.Latency)
defer ticker.Stop()
select {
case <-w.closed:
return nil, func() {}, io.EOF
case pcmData := <-w.PCM:
copy(a.Data, bytesTo16BitSamples(pcmData[:]))
case <-time.After(p.Latency):
case <-ticker.C:
// no stuck
}
return a, func() {}, nil