asdfuser pushed a commit to branch master.
commit 3fdc608da16d5071a5b0f3a2b3be4a1e2f7124bc
Author: Daniel Willmann <[email protected]>
Date: Fri Apr 26 18:17:03 2013 +0100
ecore_audio: Move sndfile VIO into a file to access from in- and output
The VIO wrapper functions are needed from the sndfile inputs and outputs
so move them to a separate file and access from both.
Signed-off-by: Daniel Willmann <[email protected]>
---
src/Makefile_Ecore_Audio.am | 3 +-
src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c | 74 +---------------
src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c | 2 +
src/lib/ecore_audio/ecore_audio_sndfile_vio.c | 100 ++++++++++++++++++++++
4 files changed, 106 insertions(+), 73 deletions(-)
diff --git a/src/Makefile_Ecore_Audio.am b/src/Makefile_Ecore_Audio.am
index b224906..35a414c 100644
--- a/src/Makefile_Ecore_Audio.am
+++ b/src/Makefile_Ecore_Audio.am
@@ -43,7 +43,8 @@ lib/ecore_audio/ecore_audio_obj_out_sndfile.h
lib_ecore_audio_libecore_audio_la_SOURCES += \
lib/ecore_audio/ecore_audio_obj_in_sndfile.c \
-lib/ecore_audio/ecore_audio_obj_out_sndfile.c
+lib/ecore_audio/ecore_audio_obj_out_sndfile.c \
+lib/ecore_audio/ecore_audio_sndfile_vio.c
endif
endif
diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
b/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
index eee40c4..33aff76 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
@@ -19,6 +19,8 @@ EAPI Eo_Op ECORE_AUDIO_OBJ_IN_SNDFILE_BASE_ID = EO_NOOP;
#define MY_CLASS ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS
#define MY_CLASS_NAME "ecore_audio_obj_in_sndfile"
+extern SF_VIRTUAL_IO vio_wrapper;
+
struct _Ecore_Audio_Sndfile
{
SNDFILE *handle;
@@ -27,78 +29,6 @@ struct _Ecore_Audio_Sndfile
typedef struct _Ecore_Audio_Sndfile Ecore_Audio_Sndfile;
-/* Virtual IO wrapper functions */
-
-static sf_count_t _wrap_get_filelen(void *data)
-{
- Eo *eo_obj = data;
- Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
-
- if (!ea_obj->vio->vio)
- goto error;
-
- if (ea_obj->vio->vio->get_length)
- return ea_obj->vio->vio->get_length(ea_obj->vio->data, eo_obj);
-
-error:
- return -1;
-}
-
-static sf_count_t _wrap_seek(sf_count_t offset, int whence, void *data)
-{
- Eo *eo_obj = data;
- Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
-
- if (!ea_obj->vio->vio)
- goto error;
-
- if (ea_obj->vio->vio->seek)
- return ea_obj->vio->vio->seek(ea_obj->vio->data, eo_obj, offset, whence);
-
-error:
- return -1;
-}
-
-static sf_count_t _wrap_read(void *buffer, sf_count_t count, void *data)
-{
- Eo *eo_obj = data;
- Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
-
- if (!ea_obj->vio->vio)
- goto error;
-
- if (ea_obj->vio->vio->read)
- return ea_obj->vio->vio->read(ea_obj->vio->data, eo_obj, buffer, count);
-
-error:
- return 0;
-}
-
-static sf_count_t _wrap_tell(void *data)
-{
- Eo *eo_obj = data;
- Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
-
- if (!ea_obj->vio->vio)
- goto error;
-
- if (ea_obj->vio->vio->tell)
- return ea_obj->vio->vio->tell(ea_obj->vio->data, eo_obj);
-
-error:
- return -1;
-}
-
-static SF_VIRTUAL_IO vio_wrapper = {
- .get_filelen = _wrap_get_filelen,
- .seek = _wrap_seek,
- .read = _wrap_read,
- .write = NULL,
- .tell = _wrap_tell,
-};
-
-/* End virtual IO wrapper functions */
-
static void _read(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
{
Ecore_Audio_Sndfile *obj = _pd;
diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
index 68c2a3d..0d62283 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c
@@ -19,6 +19,8 @@ EAPI Eo_Op ECORE_AUDIO_OBJ_OUT_SNDFILE_BASE_ID = EO_NOOP;
#define MY_CLASS ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS
#define MY_CLASS_NAME "ecore_audio_obj_out_sndfile"
+extern SF_VIRTUAL_IO vio_wrapper;
+
struct _Ecore_Audio_Sndfile
{
SNDFILE *handle;
diff --git a/src/lib/ecore_audio/ecore_audio_sndfile_vio.c
b/src/lib/ecore_audio/ecore_audio_sndfile_vio.c
new file mode 100644
index 0000000..0626806
--- /dev/null
+++ b/src/lib/ecore_audio/ecore_audio_sndfile_vio.c
@@ -0,0 +1,100 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_FEATURES_H
+#include <features.h>
+#endif
+
+#include <Eo.h>
+
+#include "ecore_audio_private.h"
+#include <sndfile.h>
+
+/* Virtual IO wrapper functions */
+
+static sf_count_t _wrap_get_filelen(void *data)
+{
+ Eo *eo_obj = data;
+ Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
+
+ if (!ea_obj->vio->vio)
+ goto error;
+
+ if (ea_obj->vio->vio->get_length)
+ return ea_obj->vio->vio->get_length(ea_obj->vio->data, eo_obj);
+
+error:
+ return -1;
+}
+
+static sf_count_t _wrap_seek(sf_count_t offset, int whence, void *data)
+{
+ Eo *eo_obj = data;
+ Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
+
+ if (!ea_obj->vio->vio)
+ goto error;
+
+ if (ea_obj->vio->vio->seek)
+ return ea_obj->vio->vio->seek(ea_obj->vio->data, eo_obj, offset, whence);
+
+error:
+ return -1;
+}
+
+static sf_count_t _wrap_read(void *buffer, sf_count_t count, void *data)
+{
+ Eo *eo_obj = data;
+ Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
+
+ if (!ea_obj->vio->vio)
+ goto error;
+
+ if (ea_obj->vio->vio->read)
+ return ea_obj->vio->vio->read(ea_obj->vio->data, eo_obj, buffer, count);
+
+error:
+ return 0;
+}
+
+static sf_count_t _wrap_write(const void *buffer, sf_count_t count, void *data)
+{
+ Eo *eo_obj = data;
+ Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
+
+ if (!ea_obj->vio->vio)
+ goto error;
+
+ if (ea_obj->vio->vio->write)
+ return ea_obj->vio->vio->write(ea_obj->vio->data, eo_obj, buffer, count);
+
+error:
+ return 0;
+}
+
+static sf_count_t _wrap_tell(void *data)
+{
+ Eo *eo_obj = data;
+ Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
+
+ if (!ea_obj->vio->vio)
+ goto error;
+
+ if (ea_obj->vio->vio->tell)
+ return ea_obj->vio->vio->tell(ea_obj->vio->data, eo_obj);
+
+error:
+ return -1;
+}
+
+SF_VIRTUAL_IO vio_wrapper = {
+ .get_filelen = _wrap_get_filelen,
+ .seek = _wrap_seek,
+ .read = _wrap_read,
+ .write = _wrap_write,
+ .tell = _wrap_tell,
+};
+
+/* End virtual IO wrapper functions */
+
--
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr