MCPcopy Index your code
hub / github.com/ebitengine/oto / newAudioQueue

Function newAudioQueue

driver_darwin.go:35–70  ·  view source on GitHub ↗
(sampleRate, channelCount int, oneBufferSizeInBytes int)

Source from the content-addressed store, hash-verified

33)
34
35func newAudioQueue(sampleRate, channelCount int, oneBufferSizeInBytes int) (_AudioQueueRef, []_AudioQueueBufferRef, error) {
36 desc := _AudioStreamBasicDescription{
37 mSampleRate: float64(sampleRate),
38 mFormatID: uint32(kAudioFormatLinearPCM),
39 mFormatFlags: uint32(kAudioFormatFlagIsFloat),
40 mBytesPerPacket: uint32(channelCount * float32SizeInBytes),
41 mFramesPerPacket: 1,
42 mBytesPerFrame: uint32(channelCount * float32SizeInBytes),
43 mChannelsPerFrame: uint32(channelCount),
44 mBitsPerChannel: uint32(8 * float32SizeInBytes),
45 }
46
47 var audioQueue _AudioQueueRef
48 if osstatus := _AudioQueueNewOutput(
49 &desc,
50 render,
51 nil,
52 0, //CFRunLoopRef
53 0, //CFStringRef
54 0,
55 &audioQueue); osstatus != noErr {
56 return 0, nil, fmt.Errorf("oto: AudioQueueNewFormat with StreamFormat failed: %d", osstatus)
57 }
58
59 bufs := make([]_AudioQueueBufferRef, 0, bufferCount)
60 for len(bufs) < cap(bufs) {
61 var buf _AudioQueueBufferRef
62 if osstatus := _AudioQueueAllocateBuffer(audioQueue, uint32(oneBufferSizeInBytes), &buf); osstatus != noErr {
63 return 0, nil, fmt.Errorf("oto: AudioQueueAllocateBuffer failed: %d", osstatus)
64 }
65 buf.mAudioDataByteSize = uint32(oneBufferSizeInBytes)
66 bufs = append(bufs, buf)
67 }
68
69 return audioQueue, bufs, nil
70}
71
72type context struct {
73 audioQueue _AudioQueueRef

Callers 1

newContextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…