diff options
author | Daniel Willmann <d.willmann@samsung.com> | 2013-04-26 18:17:03 +0100 |
---|---|---|
committer | Daniel Willmann <d.willmann@samsung.com> | 2013-04-26 18:49:24 +0100 |
commit | 3fdc608da16d5071a5b0f3a2b3be4a1e2f7124bc (patch) | |
tree | 8cf428c43479c6784d7291b2b04bd953b37a063f /src/lib/ecore_audio | |
parent | 3b70c0bc83552a26b89879aed42293de1e00b090 (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/lib/ecore_audio')
-rw-r--r-- | src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c | 74 | ||||
-rw-r--r-- | src/lib/ecore_audio/ecore_audio_obj_out_sndfile.c | 2 | ||||
-rw-r--r-- | src/lib/ecore_audio/ecore_audio_sndfile_vio.c | 100 |
3 files changed, 104 insertions, 72 deletions
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 eee40c41d2..33aff76398 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 | ||
22 | extern SF_VIRTUAL_IO vio_wrapper; | ||
23 | |||
22 | struct _Ecore_Audio_Sndfile | 24 | struct _Ecore_Audio_Sndfile |
23 | { | 25 | { |
24 | SNDFILE *handle; | 26 | SNDFILE *handle; |
@@ -27,78 +29,6 @@ struct _Ecore_Audio_Sndfile | |||
27 | 29 | ||
28 | typedef struct _Ecore_Audio_Sndfile Ecore_Audio_Sndfile; | 30 | typedef struct _Ecore_Audio_Sndfile Ecore_Audio_Sndfile; |
29 | 31 | ||
30 | /* Virtual IO wrapper functions */ | ||
31 | |||
32 | static 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 | |||
43 | error: | ||
44 | return -1; | ||
45 | } | ||
46 | |||
47 | static 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 | |||
58 | error: | ||
59 | return -1; | ||
60 | } | ||
61 | |||
62 | static 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 | |||
73 | error: | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static 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 | |||
88 | error: | ||
89 | return -1; | ||
90 | } | ||
91 | |||
92 | static 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 | |||
102 | static void _read(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list) | 32 | static 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 68c2a3d84f..0d62283793 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 | ||
22 | extern SF_VIRTUAL_IO vio_wrapper; | ||
23 | |||
22 | struct _Ecore_Audio_Sndfile | 24 | struct _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 0000000000..06268069aa --- /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 | |||
16 | static 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 | |||
27 | error: | ||
28 | return -1; | ||
29 | } | ||
30 | |||
31 | static 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 | |||
42 | error: | ||
43 | return -1; | ||
44 | } | ||
45 | |||
46 | static 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 | |||
57 | error: | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | static 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 | |||
72 | error: | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static 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 | |||
87 | error: | ||
88 | return -1; | ||
89 | } | ||
90 | |||
91 | SF_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 | |||