Ignore:
Timestamp:
Jan 24, 2014, 5:09:50 PM (10 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:
5ab8e59
Parents:
16dda03
Message:

src/io/*apple*: improve error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_apple_audio.c

    r16dda03 r98a3887  
    5151extern void freeAudioBufferList(AudioBufferList *bufferList);
    5252extern CFURLRef getURLFromPath(const char * path);
     53char_t *getPrintableOSStatusError(char_t *str, OSStatus error);
    5354
    5455uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path);
     
    8081  CFURLRef fileURL = getURLFromPath(path);
    8182  err = ExtAudioFileOpenURL(fileURL, &s->audioFile);
    82   if (err) { AUBIO_ERR("error when trying to access %s, in ExtAudioFileOpenURL, %d\n", s->path, (int)err); goto beach;}
     83  if (err == -43) {
     84    AUBIO_ERR("source_apple_audio: Failed opening %s, "
     85        "file not found, or no read access\n", s->path);
     86    goto beach;
     87  } else if (err) {
     88    char_t errorstr[20];
     89    AUBIO_ERR("source_apple_audio: Failed opening %s, "
     90        "error in ExtAudioFileOpenURL (%s)\n", s->path,
     91        getPrintableOSStatusError(errorstr, err));
     92    goto beach;
     93  }
    8394
    8495  // create an empty AudioStreamBasicDescription
     
    90101  err = ExtAudioFileGetProperty(s->audioFile,
    91102      kExtAudioFileProperty_FileDataFormat, &propSize, &fileFormat);
    92   if (err) { AUBIO_ERROR("error in ExtAudioFileGetProperty, %d\n", (int)err); goto beach;}
     103  if (err) {
     104    char_t errorstr[20];
     105    AUBIO_ERROR("source_apple_audio: Failed opening %s, "
     106        "error in ExtAudioFileGetProperty (%s)\n", s->path,
     107        getPrintableOSStatusError(errorstr, err));
     108    goto beach;
     109  }
    93110
    94111  if (s->samplerate == 0) {
     
    117134      propSize, &clientFormat);
    118135  if (err) {
    119       AUBIO_ERROR("error in ExtAudioFileSetProperty, %d\n", (int)err);
     136    char_t errorstr[20];
     137    AUBIO_ERROR("source_apple_audio: Failed opening %s, "
     138        "error in ExtAudioFileSetProperty (%s)\n", s->path,
     139        getPrintableOSStatusError(errorstr, err));
    120140#if 1
    121141  // print client and format descriptions
     
    158178  UInt32 c, v, loadedPackets = s->block_size;
    159179  OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList);
    160   if (err) { AUBIO_ERROR("error in ExtAudioFileRead %s %d\n", s->path, (int)err); goto beach;}
     180  if (err) {
     181    char_t errorstr[20];
     182    AUBIO_ERROR("source_apple_audio: error while reading %s "
     183        "with ExtAudioFileRead (%s)\n", s->path,
     184        getPrintableOSStatusError(errorstr, err));
     185    goto beach;
     186  }
    161187
    162188  short *data = (short*)s->bufferList.mBuffers[0].mData;
     
    188214  UInt32 c, v, loadedPackets = s->block_size;
    189215  OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList);
    190   if (err) { AUBIO_ERROR("source_apple_audio: error in ExtAudioFileRead, %d\n", (int)err); goto beach;}
     216  if (err) {
     217    char_t errorstr[20];
     218    AUBIO_ERROR("source_apple_audio: error while reading %s "
     219        "with ExtAudioFileRead (%s)\n", s->path,
     220        getPrintableOSStatusError(errorstr, err));
     221    goto beach;
     222  }
    191223
    192224  short *data = (short*)s->bufferList.mBuffers[0].mData;
     
    226258{
    227259  OSStatus err = noErr;
    228   if (!s || !s->audioFile) { return 1; }
     260  if (!s || !s->audioFile) { return AUBIO_FAIL; }
    229261  err = ExtAudioFileDispose(s->audioFile);
    230   if (err) AUBIO_ERROR("error in ExtAudioFileDispose, %d\n", (int)err);
    231262  s->audioFile = NULL;
    232   return err;
     263  if (err) {
     264    char_t errorstr[20];
     265    AUBIO_ERROR("source_apple_audio: error while closing %s "
     266        "in ExtAudioFileDispose (%s)\n", s->path,
     267        getPrintableOSStatusError(errorstr, err));
     268    return err;
     269  }
     270  return AUBIO_OK;
    233271}
    234272
     
    248286  SInt64 resampled_pos = (SInt64)ROUND( pos * ratio );
    249287  OSStatus err = ExtAudioFileSeek(s->audioFile, resampled_pos);
    250   if (err) AUBIO_ERROR("source_apple_audio: error in ExtAudioFileSeek (%d)\n", (int)err);
     288  if (err) {
     289    char_t errorstr[20];
     290    AUBIO_ERROR("source_apple_audio: error while seeking %s at %d "
     291        "in ExtAudioFileSeek (%s)\n", s->path, pos,
     292        getPrintableOSStatusError(errorstr, err));
     293  }
    251294  return err;
    252295}
Note: See TracChangeset for help on using the changeset viewer.