[sink_wavwrite] check fseek and fwrite return values
[aubio.git] / src / io / audio_unit.c
index c935b26..2674388 100644 (file)
@@ -18,9 +18,8 @@
 
 */
 
-#include "config.h"
-#ifdef TARGET_OS_IPHONE
 #include "aubio_priv.h"
+#ifdef HAVE_AUDIO_UNIT
 
 #include "fvec.h"
 #include "fmat.h"
@@ -104,8 +103,8 @@ aubio_audio_unit_t * new_aubio_audio_unit(uint_t samplerate,
   o->au_ios_inbuf = AUBIO_ARRAY(SInt16, AU_IOS_MAX_FRAMES * o->hw_input_channels);
 
   /* the floats coming from and to the device callback */
-  o->output_frames = new_fmat(blocksize, sw_output_channels);
-  o->input_frames = new_fmat(blocksize, sw_input_channels);
+  o->output_frames = new_fmat(sw_output_channels, blocksize);
+  o->input_frames = new_fmat(sw_input_channels, blocksize);
 
   /* check for some sizes */
   if ( o->hw_output_channels != o->output_frames->height ) {
@@ -233,14 +232,14 @@ sint_t aubio_audio_unit_init (aubio_audio_unit_t *o)
   audioFormat.mSampleRate = (Float64)samplerate;
   audioFormat.mChannelsPerFrame = 2;
   audioFormat.mFormatID = kAudioFormatLinearPCM;
-  audioFormat.mFormatFlags = kAudioFormatFlagsCanonical;
+  audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;
   audioFormat.mFramesPerPacket = 1;
-  audioFormat.mBitsPerChannel = 8 * sizeof(AudioSampleType);
+  audioFormat.mBitsPerChannel = 8 * sizeof(SInt16);
 #if 1  // interleaving
-  audioFormat.mBytesPerFrame = 2 * sizeof(AudioSampleType);
-  audioFormat.mBytesPerPacket = 2 * sizeof(AudioSampleType);
+  audioFormat.mBytesPerFrame = 2 * sizeof(SInt16);
+  audioFormat.mBytesPerPacket = 2 * sizeof(SInt16);
 #else
-  audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame = sizeof(AudioUnitSampleType);
+  audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame = sizeof(SInt32);
   audioFormat.mFormatFlags |= kAudioFormatFlagIsNonInterleaved;
 #endif
 
@@ -652,7 +651,7 @@ void audio_unit_check_audio_route(aubio_audio_unit_t *o) {
     if (o->verbose) {
       AUBIO_MSG ("audio_unit: current route is %s\n", route);
     }
-    free(route);
+    //free(route);
   }
   if( currentRoute ) {
     if( CFStringCompare( currentRoute, CFSTR("Headset"), 0 ) == kCFCompareEqualTo ) {
@@ -774,4 +773,4 @@ uint_t del_aubio_audio_unit(aubio_audio_unit_t *o)
   return (int)err;
 }
 
-#endif /* TARGET_OS_IPHONE */
+#endif /* HAVE_AUDIO_UNIT */