aubio_sink_sndfile_t * new_aubio_sink_sndfile(const char_t * path, uint_t samplerate) { aubio_sink_sndfile_t * s = AUBIO_NEW(aubio_sink_sndfile_t); s->max_size = MAX_SIZE; if (path == NULL) { AUBIO_ERR("sink_sndfile: Aborted opening null path\n"); return NULL; } if (s->path) AUBIO_FREE(s->path); s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); s->samplerate = 0; s->channels = 0; // negative samplerate given, abort if ((sint_t)samplerate < 0) goto beach; // zero samplerate given. do not open yet if ((sint_t)samplerate == 0) return s; s->samplerate = samplerate; s->channels = 1; if (aubio_sink_sndfile_open(s) != AUBIO_OK) {; goto beach; } return s; beach: del_aubio_sink_sndfile(s); return NULL; }
void del_aubio_sink(aubio_sink_t * s) { if (!s) return; #ifdef __APPLE__ del_aubio_sink_apple_audio((aubio_sink_apple_audio_t *)s->sink); #else /* __APPLE__ */ #if HAVE_SNDFILE del_aubio_sink_sndfile((aubio_sink_sndfile_t *)s->sink); #endif /* HAVE_SNDFILE */ #endif /* __APPLE__ */ AUBIO_FREE(s); return; }