debug needed

This commit is contained in:
TonyChyi 2022-09-27 12:32:23 +08:00
parent 18f5d649d1
commit 39a89b80e2

View File

@ -125,6 +125,16 @@ func (s *Server) Run() error {
}
func (s *Server) startCapture() {
const waveHeaderSize = 16
waveHeader := &audiodriver.WavHeader{
Size: waveHeaderSize,
AudioFormat: 1,
NumChannels: 2,
SampleRate: 44100,
BlockAlign: 4,
BitsPerSample: 16,
}
go func() {
f, err := os.Open(s.options.AudioPipe)
if err != nil {
@ -134,16 +144,13 @@ func (s *Server) startCapture() {
logrus.Debug("start reading from fifo")
waveHeader, err := audiodriver.NewHeader(f)
if err != nil {
logrus.Fatal(err)
}
logrus.Debug(waveHeader)
s.audioHeader <- waveHeader
close(s.audioHeader) // only once
// skip riff data chunk ID and size, 8 bytes
var _dataChunkHeader [audiodriver.DataChunkIDSize + audiodriver.DataChunkSizeSize]byte
// skip to pcm data, for 44 bytes.
var _dataChunkHeader [audiodriver.FmtHeaderOffset +
audiodriver.FmtHeaderIDSize + audiodriver.FmtHeaderChunkSizeSize + waveHeaderSize +
audiodriver.DataChunkIDSize + audiodriver.DataChunkSizeSize]byte
if _, err := f.Read(_dataChunkHeader[:]); err != nil {
logrus.Fatal(err)
}