Changeset d3066e2


Ignore:
Timestamp:
Nov 13, 2013, 1:25:30 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
4bc92c0
Parents:
c101fe1
Message:

src/io/audio_unit.c: cast OSStatus to int, add missing \n

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/audio_unit.c

    rc101fe1 rd3066e2  
    110110  /* check for some sizes */
    111111  if ( o->hw_output_channels != o->output_frames->height ) {
    112     AUBIO_ERR ("got hw_output_channels = %d, but output_frames has %d rows",
     112    AUBIO_ERR ("got hw_output_channels = %d, but output_frames has %d rows\n",
    113113        o->hw_output_channels, o->output_frames->height);
    114114  }
    115115  if ( o->blocksize != o->output_frames->length ) {
    116     AUBIO_ERR ("got blocksize = %d, but output_frames has length %d",
     116    AUBIO_ERR ("got blocksize = %d, but output_frames has length %d\n",
    117117        o->blocksize, o->output_frames->length);
    118118  }
    119119  if ( o->hw_input_channels != o->input_frames->height ) {
    120     AUBIO_ERR ("got hw_input_channels = %d, but input_frames has %d rows",
     120    AUBIO_ERR ("got hw_input_channels = %d, but input_frames has %d rows\n",
    121121        o->hw_input_channels, o->input_frames->height);
    122122  }
    123123  if ( o->blocksize != o->input_frames->length ) {
    124     AUBIO_ERR ("got blocksize = %d, but input_frames has length %d",
     124    AUBIO_ERR ("got blocksize = %d, but input_frames has length %d\n",
    125125        o->blocksize, o->input_frames->length);
    126126  }
     
    159159  /* setting up audio session with interruption listener */
    160160  err = AudioSessionInitialize(NULL, NULL, audio_unit_interruption_listener, o);
    161   if (err) { AUBIO_ERR("audio_unit: could not initialize audio session (%ld)", err); goto fail; }
     161  if (err) { AUBIO_ERR("audio_unit: could not initialize audio session (%d)\n", (int)err); goto fail; }
    162162
    163163  audio_unit_set_audio_session_category(o->input_enabled, o->verbose);
     
    167167  err = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange,
    168168      audio_unit_route_change_listener, o);
    169   if (err) { AUBIO_ERR("audio_unit: could not set route change listener (%ld)", err); goto fail; }
     169  if (err) { AUBIO_ERR("audio_unit: could not set route change listener (%d)\n", (int)err); goto fail; }
    170170
    171171  /* set latency */
    172172  err = AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration,
    173173      sizeof(latency), &latency);
    174   if (err) { AUBIO_ERR("audio_unit: could not set preferred latency (%ld)", err); goto fail; }
     174  if (err) { AUBIO_ERR("audio_unit: could not set preferred latency (%d)\n", (int)err); goto fail; }
    175175
    176176#if 0 // only for iphone OS >= 3.1
     
    178178  err = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
    179179      sizeof(UInt32), &val);
    180   if (err) { AUBIO_ERR("audio_unit: could not set session property to default to speaker"); }
     180  if (err) { AUBIO_ERR("audio_unit: could not set session property to default to speaker\n"); }
    181181#endif
    182182
     
    198198
    199199  err = AudioComponentInstanceNew(comp, &(o->audio_unit));
    200   if (err) { AUBIO_ERR("audio_unit: failed creating the audio unit"); goto fail; }
     200  if (err) { AUBIO_ERR("audio_unit: failed creating the audio unit\n"); goto fail; }
    201201
    202202  /* enable IO */
     
    205205      kAudioUnitScope_Input, 1, &enabled, sizeof(enabled));
    206206  if (err) {
    207     AUBIO_ERR("audio_unit: failed enabling input of audio unit");
     207    AUBIO_ERR("audio_unit: failed enabling input of audio unit\n");
    208208    goto fail;
    209209  }
     
    214214      kAudioUnitScope_Global, 0, &max_fps, sizeof(max_fps));
    215215  if (err) {
    216     AUBIO_ERR("audio_unit: could not set maximum frames per slice property (%ld)", err);
     216    AUBIO_ERR("audio_unit: could not set maximum frames per slice property (%d)\n", (int)err);
    217217    goto fail;
    218218  }
     
    220220  AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SetRenderCallback,
    221221      kAudioUnitScope_Input, 0, &(o->au_ios_cb_struct), sizeof(o->au_ios_cb_struct));
    222   if (err) { AUBIO_ERR("audio_unit: failed setting audio unit render callback"); goto fail; }
     222  if (err) { AUBIO_ERR("audio_unit: failed setting audio unit render callback\n"); goto fail; }
    223223
    224224#if 0
    225225  err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SampleRate,
    226226      kAudioUnitScope_Input, 0, &samplerate, sizeof(Float64));
    227   if (err) { AUBIO_ERR("audio_unit: could not set audio input sample rate"); goto fail; }
     227  if (err) { AUBIO_ERR("audio_unit: could not set audio input sample rate\n"); goto fail; }
    228228  err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SampleRate,
    229229      kAudioUnitScope_Output, 1, &samplerate, sizeof(Float64));
    230   if (err) { AUBIO_ERR("audio_unit: could not set audio input sample rate"); goto fail; }
     230  if (err) { AUBIO_ERR("audio_unit: could not set audio input sample rate\n"); goto fail; }
    231231#endif
    232232
     
    247247  err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
    248248      kAudioUnitScope_Input, 0, &audioFormat, sizeof(audioFormat));
    249   if (err) { AUBIO_ERR("audio_unit: could not set audio output format"); goto fail; }
     249  if (err) { AUBIO_ERR("audio_unit: could not set audio output format\n"); goto fail; }
    250250  err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
    251251      kAudioUnitScope_Output, 1, &audioFormat, sizeof(audioFormat));
    252   if (err) { AUBIO_ERR("audio_unit: could not set audio input format"); goto fail; }
     252  if (err) { AUBIO_ERR("audio_unit: could not set audio input format\n"); goto fail; }
    253253
    254254#if 0
     
    257257  err = AudioUnitGetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
    258258      kAudioUnitScope_Input, 0, &thruFormat, &thissize);
    259   if (err) { AUBIO_ERR("audio_unit: could not get speaker output format, err: %d", (int)err); goto fail; }
     259  if (err) { AUBIO_ERR("audio_unit: could not get speaker output format, err: %d\n", (int)err); goto fail; }
    260260  err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
    261261      kAudioUnitScope_Output, 1, &thruFormat, sizeof(thruFormat));
    262   if (err) { AUBIO_ERR("audio_unit: could not set input audio format, err: %d", (int)err); goto fail; }
     262  if (err) { AUBIO_ERR("audio_unit: could not set input audio format, err: %d\n", (int)err); goto fail; }
    263263#endif
    264264
    265265  /* time to initialize the unit */
    266266  err = AudioUnitInitialize(*audio_unit);
    267   if (err) { AUBIO_ERR("audio_unit: failed initializing audio, err: %d", (int)err); goto fail; }
     267  if (err) { AUBIO_ERR("audio_unit: failed initializing audio, err: %d\n", (int)err); goto fail; }
    268268
    269269  return 0;
     
    287287        inNumber_frames, input_output);
    288288    if (err) {
    289       AUBIO_ERR("audio_unit: error performing AudioUnitRender (%d)", err);
     289      AUBIO_ERR("audio_unit: error performing AudioUnitRender (%d)\n", err);
    290290      return err;
    291291    }
     
    297297  // FIXME find out why this happens
    298298  if (number_frames < 10) {
    299     AUBIO_ERR("audio_unit: got number_frames %d", (int)number_frames);
     299    AUBIO_ERR("audio_unit: got number_frames %d\n", (int)number_frames);
    300300    return -1;
    301301  }
     
    373373
    374374  if (o->dio_error) {
    375     AUBIO_WRN("audio_unit: dio error %d", o->total_frames);
     375    AUBIO_WRN("audio_unit: dio error %d\n", o->total_frames);
    376376    o->dio_error = 0;
    377377  }
     
    421421
    422422fail:
    423   AUBIO_ERR("audio_unit: callback() failed");
     423  AUBIO_ERR("audio_unit: callback() failed\n");
    424424  o->total_frames += AU_IOS_MAX_FRAMES;
    425425  return 1;
     
    439439  err = AudioUnitGetProperty (o->audio_unit, kAudioUnitProperty_SampleRate,
    440440      kAudioUnitScope_Output, 1, &samplerate, &thissize);
    441   if (err) { AUBIO_ERR("audio_unit: could not get audio unit sample rate (%ld)",
    442       err); goto fail; }
     441  if (err) { AUBIO_ERR("audio_unit: could not get audio unit sample rate (%d)\n",
     442      (int)err); goto fail; }
    443443
    444444  /* get hardware input channels */
     
    446446  err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels,
    447447      &thissize, &input_hw_channels);
    448   if (err) { AUBIO_ERR("audio_unit: could not get hardware input channels (%ld)",
    449       err); goto fail; }
     448  if (err) { AUBIO_ERR("audio_unit: could not get hardware input channels (%d)\n",
     449      (int)err); goto fail; }
    450450
    451451  /* get hardware output channels */
     
    453453  err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputNumberChannels,
    454454      &thissize, &output_hw_channels);
    455   if (err) { AUBIO_ERR("audio_unit: could not get hardware output channels (%ld)",
    456       err); goto fail; }
     455  if (err) { AUBIO_ERR("audio_unit: could not get hardware output channels (%d)\n",
     456      (int)err); goto fail; }
    457457
    458458  /* get hardware input volume */
     
    460460  err = AudioSessionGetProperty(kAudioSessionProperty_InputGainScalar,
    461461      &thissize, &input_hw_volume);
    462   if (err) { AUBIO_ERR("audio_unit: could not get hardware input volume (%ld)",
    463       err); goto fail; }
     462  if (err) { AUBIO_ERR("audio_unit: could not get hardware input volume (%d)\n",
     463      (int)err); goto fail; }
    464464
    465465  /* get hardware output volume */
     
    467467  err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume,
    468468      &thissize, &output_hw_volume);
    469   if (err) { AUBIO_ERR("audio_unit: could not get hardware output volume (%ld)",
    470       err); goto fail; }
    471 
    472   AUBIO_MSG("audio_unit: opened at %.0fHz, sw channels %din/%dout, hw channels %ldin/%ldout, hw vol %.2fin/%.2fout",
     469  if (err) { AUBIO_ERR("audio_unit: could not get hardware output volume (%d)\n",
     470      (int)err); goto fail; }
     471
     472  AUBIO_MSG("audio_unit: opened at %.0fHz, sw channels %din/%dout, hw channels %din/%dout, hw vol %.2fin/%.2fout\n",
    473473      samplerate,
    474474      o->sw_input_channels, o->sw_output_channels,
    475       input_hw_channels, output_hw_channels,
     475      (unsigned int)input_hw_channels, (unsigned int)output_hw_channels,
    476476      input_hw_volume, output_hw_volume);
    477477
     
    480480  err = AudioUnitGetProperty (o->audio_unit, kAudioUnitProperty_MaximumFramesPerSlice,
    481481      kAudioUnitScope_Global, 0, &max_fps, &thissize);
    482   if (err) { AUBIO_ERR("audio_unit: could not get maximum frames per slice property %ld",
    483       err); goto fail; }
     482  if (err) { AUBIO_ERR("audio_unit: could not get maximum frames per slice property %d\n",
     483      (int)err); goto fail; }
    484484
    485485  /* get hardware latency */
     
    487487  err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareIOBufferDuration,
    488488      &thissize, &latency);
    489   if (err) { AUBIO_ERR("audio_unit: could not get hardware latency %ld",
    490       err); goto fail; }
     489  if (err) { AUBIO_ERR("audio_unit: could not get hardware latency %d\n",
     490      (int)err); goto fail; }
    491491
    492492  /* get input latency */
     
    494494  err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputLatency,
    495495      &thissize, &input_latency);
    496   if (err) { AUBIO_ERR("audio_unit: could not get input latency %ld",
    497       err); goto fail; }
     496  if (err) { AUBIO_ERR("audio_unit: could not get input latency %d\n",
     497      (int)err); goto fail; }
    498498
    499499  /* get output harlatency */
     
    501501  err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputLatency,
    502502      &thissize, &output_latency);
    503   if (err) { AUBIO_ERR("audio_unit: could not get output latency %ld",
    504       err); goto fail; }
    505 
    506   AUBIO_MSG("audio_unit: I/O latency: %.2fms, %d frames, (%.2fms, %d frames in, %.2fms %d frames out)",
     503  if (err) { AUBIO_ERR("audio_unit: could not get output latency %d\n",
     504      (int)err); goto fail; }
     505
     506  AUBIO_MSG("audio_unit: I/O latency: %.2fms, %d frames, (%.2fms, %d frames in, %.2fms %d frames out)\n",
    507507      latency*1000., (sint_t)round(latency*samplerate),
    508508      input_latency*1000., (sint_t)ROUND(input_latency*samplerate),
     
    523523  /* time to start the unit */
    524524  err = AudioOutputUnitStart (o->audio_unit);
    525   if (err) { AUBIO_ERR("audio_unit: could not start unit (%ld)", err); }
     525  if (err) { AUBIO_ERR("audio_unit: could not start unit (%d)\n", (int)err); }
    526526  return err;
    527527}
     
    531531  if (o->audio_unit == NULL) return -1;
    532532  OSStatus err = AudioOutputUnitStop (o->audio_unit);
    533   if (err) { AUBIO_WRN("audio_unit: failed stopping audio unit (%ld)", err); }
     533  if (err) { AUBIO_WRN("audio_unit: failed stopping audio unit (%d)\n", (int)err); }
    534534  err = AudioUnitUninitialize (o->audio_unit);
    535   if (err) { AUBIO_WRN("audio_unit: failed unitializing audio unit (%ld)", err); }
     535  if (err) { AUBIO_WRN("audio_unit: failed unitializing audio unit (%d)\n", (int)err); }
    536536  err = AudioSessionSetActive(false);
    537   if (err) { AUBIO_WRN("audio_unit: failed stopping audio session (%ld)", err); }
     537  if (err) { AUBIO_WRN("audio_unit: failed stopping audio session (%d)\n", (int)err); }
    538538  return err;
    539539}
     
    554554
    555555  if (inInterruptionState == kAudioSessionEndInterruption) {
    556     AUBIO_WRN("audio_unit: session interruption ended");
     556    AUBIO_WRN("audio_unit: session interruption ended\n");
    557557    err = AudioSessionSetActive(true);
    558558    if (err) {
    559       AUBIO_ERR("audio_unit: could not make session active after interruption (%ld)", err);
     559      AUBIO_ERR("audio_unit: could not make session active after interruption (%d)\n", (int)err);
    560560      goto fail;
    561561    }
    562562    err = AudioOutputUnitStart(this_unit);
    563563    if (err) {
    564       AUBIO_ERR("audio_unit: failed starting unit (%ld)", err);
     564      AUBIO_ERR("audio_unit: failed starting unit (%d)\n", (int)err);
    565565      goto fail;
    566566    }
    567567  }
    568568  if (inInterruptionState == kAudioSessionBeginInterruption) {
    569     AUBIO_WRN("audio_unit: session interruption started");
     569    AUBIO_WRN("audio_unit: session interruption started\n");
    570570    err = AudioOutputUnitStop(this_unit);
    571571    if (err) {
    572       AUBIO_ERR("audio_unit: could not stop unit at interruption (%ld)", err);
     572      AUBIO_ERR("audio_unit: could not stop unit at interruption (%d)\n", (int)err);
    573573      goto fail;
    574574    }
    575575    err = AudioSessionSetActive(false);
    576576    if (err) {
    577       AUBIO_ERR("audio_unit: could not make session inactive after interruption (%ld)", err);
     577      AUBIO_ERR("audio_unit: could not make session inactive after interruption (%d)\n", (int)err);
    578578      goto fail;
    579579    }
     
    589589      &thissize, &category);
    590590  if (err) {
    591     AUBIO_ERR("audio_unit: could not get audio category (%ld)", err);
     591    AUBIO_ERR("audio_unit: could not get audio category (%d)\n", (int)err);
    592592    return err;
    593593  }
    594594  if (category == kAudioSessionCategory_AmbientSound) {
    595     AUBIO_MSG("audio_unit: session category is AmbiantSound");
     595    AUBIO_MSG("audio_unit: session category is AmbiantSound\n");
    596596  } else if (category == kAudioSessionCategory_SoloAmbientSound) {
    597     AUBIO_MSG("audio_unit: session category is SoloAmbiantSound");
     597    AUBIO_MSG("audio_unit: session category is SoloAmbiantSound\n");
    598598  } else if (category == kAudioSessionCategory_MediaPlayback) {
    599     AUBIO_MSG("audio_unit: session category is MediaPlayback");
     599    AUBIO_MSG("audio_unit: session category is MediaPlayback\n");
    600600  } else if (category == kAudioSessionCategory_RecordAudio) {
    601     AUBIO_MSG("audio_unit: session category is RecordAudio");
     601    AUBIO_MSG("audio_unit: session category is RecordAudio\n");
    602602  } else if (category == kAudioSessionCategory_PlayAndRecord) {
    603     AUBIO_MSG("audio_unit: session category is PlayAndRecord");
     603    AUBIO_MSG("audio_unit: session category is PlayAndRecord\n");
    604604  } else if (category == kAudioSessionCategory_AudioProcessing) {
    605     AUBIO_MSG("audio_unit: session category is AudioProcessing");
     605    AUBIO_MSG("audio_unit: session category is AudioProcessing\n");
    606606  }
    607607  return category;
     
    615615  if (has_input) {
    616616    category = kAudioSessionCategory_PlayAndRecord;
    617     if (verbose) AUBIO_MSG("audio_unit: setting category to PlayAndRecord");
     617    if (verbose) AUBIO_MSG("audio_unit: setting category to PlayAndRecord\n");
    618618  } else {
    619619    category = kAudioSessionCategory_MediaPlayback;
    620     if (verbose) AUBIO_MSG("audio_unit: setting category to MediaPlayback");
     620    if (verbose) AUBIO_MSG("audio_unit: setting category to MediaPlayback\n");
    621621  }
    622622  err = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
    623623      sizeof(category), &category);
    624624  if (err) {
    625     AUBIO_ERR("audio_unit: could not set audio category");
     625    AUBIO_ERR("audio_unit: could not set audio category\n");
    626626  }
    627627
     
    631631      sizeof (allowMixing), &allowMixing);
    632632  if (err) {
    633     AUBIO_ERR("audio_unit: could not set audio session to mix with others");
     633    AUBIO_ERR("audio_unit: could not set audio session to mix with others\n");
    634634  }
    635635
     
    641641  UInt32 val, thissize = sizeof(currentRoute);
    642642  OSStatus err = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &thissize, &currentRoute);
    643   if (err) { AUBIO_ERR("audio_unit: could not get current route"); goto fail; }
     643  if (err) { AUBIO_ERR("audio_unit: could not get current route\n"); goto fail; }
    644644  else {
    645645    char *route = (char *)CFStringGetCStringPtr ( currentRoute, kCFStringEncodingUTF8);
     
    651651    }
    652652    if (o->verbose) {
    653       AUBIO_MSG ("audio_unit: current route is %s", route);
     653      AUBIO_MSG ("audio_unit: current route is %s\n", route);
    654654    }
    655655    free(route);
     
    677677        o->input_enabled = false;
    678678        if (o->verbose) {
    679           AUBIO_MSG ("audio_unit: disabling input to avoid feedback");
     679          AUBIO_MSG ("audio_unit: disabling input to avoid feedback\n");
    680680        }
    681681      } else {
    682         AUBIO_WRN ("audio_unit: input not disabled as prevent_feedback set to 0, risking feedback");
     682        AUBIO_WRN ("audio_unit: input not disabled as prevent_feedback set to 0, risking feedback\n");
    683683      }
    684684    }
     
    686686    err = AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute,
    687687        sizeof(UInt32), &val);
    688     if (err) { AUBIO_ERR("audio_unit: could not set session OverrideAudioRoute to Speaker"); }
     688    if (err) { AUBIO_ERR("audio_unit: could not set session OverrideAudioRoute to Speaker\n"); }
    689689
    690690  }
     
    704704  switch (change_reason_number) {
    705705    case kAudioSessionRouteChangeReason_NewDeviceAvailable:
    706       AUBIO_MSG("audio_unit: route changed to NewDeviceAvailable");
     706      AUBIO_MSG("audio_unit: route changed to NewDeviceAvailable\n");
    707707      break;
    708708    case kAudioSessionRouteChangeReason_OldDeviceUnavailable:
    709       AUBIO_MSG("audio_unit: route changed to OldDeviceUnavailable");
     709      AUBIO_MSG("audio_unit: route changed to OldDeviceUnavailable\n");
    710710      break;
    711711    case kAudioSessionRouteChangeReason_CategoryChange:
    712       AUBIO_MSG("audio_unit: route changed to CategoryChange");
     712      AUBIO_MSG("audio_unit: route changed to CategoryChange\n");
    713713      audio_unit_get_audio_session_category();
    714714      break;
    715715    case kAudioSessionRouteChangeReason_Override:
    716       AUBIO_MSG("audio_unit: route changed to Override");
     716      AUBIO_MSG("audio_unit: route changed to Override\n");
    717717      break;
    718718    case kAudioSessionRouteChangeReason_WakeFromSleep:
    719       AUBIO_MSG("audio_unit: route changed to WakeFromSleep");
     719      AUBIO_MSG("audio_unit: route changed to WakeFromSleep\n");
    720720      break;
    721721    case kAudioSessionRouteChangeReason_NoSuitableRouteForCategory:
    722       AUBIO_MSG("audio_unit: route changed to NoSuitableRouteForCategory");
     722      AUBIO_MSG("audio_unit: route changed to NoSuitableRouteForCategory\n");
    723723      break;
    724724    case kAudioSessionRouteChangeReason_Unknown:
    725725    default:
    726       AUBIO_ERR("audio_unit: route changed for an unknown reason!?");
     726      AUBIO_ERR("audio_unit: route changed for an unknown reason!?\n");
    727727      break;
    728728  }
Note: See TracChangeset for help on using the changeset viewer.