summaryrefslogtreecommitdiff
path: root/src/lib/ecore_audio/ecore_audio_sndfile_vio.c
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/lib/ecore_audio/ecore_audio_sndfile_vio.c
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 '')
-rw-r--r--src/lib/ecore_audio/ecore_audio_sndfile_vio.c100
1 files changed, 100 insertions, 0 deletions
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
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