From 55975b0e5fe26e3bf5af57de28cd8bbe1d061f46 Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Mon, 21 Mar 2016 11:31:30 +0100 Subject: [PATCH] make it build --- .gitignore | 1 + Makefile | 11 +++++++++-- coreaudio_example.cc | 12 ++++++------ coreaudio_example_main.cc | 1 + 4 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 .gitignore create mode 100644 coreaudio_example_main.cc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..33a9488 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +example diff --git a/Makefile b/Makefile index 35bea16..28e2037 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,9 @@ -all: - clang++ -std=c++11 -stdlib=libc++ coreaudio_example.cc +all: example + +example: + clang++ -std=c++11 -stdlib=libc++ -Wl,-framework,CoreAudio -Wl,-framework,AudioUnit coreaudio_example.cc coreaudio_example_main.cc -o example + +clean: + rm -rf example + +PHONY: clean diff --git a/coreaudio_example.cc b/coreaudio_example.cc index cdae6f2..f688bd4 100644 --- a/coreaudio_example.cc +++ b/coreaudio_example.cc @@ -109,7 +109,7 @@ bool init (void) void cleanup (void) { - AudioUnitInstanceDispose (output_instance); + AudioComponentInstanceDispose (output_instance); } /* @@ -146,12 +146,12 @@ bool open_audio (int format, int rate, int chan, AURenderCallbackStruct * callba AudioStreamBasicDescription streamFormat; streamFormat.mSampleRate = rate; streamFormat.mFormatID = kAudioFormatLinearPCM; - streamFormat.mFormatFlags = m->mFormatFlags; + streamFormat.mFormatFlags = m->flags; streamFormat.mFramesPerPacket = 1; streamFormat.mChannelsPerFrame = chan; - streamFormat.mBitsPerChannel = m->mBitsPerChannel; - streamFormat.mBytesPerPacket = chan * buffer_bytes_per_channel; - streamFormat.mBytesPerFrame = chan * buffer_bytes_per_channel; + streamFormat.mBitsPerChannel = m->bits_per_sample; + streamFormat.mBytesPerPacket = chan * m->bytes_per_sample; + streamFormat.mBytesPerFrame = chan * m->bytes_per_sample; printf ("Stream format:\n"); printf (" Channels: %d\n", streamFormat.mChannelsPerFrame); @@ -173,7 +173,7 @@ bool open_audio (int format, int rate, int chan, AURenderCallbackStruct * callba if (AudioOutputUnitStart (output_instance)) { - fprintf ("Unable to start audio unit.\n"); + printf ("Unable to start audio unit.\n"); return false; } diff --git a/coreaudio_example_main.cc b/coreaudio_example_main.cc new file mode 100644 index 0000000..76e8197 --- /dev/null +++ b/coreaudio_example_main.cc @@ -0,0 +1 @@ +int main() { return 0; }