summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Willmann <d.willmann@samsung.com>2013-04-26 18:17:03 +0100
committerDaniel Willmann <d.willmann@samsung.com>2013-04-26 18:49:24 +0100
commit3fdc608da16d5071a5b0f3a2b3be4a1e2f7124bc (patch)
tree8cf428c43479c6784d7291b2b04bd953b37a063f /src
parent3b70c0bc83552a26b89879aed42293de1e00b090 (diff)
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 <d.willmann@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Ecore_Audio.am3
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c74
-rw-r--r--src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c2
-rw-r--r--src/lib/ecore_audio/ecore_audio_sndfile_vio.c100
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
43 43
44lib_ecore_audio_libecore_audio_la_SOURCES += \ 44lib_ecore_audio_libecore_audio_la_SOURCES += \
45lib/ecore_audio/ecore_audio_obj_in_sndfile.c \ 45lib/ecore_audio/ecore_audio_obj_in_sndfile.c \
46lib/ecore_audio/ecore_audio_obj_out_sndfile.c 46lib/ecore_audio/ecore_audio_obj_out_sndfile.c \
47lib/ecore_audio/ecore_audio_sndfile_vio.c
47endif 48endif
48 49
49endif 50endif
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;
19#define MY_CLASS ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS 19#define MY_CLASS ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS
20#define MY_CLASS_NAME "ecore_audio_obj_in_sndfile" 20#define MY_CLASS_NAME "ecore_audio_obj_in_sndfile"
21 21
22extern SF_VIRTUAL_IO vio_wrapper;
23
22struct _Ecore_Audio_Sndfile 24struct _Ecore_Audio_Sndfile
23{ 25{
24 SNDFILE *handle; 26 SNDFILE *handle;
@@ -27,78 +29,6 @@ struct _Ecore_Audio_Sndfile
27 29
28typedef struct _Ecore_Audio_Sndfile Ecore_Audio_Sndfile; 30typedef struct _Ecore_Audio_Sndfile Ecore_Audio_Sndfile;
29 31
30/* Virtual IO wrapper functions */
31
32static sf_count_t _wrap_get_filelen(void *data)
33{
34 Eo *eo_obj = data;
35 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
36
37 if (!ea_obj->vio->vio)
38 goto error;
39
40 if (ea_obj->vio->vio->get_length)
41 return ea_obj->vio->vio->get_length(ea_obj->vio->data, eo_obj);
42
43error:
44 return -1;
45}
46
47static sf_count_t _wrap_seek(sf_count_t offset, int whence, void *data)
48{
49 Eo *eo_obj = data;
50 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
51
52 if (!ea_obj->vio->vio)
53 goto error;
54
55 if (ea_obj->vio->vio->seek)
56 return ea_obj->vio->vio->seek(ea_obj->vio->data, eo_obj, offset, whence);
57
58error:
59 return -1;
60}
61
62static sf_count_t _wrap_read(void *buffer, sf_count_t count, void *data)
63{
64 Eo *eo_obj = data;
65 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
66
67 if (!ea_obj->vio->vio)
68 goto error;
69
70 if (ea_obj->vio->vio->read)
71 return ea_obj->vio->vio->read(ea_obj->vio->data, eo_obj, buffer, count);
72
73error:
74 return 0;
75}
76
77static sf_count_t _wrap_tell(void *data)
78{
79 Eo *eo_obj = data;
80 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
81
82 if (!ea_obj->vio->vio)
83 goto error;
84
85 if (ea_obj->vio->vio->tell)
86 return ea_obj->vio->vio->tell(ea_obj->vio->data, eo_obj);
87
88error:
89 return -1;
90}
91
92static SF_VIRTUAL_IO vio_wrapper = {
93 .get_filelen = _wrap_get_filelen,
94 .seek = _wrap_seek,
95 .read = _wrap_read,
96 .write = NULL,
97 .tell = _wrap_tell,
98};
99
100/* End virtual IO wrapper functions */
101
102static void _read(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list) 32static void _read(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
103{ 33{
104 Ecore_Audio_Sndfile *obj = _pd; 34 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;
19#define MY_CLASS ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS 19#define MY_CLASS ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS
20#define MY_CLASS_NAME "ecore_audio_obj_out_sndfile" 20#define MY_CLASS_NAME "ecore_audio_obj_out_sndfile"
21 21
22extern SF_VIRTUAL_IO vio_wrapper;
23
22struct _Ecore_Audio_Sndfile 24struct _Ecore_Audio_Sndfile
23{ 25{
24 SNDFILE *handle; 26 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 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#ifdef HAVE_FEATURES_H
6#include <features.h>
7#endif
8
9#include <Eo.h>
10
11#include "ecore_audio_private.h"
12#include <sndfile.h>
13
14/* Virtual IO wrapper functions */
15
16static sf_count_t _wrap_get_filelen(void *data)
17{
18 Eo *eo_obj = data;
19 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
20
21 if (!ea_obj->vio->vio)
22 goto error;
23
24 if (ea_obj->vio->vio->get_length)
25 return ea_obj->vio->vio->get_length(ea_obj->vio->data, eo_obj);
26
27error:
28 return -1;
29}
30
31static sf_count_t _wrap_seek(sf_count_t offset, int whence, void *data)
32{
33 Eo *eo_obj = data;
34 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
35
36 if (!ea_obj->vio->vio)
37 goto error;
38
39 if (ea_obj->vio->vio->seek)
40 return ea_obj->vio->vio->seek(ea_obj->vio->data, eo_obj, offset, whence);
41
42error:
43 return -1;
44}
45
46static sf_count_t _wrap_read(void *buffer, sf_count_t count, void *data)
47{
48 Eo *eo_obj = data;
49 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
50
51 if (!ea_obj->vio->vio)
52 goto error;
53
54 if (ea_obj->vio->vio->read)
55 return ea_obj->vio->vio->read(ea_obj->vio->data, eo_obj, buffer, count);
56
57error:
58 return 0;
59}
60
61static sf_count_t _wrap_write(const void *buffer, sf_count_t count, void *data)
62{
63 Eo *eo_obj = data;
64 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
65
66 if (!ea_obj->vio->vio)
67 goto error;
68
69 if (ea_obj->vio->vio->write)
70 return ea_obj->vio->vio->write(ea_obj->vio->data, eo_obj, buffer, count);
71
72error:
73 return 0;
74}
75
76static sf_count_t _wrap_tell(void *data)
77{
78 Eo *eo_obj = data;
79 Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
80
81 if (!ea_obj->vio->vio)
82 goto error;
83
84 if (ea_obj->vio->vio->tell)
85 return ea_obj->vio->vio->tell(ea_obj->vio->data, eo_obj);
86
87error:
88 return -1;
89}
90
91SF_VIRTUAL_IO vio_wrapper = {
92 .get_filelen = _wrap_get_filelen,
93 .seek = _wrap_seek,
94 .read = _wrap_read,
95 .write = _wrap_write,
96 .tell = _wrap_tell,
97};
98
99/* End virtual IO wrapper functions */
100