Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minimal CoreAudio line in example
#include <CoreAudio/CoreAudio.h>
#include <AudioToolbox/AudioToolbox.h>
#include <iostream>
static const int kNumberBuffers = 3;
static const int kBufferByteSize = 8192;
void callback (void *userData, AudioQueueRef queue, AudioQueueBufferRef buffer, const AudioTimeStamp *startTime, UInt32 inumberPacketDescriptions, const AudioStreamPacketDescription *packetDescs) {
OSStatus status;
std::cout << buffer->mAudioDataBytesCapacity << std::endl;
status = AudioQueueEnqueueBuffer(queue, buffer, 0, nullptr);
if (status != 0) exit(5);
}
int main() {
OSStatus status;
AudioStreamBasicDescription desc;
desc.mSampleRate = 44100;
desc.mFormatID = kAudioFormatLinearPCM;
desc.mFormatFlags = kAudioFormatFlagIsSignedInteger;
desc.mBytesPerPacket = 0;
desc.mFramesPerPacket = 1;
desc.mBytesPerFrame = 0;
desc.mChannelsPerFrame = 2;
desc.mBitsPerChannel = 16;
desc.mReserved = 0;
AudioQueueRef queue;
status = AudioQueueNewInput(&desc, callback, nullptr, nullptr, nullptr, 0, &queue);
if (status != 0) return 1;
status = AudioQueueStart(queue, nullptr);
if (status != 0) return 2;
for (int i = 0; i < kNumberBuffers; ++i) {
AudioQueueBufferRef buffer;
status = AudioQueueAllocateBuffer(queue, kBufferByteSize, &buffer);
if (status != 0) return 3;
status = AudioQueueEnqueueBuffer(queue, buffer, 0, nullptr);
if (status != 0) return 4;
}
getchar();
return 0;
}
line-in:
clang++ darwin.cc -framework AudioToolBox -framework CoreFoundation -o line-in
@amit-bst

This comment has been minimized.

Copy link

commented Apr 11, 2019

This gives [aqme] 318: error -66680 finding/initializing AQDefaultInput

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.