summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorSeunghun Lee <beauty.positive3@gmail.com>2015-06-22 10:23:54 -0400
committerChris Michael <cp.michael@samsung.com>2015-06-22 10:31:42 -0400
commit8b621775619b9959fe952b095b3baaa7aaa99572 (patch)
tree99059a841a79729cac4687ea41f3abf672e6e455 /src/examples
parent3671506ad39d2a956e388e151bd20f1b9ffd62a5 (diff)
ecore-buffer: Add ecore_buffer library to EFL.
Summary: Ecore_Buffer is abstraction of graphic buffer. it supports backend of shm, x11_dri2 and x11_dri3 for now, and this library also provides method to share buffers between processes. Ecore_Buffer_Provider and Ecore_Buffer_Consumer is for this, sharing buffer. provider draws something in to Ecore_Buffer, and consumer receives and displays it. the binary, bq_mgr is a connection maker for buffer provider and consumer. it can be included Enlightenment as a deamon later. @feature Test Plan: 1. Configure with --enable-ecore-buffer and --enable-always-build-examples to build examples. 2. Run bq_mgr, it connects consumer and provider. 3. Run ecore_buffer_provider_example and ecore_buffer_consumer_example Reviewers: lsj119, gwanglim, cedric, zmike, jpeg, raster, devilhorns Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2197
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/ecore/.gitignore3
-rw-r--r--src/examples/ecore/Makefile.am19
-rw-r--r--src/examples/ecore/ecore_buffer_consumer_example.c192
-rw-r--r--src/examples/ecore/ecore_buffer_example.c128
-rw-r--r--src/examples/ecore/ecore_buffer_provider_example.c274
5 files changed, 616 insertions, 0 deletions
diff --git a/src/examples/ecore/.gitignore b/src/examples/ecore/.gitignore
index acc3750839..8b84fca973 100644
--- a/src/examples/ecore/.gitignore
+++ b/src/examples/ecore/.gitignore
@@ -43,3 +43,6 @@
43/ecore_thread_example 43/ecore_thread_example
44/ecore_time_functions_example 44/ecore_time_functions_example
45/ecore_timer_example 45/ecore_timer_example
46/ecore_buffer_example
47/ecore_buffer_consumer_example
48/ecore_buffer_provider_example
diff --git a/src/examples/ecore/Makefile.am b/src/examples/ecore/Makefile.am
index f73c4f9e3b..179408e369 100644
--- a/src/examples/ecore/Makefile.am
+++ b/src/examples/ecore/Makefile.am
@@ -8,6 +8,7 @@ AM_CPPFLAGS = \
8-I$(top_srcdir)/src/lib/eo \ 8-I$(top_srcdir)/src/lib/eo \
9-I$(top_srcdir)/src/lib/evas \ 9-I$(top_srcdir)/src/lib/evas \
10-I$(top_srcdir)/src/lib/ecore \ 10-I$(top_srcdir)/src/lib/ecore \
11-I$(top_srcdir)/src/lib/ecore_buffer \
11-I$(top_srcdir)/src/lib/ecore_input \ 12-I$(top_srcdir)/src/lib/ecore_input \
12-I$(top_srcdir)/src/lib/ecore_input_evas \ 13-I$(top_srcdir)/src/lib/ecore_input_evas \
13-I$(top_srcdir)/src/lib/ecore_file \ 14-I$(top_srcdir)/src/lib/ecore_file \
@@ -35,6 +36,9 @@ AM_CPPFLAGS = \
35 36
36EXTRA_PROGRAMS = \ 37EXTRA_PROGRAMS = \
37ecore_animator_example \ 38ecore_animator_example \
39ecore_buffer_example \
40ecore_buffer_consumer_example \
41ecore_buffer_provider_example \
38ecore_client_bench \ 42ecore_client_bench \
39ecore_compose_get_example \ 43ecore_compose_get_example \
40ecore_con_client_example \ 44ecore_con_client_example \
@@ -112,6 +116,18 @@ $(ECORE_COMMON_LDADD)
112ecore_animator_example_SOURCES = ecore_animator_example.c 116ecore_animator_example_SOURCES = ecore_animator_example.c
113ecore_animator_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) 117ecore_animator_example_LDADD = $(ECORE_EVAS_COMMON_LDADD)
114 118
119ecore_buffer_example_SOURCES = ecore_buffer_example.c
120ecore_buffer_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) \
121 $(top_builddir)/src/lib/ecore_buffer/libecore_buffer.la
122
123ecore_buffer_consumer_example_SOURCES = ecore_buffer_consumer_example.c
124ecore_buffer_consumer_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) \
125 $(top_builddir)/src/lib/ecore_buffer/libecore_buffer.la
126
127ecore_buffer_provider_example_SOURCES = ecore_buffer_provider_example.c
128ecore_buffer_provider_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) \
129 $(top_builddir)/src/lib/ecore_buffer/libecore_buffer.la
130
115ecore_client_bench_SOURCES = ecore_client_bench.c 131ecore_client_bench_SOURCES = ecore_client_bench.c
116ecore_client_bench_LDADD = $(ECORE_CON_COMMON_LDADD) 132ecore_client_bench_LDADD = $(ECORE_CON_COMMON_LDADD)
117 133
@@ -249,6 +265,9 @@ ecore_con_eet_server_example_LDADD = $(ECORE_CON_COMMON_LDADD)
249 265
250SRCS = \ 266SRCS = \
251ecore_animator_example.c \ 267ecore_animator_example.c \
268ecore_buffer_example.c \
269ecore_buffer_consumer_example.c \
270ecore_buffer_provider_example.c \
252ecore_audio_custom.c \ 271ecore_audio_custom.c \
253ecore_audio_playback.c \ 272ecore_audio_playback.c \
254ecore_audio_to_ogg.c \ 273ecore_audio_to_ogg.c \
diff --git a/src/examples/ecore/ecore_buffer_consumer_example.c b/src/examples/ecore/ecore_buffer_consumer_example.c
new file mode 100644
index 0000000000..e24a3e2ff1
--- /dev/null
+++ b/src/examples/ecore/ecore_buffer_consumer_example.c
@@ -0,0 +1,192 @@
1#include <stdio.h>
2#include <Eina.h>
3#include <Ecore.h>
4#include <Ecore_Evas.h>
5#include <Ecore_Buffer.h>
6#include <Ecore_Buffer_Queue.h>
7#include <Evas.h>
8
9#ifdef DEBUG
10#define LOG(f, x...) printf("[CONSUMER|%30.30s|%04d] " f "\n", __func__, __LINE__, ##x)
11#else
12#define LOG(f, x...)
13#endif
14
15#define WIDTH 720
16#define HEIGHT 960
17
18typedef struct _Consumer_Data
19{
20 Ecore_Buffer_Consumer *consumer;
21 Ecore_Buffer *buffer;
22 Ecore_Job *render_job;
23 struct
24 {
25 Evas *e;
26 Ecore_Evas *ee;
27 Evas_Object *bg, *img;
28 } win;
29} Consumer_Data;
30
31const char *name = "ecore_buffer_queue_test";
32
33static void
34shutdown_all(void)
35{
36 ecore_buffer_queue_shutdown();
37 ecore_buffer_shutdown();
38 ecore_evas_shutdown();
39 ecore_shutdown();
40 eina_shutdown();
41}
42
43static Eina_Bool
44init_all(void)
45{
46 if (!eina_init()) goto err;
47 if (!ecore_init()) goto err;
48 if (!ecore_evas_init()) goto err;
49 if (!ecore_buffer_init()) goto err;
50 if (!ecore_buffer_queue_init()) goto err;
51
52 return EINA_TRUE;
53err:
54 shutdown_all();
55 return EINA_FALSE;
56}
57
58static void
59_cb_render_post(void *data, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
60{
61 Consumer_Data *cd = (Consumer_Data *)data;
62
63 if (cd->buffer)
64 {
65 ecore_buffer_consumer_buffer_release(cd->consumer, cd->buffer);
66 cd->buffer = NULL;
67 }
68}
69
70static void
71_consumer_cb_render_job(void *data)
72{
73 Consumer_Data *cd = (Consumer_Data *)data;
74 void *pixel_data;
75 unsigned int w, h;
76
77 LOG("Startup - Render");
78
79 if (!(cd->buffer = ecore_buffer_consumer_buffer_dequeue(cd->consumer)))
80 {
81 LOG("Failed to dequeue buffer");
82 goto end;
83 }
84
85 LOG("Success to get Compositable Buffer, "
86 "Drawing it to Consumer's Canvas now... - buffer:%p", cd->buffer);
87 // Get pixel data and set it to object.
88 pixel_data = ecore_buffer_data_get(cd->buffer);
89 ecore_buffer_size_get(cd->buffer, &w, &h);
90 evas_object_image_data_set(cd->win.img, pixel_data);
91 evas_object_image_data_update_add(cd->win.img, 0, 0, w, h);
92
93 ecore_job_del(cd->render_job);
94 cd->render_job = NULL;
95
96end:
97 LOG("Done - Render");
98}
99
100static void
101_consumer_render_queue(Consumer_Data *cd)
102{
103 if (!cd) return;
104
105 LOG("Render Queue");
106
107 if (!cd->render_job)
108 cd->render_job = ecore_job_add(_consumer_cb_render_job, cd);
109}
110
111static void
112_cb_provider_add(Ecore_Buffer_Consumer *consumer EINA_UNUSED, void *data EINA_UNUSED)
113{
114 LOG("Connected with Provider");
115}
116
117static void
118_cb_provider_del(Ecore_Buffer_Consumer *consumer EINA_UNUSED, void *data EINA_UNUSED)
119{
120 LOG("Disconnected with Provider, Shutdown Consumer now.");
121 ecore_main_loop_quit();
122}
123
124static void
125_cb_buffer_enqueued(Ecore_Buffer_Consumer *consumer EINA_UNUSED, void *data)
126{
127 Consumer_Data *cd = (Consumer_Data *)data;
128
129 LOG("Buffer Enqueued");
130
131 _consumer_render_queue(cd);
132}
133
134int
135main(void)
136{
137 Consumer_Data *cd;
138 Evas_Object *o;
139 const int queue_size = 3;
140
141 if (!init_all())
142 {
143 LOG("Initializing failed");
144 return -1;
145 }
146
147 cd = (Consumer_Data *)calloc(sizeof(Consumer_Data), 1);
148
149 if (!(cd->consumer = ecore_buffer_consumer_new(name, queue_size, WIDTH, HEIGHT)))
150 {
151 LOG("Failed to create consumer");
152 goto shutdown;
153 }
154
155 ecore_buffer_consumer_provider_add_cb_set(cd->consumer, _cb_provider_add, cd);
156 ecore_buffer_consumer_provider_del_cb_set(cd->consumer, _cb_provider_del, cd);
157 ecore_buffer_consumer_buffer_enqueued_cb_set(cd->consumer, _cb_buffer_enqueued, cd);
158
159 cd->win.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
160 cd->win.e = ecore_evas_get(cd->win.ee);
161
162 o = evas_object_rectangle_add(cd->win.e);
163 evas_object_move(o, 0, 0);
164 evas_object_resize(o, WIDTH, HEIGHT);
165 evas_object_color_set(o, 255, 0, 0, 255);
166 evas_object_show(o);
167 cd->win.bg = o;
168
169 o = evas_object_image_add(cd->win.e);
170 evas_object_image_fill_set(o, 0, 0, WIDTH, HEIGHT);
171 evas_object_image_size_set(o, WIDTH, HEIGHT);
172
173 evas_object_move(o, 0, 0);
174 evas_object_resize(o, WIDTH, HEIGHT);
175 evas_object_show(o);
176 cd->win.img = o;
177
178 ecore_evas_show(cd->win.ee);
179
180 evas_event_callback_add(cd->win.e, EVAS_CALLBACK_RENDER_POST, _cb_render_post, cd);
181
182 ecore_main_loop_begin();
183
184shutdown:
185 if (cd->win.ee) ecore_evas_free(cd->win.ee);
186 if (cd->buffer) ecore_buffer_consumer_buffer_release(cd->consumer, cd->buffer);
187 if (cd->consumer) ecore_buffer_consumer_free(cd->consumer);
188 if (cd) free(cd);
189
190 shutdown_all();
191 return 0;
192}
diff --git a/src/examples/ecore/ecore_buffer_example.c b/src/examples/ecore/ecore_buffer_example.c
new file mode 100644
index 0000000000..7ceeb1710e
--- /dev/null
+++ b/src/examples/ecore/ecore_buffer_example.c
@@ -0,0 +1,128 @@
1#include <stdio.h>
2#include <Eina.h>
3#include <Ecore.h>
4#include <Ecore_Evas.h>
5#include <Evas.h>
6#include <Ecore_Buffer.h>
7#include <Ecore_Buffer_Queue.h>
8
9#define WIDTH 720
10#define HEIGHT 960
11
12struct _Window
13{
14 Evas *e;
15 Ecore_Evas *ee;
16 Evas_Object *bg, *img;
17 Ecore_Buffer *buffer;
18};
19
20struct _Window win;
21Eina_List *hdls;
22
23static void
24paint_pixels(void *image, int padding, int width, int height, uint32_t time)
25{
26 const int halfh = padding + (height - padding * 2) / 2;
27 const int halfw = padding + (width - padding * 2) / 2;
28 int ir, or;
29 uint32_t *pixel = image;
30 int y;
31
32 /* squared radii thresholds */
33 or = (halfw < halfh ? halfw : halfh) - 8;
34 ir = or - 32;
35 or *= or;
36 ir *= ir;
37
38 pixel += padding * width;
39 for (y = padding; y < height - padding; y++) {
40 int x;
41 int y2 = (y - halfh) * (y - halfh);
42
43 pixel += padding;
44 for (x = padding; x < width - padding; x++) {
45 uint32_t v;
46
47 /* squared distance from center */
48 int r2 = (x - halfw) * (x - halfw) + y2;
49
50 if (r2 < ir)
51 v = (r2 / 32 + time / 64) * 0x0080401;
52 else if (r2 < or)
53 v = (y + time / 32) * 0x0080401;
54 else
55 v = (x + time / 16) * 0x0080401;
56 v &= 0x00ffffff;
57 v |= 0xff000000;
58
59 *pixel++ = v;
60 }
61
62 pixel += padding;
63 }
64}
65
66static void
67_cb_post_render(Ecore_Evas *ee EINA_UNUSED)
68{
69 void *data;
70
71 // Get pixel data and update.
72 data = ecore_buffer_data_get(win.buffer);
73 paint_pixels(data, 0, WIDTH, HEIGHT, ecore_loop_time_get() * 1000);
74 evas_object_image_data_set(win.img, data);
75 evas_object_image_data_update_add(win.img, 0, 0, WIDTH, HEIGHT);
76}
77
78int
79main(void)
80{
81 Evas_Object *o;
82 void *data;
83
84 eina_init();
85 ecore_init();
86 ecore_evas_init();
87 ecore_buffer_init();
88
89 win.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
90 win.e = ecore_evas_get(win.ee);
91
92 o = evas_object_rectangle_add(win.e);
93 evas_object_move(o, 0, 0);
94 evas_object_resize(o, WIDTH, HEIGHT);
95 evas_object_color_set(o, 255, 0, 0, 255);
96 evas_object_show(o);
97 win.bg = o;
98
99 o = evas_object_image_add(win.e);
100 evas_object_image_fill_set(o, 0, 0, WIDTH, HEIGHT);
101 evas_object_image_size_set(o, WIDTH, HEIGHT);
102
103 evas_object_move(o, 0, 0);
104 evas_object_resize(o, WIDTH, HEIGHT);
105 evas_object_show(o);
106 win.img = o;
107
108 // Create buffer and drawing.
109 win.buffer = ecore_buffer_new("shm", WIDTH, HEIGHT, 0, 0);
110 data = ecore_buffer_data_get(win.buffer);
111 paint_pixels(data, 0, WIDTH, HEIGHT, 0);
112 evas_object_image_data_set(win.img, data);
113 evas_object_image_data_update_add(win.img, 0, 0, WIDTH, HEIGHT);
114
115 ecore_evas_show(win.ee);
116
117 ecore_evas_callback_post_render_set(win.ee, _cb_post_render);
118
119 ecore_main_loop_begin();
120
121 ecore_buffer_free(win.buffer);
122 ecore_buffer_shutdown();
123 ecore_evas_shutdown();
124 ecore_shutdown();
125 eina_shutdown();
126
127 return 0;
128}
diff --git a/src/examples/ecore/ecore_buffer_provider_example.c b/src/examples/ecore/ecore_buffer_provider_example.c
new file mode 100644
index 0000000000..112854b4dc
--- /dev/null
+++ b/src/examples/ecore/ecore_buffer_provider_example.c
@@ -0,0 +1,274 @@
1#include <stdio.h>
2#include <Eina.h>
3#include <Ecore.h>
4#include <Ecore_Evas.h>
5#include <Ecore_Buffer.h>
6#include <Ecore_Buffer_Queue.h>
7#include <Evas.h>
8
9#ifdef DEBUG
10#define LOG(f, x...) printf("[PROVIDER|%30.30s|%04d] " f "\n", __func__, __LINE__, ##x)
11#else
12#define LOG(f, x...)
13#endif
14
15typedef struct _Provider_Data
16{
17 Ecore_Buffer_Provider *provider;
18 Ecore_Buffer *buffer;
19 Eina_List *buffer_list;
20 Ecore_Job *render_job;
21 Ecore_Idle_Enterer *post_render;
22 unsigned int w, h;
23} Provider_Data;
24
25const char *name = "ecore_buffer_queue_test";
26
27static void _provider_render_queue(Provider_Data *pd);
28
29static void
30shutdown_all(void)
31{
32 ecore_buffer_queue_shutdown();
33 ecore_buffer_shutdown();
34 ecore_evas_shutdown();
35 ecore_shutdown();
36 eina_shutdown();
37}
38
39static Eina_Bool
40init_all(void)
41{
42 if (!eina_init()) goto err;
43 if (!ecore_init()) goto err;
44 if (!ecore_evas_init()) goto err;
45 if (!ecore_buffer_init()) goto err;
46 if (!ecore_buffer_queue_init()) goto err;
47
48 return EINA_TRUE;
49err:
50 shutdown_all();
51 return EINA_FALSE;
52}
53
54Ecore_Buffer *
55_provider_buffer_get(Provider_Data *pd, unsigned int w, unsigned int h, unsigned int format)
56{
57 Ecore_Buffer *buffer = NULL;
58 Ecore_Buffer_Return ret;
59 unsigned int res_w, res_h, res_format;
60
61 LOG("Dequeue");
62 ret = ecore_buffer_provider_buffer_acquire(pd->provider, &buffer);
63
64 if (ret == ECORE_BUFFER_RETURN_NEED_ALLOC)
65 {
66 buffer = ecore_buffer_new("shm", w, h, format, 0);
67 pd->buffer_list = eina_list_append(pd->buffer_list, buffer);
68 LOG("No buffer in Queue, Create Buffer");
69 }
70 else if (ret == ECORE_BUFFER_RETURN_SUCCESS)
71 {
72 ecore_buffer_size_get(buffer, &res_w, &res_h);
73 res_format = ecore_buffer_format_get(buffer);
74 if ((res_w != w) || (res_h != h) || (res_format != format))
75 {
76 LOG("Need to Reallocate Buffer, Free it First: %p", buffer);
77 pd->buffer_list = eina_list_remove(pd->buffer_list, buffer);
78 ecore_buffer_free(buffer);
79
80 buffer = ecore_buffer_new("shm", w, h, format, 0);
81 pd->buffer_list = eina_list_append(pd->buffer_list, buffer);
82 LOG("Create Buffer: %p", buffer);
83 }
84 }
85
86 return buffer;
87}
88
89static void
90paint_pixels(void *image, int padding, int width, int height, uint32_t time)
91{
92 const int halfh = padding + (height - padding * 2) / 2;
93 const int halfw = padding + (width - padding * 2) / 2;
94 int ir, or;
95 uint32_t *pixel = image;
96 int y;
97
98 /* squared radii thresholds */
99 or = (halfw < halfh ? halfw : halfh) - 8;
100 ir = or - 32;
101 or *= or;
102 ir *= ir;
103
104 pixel += padding * width;
105 for (y = padding; y < height - padding; y++) {
106 int x;
107 int y2 = (y - halfh) * (y - halfh);
108
109 pixel += padding;
110 for (x = padding; x < width - padding; x++) {
111 uint32_t v;
112
113 /* squared distance from center */
114 int r2 = (x - halfw) * (x - halfw) + y2;
115
116 if (r2 < ir)
117 v = (r2 / 32 + time / 64) * 0x0080401;
118 else if (r2 < or)
119 v = (y + time / 32) * 0x0080401;
120 else
121 v = (x + time / 16) * 0x0080401;
122 v &= 0x00ffffff;
123 v |= 0xff000000;
124
125 *pixel++ = v;
126 }
127
128 pixel += padding;
129 }
130}
131
132static Eina_Bool
133_cb_render_post(void *data)
134{
135 Provider_Data *pd = (Provider_Data *)data;
136 Ecore_Buffer *next_buffer = NULL;
137
138 LOG("Startup - Post Render");
139
140 LOG("Submit Buffer - buffer: %p", pd->buffer);
141 ecore_buffer_provider_buffer_enqueue(pd->provider, pd->buffer);
142 pd->buffer = NULL;
143
144 next_buffer = _provider_buffer_get(pd, pd->w, pd->h, ECORE_BUFFER_FORMAT_XRGB8888);
145 if (next_buffer)
146 {
147 LOG("Drawable Buffer is Existed, ADD Render job again - buffer:%p", next_buffer);
148 pd->buffer = next_buffer;
149 _provider_render_queue(pd);
150 }
151
152 ecore_idle_enterer_del(pd->post_render);
153 pd->post_render = NULL;
154
155 LOG("Done - Post Render");
156
157 return ECORE_CALLBACK_RENEW;
158}
159
160static void
161_provider_cb_render_job(void *data)
162{
163 Provider_Data *pd = (Provider_Data *)data;
164
165 LOG("Startup - Render");
166
167 if (!pd->buffer)
168 {
169 pd->buffer = _provider_buffer_get(pd,
170 pd->w, pd->h, ECORE_BUFFER_FORMAT_XRGB8888);
171 }
172
173 if (pd->buffer)
174 {
175 void *data;
176
177 LOG("Success to get Drawable Buffer, Drawing now... - buffer:%p", pd->buffer);
178 // Drawing...
179 data = ecore_buffer_data_get(pd->buffer);
180 paint_pixels(data, 0, pd->w, pd->h, ecore_loop_time_get() * 1000);
181
182 if (!pd->post_render)
183 {
184 pd->post_render =
185 ecore_idle_enterer_before_add(_cb_render_post, pd);
186 }
187 }
188
189 ecore_job_del(pd->render_job);
190 pd->render_job = NULL;
191}
192
193static void
194_provider_render_queue(Provider_Data *pd)
195{
196 if (!pd) return;
197
198 LOG("Render Queue");
199
200 if (!pd->render_job)
201 pd->render_job = ecore_job_add(_provider_cb_render_job, pd);
202}
203
204static void
205_cb_consumer_add(Ecore_Buffer_Provider *provider EINA_UNUSED, int queue_size EINA_UNUSED, int w, int h, void *data)
206{
207 Provider_Data *pd = (Provider_Data *)data;
208
209 LOG("Connected with Consumer, Now We can use Ecore_Buffer_Queue - queue_size:%d, geo(%dx%d)",
210 queue_size, w, h);
211
212 pd->w = w;
213 pd->h = h;
214
215 _provider_render_queue(pd);
216}
217
218static void
219_cb_consumer_del(Ecore_Buffer_Provider *provider EINA_UNUSED, void *data EINA_UNUSED)
220{
221 LOG("Disconnected with Consumer, Shutdown Provider now.");
222
223 ecore_main_loop_quit();
224}
225
226static void
227_cb_buffer_released(Ecore_Buffer_Provider *provider EINA_UNUSED, void *data)
228{
229 Provider_Data *pd = (Provider_Data *)data;
230
231 LOG("Buffer Enqueued");
232
233 _provider_render_queue(pd);
234}
235
236int
237main(void)
238{
239 Provider_Data *pd;
240
241 if (!init_all())
242 {
243 LOG("Initializing failed");
244 return -1;
245 }
246
247 pd = (Provider_Data *)calloc(sizeof(Provider_Data), 1);
248
249 if (!(pd->provider = ecore_buffer_provider_new(name)))
250 {
251 LOG("Failed to create provider");
252 goto shutdown;
253 }
254
255 ecore_buffer_provider_consumer_add_cb_set(pd->provider, _cb_consumer_add, pd);
256 ecore_buffer_provider_consumer_del_cb_set(pd->provider, _cb_consumer_del, pd);
257 ecore_buffer_provider_buffer_released_cb_set(pd->provider, _cb_buffer_released, pd);
258
259 ecore_main_loop_begin();
260
261shutdown:
262 if (pd->buffer_list)
263 {
264 Ecore_Buffer *b;
265
266 EINA_LIST_FREE(pd->buffer_list, b)
267 ecore_buffer_free(b);
268 }
269 if (pd->provider) ecore_buffer_provider_free(pd->provider);
270 if (pd) free(pd);
271
272 shutdown_all();
273 return 0;
274}