Changeset b643a33


Ignore:
Timestamp:
Apr 21, 2016, 7:01:50 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:
26a6af7
Parents:
ae5d58a
Message:

src/io/*.c: take a copy of const char* path

Location:
src/io
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink_apple_audio.c

    rae5d58a rb643a33  
    6060aubio_sink_apple_audio_t * new_aubio_sink_apple_audio(const char_t * uri, uint_t samplerate) {
    6161  aubio_sink_apple_audio_t * s = AUBIO_NEW(aubio_sink_apple_audio_t);
    62   s->path = uri;
    6362  s->max_frames = MAX_SIZE;
    6463  s->async = false;
     
    6867    goto beach;
    6968  }
     69  if (s->path != NULL) AUBIO_FREE(s->path);
     70  s->path = AUBIO_ARRAY(char_t, strnlen(uri, PATH_MAX));
     71  strncpy(s->path, uri, strnlen(uri, PATH_MAX));
    7072
    7173  s->samplerate = 0;
     
    250252void del_aubio_sink_apple_audio(aubio_sink_apple_audio_t * s) {
    251253  if (s->audioFile) aubio_sink_apple_audio_close (s);
     254  if (s->path) AUBIO_FREE(s->path);
    252255  freeAudioBufferList(&s->bufferList);
    253256  AUBIO_FREE(s);
  • src/io/sink_sndfile.c

    rae5d58a rb643a33  
    5757  aubio_sink_sndfile_t * s = AUBIO_NEW(aubio_sink_sndfile_t);
    5858  s->max_size = MAX_SIZE;
    59   s->path = path;
    6059
    6160  if (path == NULL) {
     
    6362    return NULL;
    6463  }
     64
     65  if (s->path) AUBIO_FREE(s->path);
     66  s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
     67  strncpy(s->path, path, strnlen(path, PATH_MAX));
    6568
    6669  s->samplerate = 0;
     
    220223void del_aubio_sink_sndfile(aubio_sink_sndfile_t * s){
    221224  if (!s) return;
     225  if (s->path) AUBIO_FREE(s->path);
    222226  aubio_sink_sndfile_close(s);
    223227  AUBIO_FREE(s->scratch_data);
  • src/io/sink_wavwrite.c

    rae5d58a rb643a33  
    9090  }
    9191
    92   s->path = path;
     92  if (s->path) AUBIO_FREE(s->path);
     93  s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
     94  strncpy(s->path, path, strnlen(path, PATH_MAX));
     95
    9396  s->max_size = MAX_SIZE;
    9497  s->bitspersample = 16;
     
    288291  if (!s) return;
    289292  aubio_sink_wavwrite_close(s);
     293  if (s->path) AUBIO_FREE(s->path);
    290294  AUBIO_FREE(s->scratch_data);
    291295  AUBIO_FREE(s);
  • src/io/source_apple_audio.c

    rae5d58a rb643a33  
    8080  s->block_size = block_size;
    8181  s->samplerate = samplerate;
    82   s->path = path;
    8382
    8483  if ( aubio_source_apple_audio_open ( s, path ) ) {
     
    9695  OSStatus err = noErr;
    9796  UInt32 propSize;
    98   s->path = path;
     97
     98  if (s->path) AUBIO_FREE(s->path);
     99  s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
     100  strncpy(s->path, path, strnlen(path, PATH_MAX));
    99101
    100102  // open the resource url
    101   CFURLRef fileURL = createURLFromPath(path);
     103  CFURLRef fileURL = createURLFromPath(s->path);
    102104  err = ExtAudioFileOpenURL(fileURL, &s->audioFile);
    103105  CFRelease(fileURL);
     
    294296void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){
    295297  aubio_source_apple_audio_close (s);
     298  if (s->path) AUBIO_FREE(s->path);
    296299  freeAudioBufferList(&s->bufferList);
    297300  AUBIO_FREE(s);
  • src/io/source_avcodec.c

    rae5d58a rb643a33  
    8585  s->hop_size = hop_size;
    8686  s->channels = 1;
    87   s->path = path;
     87
     88  if (s->path) AUBIO_FREE(s->path);
     89  s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
     90  strncpy(s->path, path, strnlen(path, PATH_MAX));
    8891
    8992  // register all formats and codecs
     
    425428    av_frame_free( &(s->avFrame) );
    426429  }
     430  if (s->path) AUBIO_FREE(s->path);
    427431  s->avFrame = NULL;
    428432  AUBIO_FREE(s);
  • src/io/source_sndfile.c

    rae5d58a rb643a33  
    8787  s->hop_size = hop_size;
    8888  s->channels = 1;
    89   s->path = path;
     89
     90  if (s->path) AUBIO_FREE(s->path);
     91  s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
     92  strncpy(s->path, path, strnlen(path, PATH_MAX));
    9093
    9194  // try opening the file, getting the info in sfinfo
     
    306309  }
    307310#endif /* HAVE_SAMPLERATE */
     311  if (s->path) AUBIO_FREE(s->path);
    308312  AUBIO_FREE(s->scratch_data);
    309313  AUBIO_FREE(s);
  • src/io/source_wavread.c

    rae5d58a rb643a33  
    8787  }
    8888
    89   s->path = path;
     89  if (s->path) AUBIO_FREE(s->path);
     90  s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
     91  strncpy(s->path, path, strnlen(path, PATH_MAX));
     92
    9093  s->samplerate = samplerate;
    9194  s->hop_size = hop_size;
     
    389392  if (s->short_output) AUBIO_FREE(s->short_output);
    390393  if (s->output) del_fmat(s->output);
     394  if (s->path) AUBIO_FREE(s->path);
    391395  AUBIO_FREE(s);
    392396}
Note: See TracChangeset for help on using the changeset viewer.