Changeset 9fa9b86 for src/io


Ignore:
Timestamp:
Feb 8, 2016, 5:01:31 PM (8 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:
5bd806d
Parents:
94b16497
Message:

src/io/sink_apple_audio.c: disable async mode for now, factorise code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink_apple_audio.c

    r94b16497 r9fa9b86  
    4444#define MAX_SIZE 4096 // the maximum number of frames that can be written at a time
    4545
     46void aubio_sink_apple_audio_write(aubio_sink_apple_audio_t *s, uint_t write);
     47
    4648struct _aubio_sink_apple_audio_t {
    4749  uint_t samplerate;
     
    6062  s->path = uri;
    6163  s->max_frames = MAX_SIZE;
    62   s->async = true;
     64  s->async = false;
    6365
    6466  if (uri == NULL) {
     
    163165
    164166void aubio_sink_apple_audio_do(aubio_sink_apple_audio_t * s, fvec_t * write_data, uint_t write) {
    165   OSStatus err = noErr;
    166167  UInt32 c, v;
    167168  short *data = (short*)s->bufferList.mBuffers[0].mData;
     
    180181      }
    181182  }
    182   if (s->async) {
    183     err = ExtAudioFileWriteAsync(s->audioFile, write, &s->bufferList);
    184 
    185     if (err) {
    186       char_t errorstr[20];
    187       AUBIO_ERROR("sink_apple_audio: error while writing %s "
    188           "in ExtAudioFileWriteAsync (%s), switching to sync\n", s->path,
    189           getPrintableOSStatusError(errorstr, err));
    190       s->async = false;
    191     } else {
    192       return;
    193     }
    194 
    195   } else {
    196     err = ExtAudioFileWrite(s->audioFile, write, &s->bufferList);
    197 
    198     if (err) {
    199       char_t errorstr[20];
    200       AUBIO_ERROR("sink_apple_audio: error while writing %s "
    201           "in ExtAudioFileWrite (%s)\n", s->path,
    202           getPrintableOSStatusError(errorstr, err));
    203     }
    204   }
    205   return;
     183  aubio_sink_apple_audio_write(s, write);
    206184}
    207185
    208186void aubio_sink_apple_audio_do_multi(aubio_sink_apple_audio_t * s, fmat_t * write_data, uint_t write) {
    209   OSStatus err = noErr;
    210187  UInt32 c, v;
    211188  short *data = (short*)s->bufferList.mBuffers[0].mData;
     
    224201      }
    225202  }
     203  aubio_sink_apple_audio_write(s, write);
     204}
     205
     206void aubio_sink_apple_audio_write(aubio_sink_apple_audio_t *s, uint_t write) {
     207  OSStatus err = noErr;
    226208  if (s->async) {
    227209    err = ExtAudioFileWriteAsync(s->audioFile, write, &s->bufferList);
    228 
    229210    if (err) {
    230211      char_t errorstr[20];
     212      if (err == kExtAudioFileError_AsyncWriteBufferOverflow) {
     213        sprintf(errorstr,"buffer overflow");
     214      } else if (err == kExtAudioFileError_AsyncWriteTooLarge) {
     215        sprintf(errorstr,"write too large");
     216      } else {
     217        // unknown error
     218        getPrintableOSStatusError(errorstr, err);
     219      }
    231220      AUBIO_ERROR("sink_apple_audio: error while writing %s "
    232           "in ExtAudioFileWriteAsync (%s), switching to sync\n", s->path,
    233           getPrintableOSStatusError(errorstr, err));
    234       s->async = false;
    235     } else {
    236       return;
     221                  "in ExtAudioFileWriteAsync (%s)\n", s->path, errorstr);
    237222    }
    238 
    239223  } else {
    240224    err = ExtAudioFileWrite(s->audioFile, write, &s->bufferList);
    241 
    242225    if (err) {
    243226      char_t errorstr[20];
     
    247230    }
    248231  }
    249   return;
    250232}
    251233
Note: See TracChangeset for help on using the changeset viewer.