Index: src/io/source.c
===================================================================
--- src/io/source.c	(revision 4865e4b220200bd82eac01c42a57c3386f05ed0f)
+++ src/io/source.c	(revision d3b9fe4f296522be3517644d340760065b8c8730)
@@ -24,4 +24,7 @@
 #include "fmat.h"
 #include "io/source.h"
+#ifdef HAVE_AVCODEC
+#include "io/source_avcodec.h"
+#endif /* HAVE_AVCODEC */
 #ifdef __APPLE__
 #include "io/source_apple_audio.h"
@@ -29,21 +32,61 @@
 #ifdef HAVE_SNDFILE
 #include "io/source_sndfile.h"
-#endif
+#endif /* HAVE_SNDFILE */
+
+typedef void (*aubio_source_do_t)(aubio_source_t * s, fvec_t * data, uint_t * read);
+typedef void (*aubio_source_do_multi_t)(aubio_source_t * s, fmat_t * data, uint_t * read);
+typedef uint_t (*aubio_source_get_samplerate_t)(aubio_source_t * s);
+typedef uint_t (*aubio_source_get_channels_t)(aubio_source_t * s);
+typedef uint_t (*aubio_source_seek_t)(aubio_source_t * s, uint_t seek);
+typedef uint_t (*del_aubio_source_t)(aubio_source_t * s);
 
 struct _aubio_source_t { 
   void *source;
+  aubio_source_do_t s_do;
+  aubio_source_do_multi_t s_do_multi;
+  aubio_source_get_samplerate_t s_get_samplerate;
+  aubio_source_get_channels_t s_get_channels;
+  aubio_source_seek_t s_seek;
+  del_aubio_source_t s_del;
 };
 
 aubio_source_t * new_aubio_source(char_t * uri, uint_t samplerate, uint_t hop_size) {
   aubio_source_t * s = AUBIO_NEW(aubio_source_t);
+#if HAVE_AVCODEC
+  s->source = (void *)new_aubio_source_avcodec(uri, samplerate, hop_size);
+  if (s->source) {
+    s->s_do = (aubio_source_do_t)(aubio_source_avcodec_do);
+    s->s_do_multi = (aubio_source_do_multi_t)(aubio_source_avcodec_do_multi);
+    s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_avcodec_get_channels);
+    s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_avcodec_get_samplerate);
+    s->s_seek = (aubio_source_seek_t)(aubio_source_avcodec_seek);
+    s->s_del = (del_aubio_source_t)(del_aubio_source_avcodec);
+    return s;
+  }
+#endif /* HAVE_AVCODEC */
 #ifdef __APPLE__
   s->source = (void *)new_aubio_source_apple_audio(uri, samplerate, hop_size);
-  if (s->source) return s;
-#else /* __APPLE__ */
+  if (s->source) {
+    s->s_do = (aubio_source_do_t)(aubio_source_apple_audio_do);
+    s->s_do_multi = (aubio_source_do_multi_t)(aubio_source_apple_audio_do_multi);
+    s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_apple_audio_get_channels);
+    s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_apple_audio_get_samplerate);
+    s->s_seek = (aubio_source_seek_t)(aubio_source_apple_audio_seek);
+    s->s_del = (del_aubio_source_t)(del_aubio_source_apple_audio);
+    return s;
+  }
+#endif /* __APPLE__ */
 #if HAVE_SNDFILE
   s->source = (void *)new_aubio_source_sndfile(uri, samplerate, hop_size);
-  if (s->source) return s;
+  if (s->source) {
+    s->s_do = (aubio_source_do_t)(aubio_source_sndfile_do);
+    s->s_do_multi = (aubio_source_do_multi_t)(aubio_source_sndfile_do_multi);
+    s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_sndfile_get_channels);
+    s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_sndfile_get_samplerate);
+    s->s_seek = (aubio_source_seek_t)(aubio_source_sndfile_seek);
+    s->s_del = (del_aubio_source_t)(del_aubio_source_sndfile);
+    return s;
+  }
 #endif /* HAVE_SNDFILE */
-#endif /* __APPLE__ */
   AUBIO_ERROR("failed creating aubio source with %s\n", uri);
   AUBIO_FREE(s);
@@ -52,62 +95,26 @@
 
 void aubio_source_do(aubio_source_t * s, fvec_t * data, uint_t * read) {
-#ifdef __APPLE__
-  aubio_source_apple_audio_do((aubio_source_apple_audio_t *)s->source, data, read);
-#else /* __APPLE__ */
-#if HAVE_SNDFILE
-  aubio_source_sndfile_do((aubio_source_sndfile_t *)s->source, data, read);
-#endif /* HAVE_SNDFILE */
-#endif /* __APPLE__ */
+  s->s_do((void *)s->source, data, read);
 }
 
 void aubio_source_do_multi(aubio_source_t * s, fmat_t * data, uint_t * read) {
-#ifdef __APPLE__
-  aubio_source_apple_audio_do_multi((aubio_source_apple_audio_t *)s->source, data, read);
-#else /* __APPLE__ */
-#if HAVE_SNDFILE
-  aubio_source_sndfile_do_multi((aubio_source_sndfile_t *)s->source, data, read);
-#endif /* HAVE_SNDFILE */
-#endif /* __APPLE__ */
+  s->s_do_multi((void *)s->source, data, read);
 }
 
 void del_aubio_source(aubio_source_t * s) {
   if (!s) return;
-#ifdef __APPLE__
-  del_aubio_source_apple_audio((aubio_source_apple_audio_t *)s->source);
-#else /* __APPLE__ */
-#if HAVE_SNDFILE
-  del_aubio_source_sndfile((aubio_source_sndfile_t *)s->source);
-#endif /* HAVE_SNDFILE */
-#endif /* __APPLE__ */
+  s->s_del((void *)s->source);
   AUBIO_FREE(s);
 }
 
 uint_t aubio_source_get_samplerate(aubio_source_t * s) {
-#ifdef __APPLE__
-  return aubio_source_apple_audio_get_samplerate((aubio_source_apple_audio_t *)s->source);
-#else /* __APPLE__ */
-#if HAVE_SNDFILE
-  return aubio_source_sndfile_get_samplerate((aubio_source_sndfile_t *)s->source);
-#endif /* HAVE_SNDFILE */
-#endif /* __APPLE__ */
+  return s->s_get_samplerate((void *)s->source);
 }
 
 uint_t aubio_source_get_channels(aubio_source_t * s) {
-#ifdef __APPLE__
-  return aubio_source_apple_audio_get_channels((aubio_source_apple_audio_t *)s->source);
-#else /* __APPLE__ */
-#if HAVE_SNDFILE
-  return aubio_source_sndfile_get_channels((aubio_source_sndfile_t *)s->source);
-#endif /* HAVE_SNDFILE */
-#endif /* __APPLE__ */
+  return s->s_get_channels((void *)s->source);
 }
 
 uint_t aubio_source_seek (aubio_source_t * s, uint_t seek ) {
-#ifdef __APPLE__
-  return aubio_source_apple_audio_seek ((aubio_source_apple_audio_t *)s->source, seek);
-#else /* __APPLE__ */
-#if HAVE_SNDFILE
-  return aubio_source_sndfile_seek ((aubio_source_sndfile_t *)s->source, seek);
-#endif /* HAVE_SNDFILE */
-#endif /* __APPLE__ */
+  return s->s_seek((void *)s->source, seek);
 }
