From 39a89b80e25eecb1fbe01f992c75074a5decb220 Mon Sep 17 00:00:00 2001 From: TonyChyi Date: Tue, 27 Sep 2022 12:32:23 +0800 Subject: [PATCH] debug needed --- servers/qemuserver/server.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/servers/qemuserver/server.go b/servers/qemuserver/server.go index 798b5e6..f5f0bf8 100644 --- a/servers/qemuserver/server.go +++ b/servers/qemuserver/server.go @@ -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) }