(sampleRate, channelCount int, oneBufferSizeInBytes int)
| 33 | ) |
| 34 | |
| 35 | func 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 | |
| 72 | type context struct { |
| 73 | audioQueue _AudioQueueRef |
no outgoing calls
no test coverage detected
searching dependent graphs…