Changeset 4b7747d


Ignore:
Timestamp:
Jan 6, 2014, 2:11:55 AM (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:
d13e6b7
Parents:
6d509c3
Message:

src/io/sink.c: use function pointers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink.c

    r6d509c3 r4b7747d  
    3030#endif
    3131
     32typedef void (*aubio_sink_do_t)(aubio_sink_t * s, fvec_t * data, uint_t write);
     33#if 0
     34typedef void (*aubio_sink_do_multi_t)(aubio_sink_t * s, fmat_t * data, uint_t * read);
     35typedef uint_t (*aubio_sink_get_samplerate_t)(aubio_sink_t * s);
     36typedef uint_t (*aubio_sink_get_channels_t)(aubio_sink_t * s);
     37#endif
     38typedef uint_t (*del_aubio_sink_t)(aubio_sink_t * s);
     39
    3240struct _aubio_sink_t {
    3341  void *sink;
     42  aubio_sink_do_t s_do;
     43#if 0
     44  aubio_sink_do_multi_t s_do_multi;
     45  aubio_sink_get_samplerate_t s_get_samplerate;
     46  aubio_sink_get_channels_t s_get_channels;
     47#endif
     48  del_aubio_sink_t s_del;
    3449};
    3550
     
    3853#ifdef __APPLE__
    3954  s->sink = (void *)new_aubio_sink_apple_audio(uri, samplerate);
    40   if (s->sink) return s;
    41 #else /* __APPLE__ */
     55  if (s->sink) {
     56    s->s_do = (aubio_sink_do_t)(aubio_sink_apple_audio_do);
     57    s->s_del = (del_aubio_sink_t)(del_aubio_sink_apple_audio);
     58    return s;
     59  }
     60#endif /* __APPLE__ */
    4261#if HAVE_SNDFILE
    4362  s->sink = (void *)new_aubio_sink_sndfile(uri, samplerate);
    44   if (s->sink) return s;
     63  if (s->sink) {
     64    s->s_do = (aubio_sink_do_t)(aubio_sink_sndfile_do);
     65    s->s_del = (del_aubio_sink_t)(del_aubio_sink_sndfile);
     66    return s;
     67  }
    4568#endif /* HAVE_SNDFILE */
    46 #endif /* __APPLE__ */
    47   AUBIO_ERROR("failed creating aubio sink with %s\n", uri);
     69  AUBIO_ERROR("sink: failed creating aubio sink with %s\n", uri);
    4870  AUBIO_FREE(s);
    4971  return NULL;
     
    5173
    5274void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t write) {
    53 #ifdef __APPLE__
    54   aubio_sink_apple_audio_do((aubio_sink_apple_audio_t *)s->sink, write_data, write);
    55 #else /* __APPLE__ */
    56 #if HAVE_SNDFILE
    57   aubio_sink_sndfile_do((aubio_sink_sndfile_t *)s->sink, write_data, write);
    58 #endif /* HAVE_SNDFILE */
    59 #endif /* __APPLE__ */
     75  s->s_do((void *)s->sink, write_data, write);
    6076}
    6177
    6278void del_aubio_sink(aubio_sink_t * s) {
    6379  if (!s) return;
    64 #ifdef __APPLE__
    65   del_aubio_sink_apple_audio((aubio_sink_apple_audio_t *)s->sink);
    66 #else /* __APPLE__ */
    67 #if HAVE_SNDFILE
    68   del_aubio_sink_sndfile((aubio_sink_sndfile_t *)s->sink);
    69 #endif /* HAVE_SNDFILE */
    70 #endif /* __APPLE__ */
     80  s->s_del((void *)s->sink);
    7181  AUBIO_FREE(s);
    7282  return;
Note: See TracChangeset for help on using the changeset viewer.