Skip to content

Distorted audio capture on linux. #500

@dezi

Description

@dezi

The problem is in pkg/driver/microphone/microphone.go lines 133...

onRecvChunk := func(_, chunk []byte, framecount uint32) {
	select {
	case <-cancelCtx.Done():
	case m.chunkChan <- chunk:
	}
}

Callback function of malgo audio capture. The chunk buffer is send to channel.
Malgo will reuse the buffer while it is beeing processed.

You have to make a copy of chunk before sending it to the channel.

onRecvChunk := func(_, chunk []byte, framecount uint32) {
	newChunk := make([]byte, len(chunk))
	copy(newChunk, chunk)
	select {
	case <-cancelCtx.Done():
	case m.chunkChan <- newChunk:
	}
}

Please fix.
Regards,
dezi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions