summaryrefslogtreecommitdiff
path: root/src/examples/ecore
diff options
context:
space:
mode:
authorDaniel Willmann <d.willmann@samsung.com>2012-12-14 23:38:35 +0000
committerDaniel Willmann <daniel@totalueberwachung.de>2012-12-14 23:38:35 +0000
commit1c68e42f251f93137b9abad151d6375f991c333a (patch)
treec64ab07280b832f97ae8479ddbb60ef7cf0b5ee3 /src/examples/ecore
parent55f6091e3d0b971d9c2ccad8c810aca075f25279 (diff)
ecore_audio: Add an example for libsndfile output: ogg encoder
Signed-off-by: Daniel Willmann <d.willmann@samsung.com> SVN revision: 81003
Diffstat (limited to 'src/examples/ecore')
-rw-r--r--src/examples/ecore/Makefile.am13
-rw-r--r--src/examples/ecore/ecore_audio_to_ogg.c69
2 files changed, 80 insertions, 2 deletions
diff --git a/src/examples/ecore/Makefile.am b/src/examples/ecore/Makefile.am
index a91d874dd2..b23dfeb466 100644
--- a/src/examples/ecore/Makefile.am
+++ b/src/examples/ecore/Makefile.am
@@ -54,7 +54,8 @@ ecore_timer_example
54if HAVE_ECORE_AUDIO 54if HAVE_ECORE_AUDIO
55EXTRA_PROGRAMS += \ 55EXTRA_PROGRAMS += \
56ecore_audio_custom \ 56ecore_audio_custom \
57ecore_audio_playback 57ecore_audio_playback \
58ecore_audio_to_ogg
58 59
59ecore_audio_custom_SOURCES = ecore_audio_custom.c 60ecore_audio_custom_SOURCES = ecore_audio_custom.c
60ecore_audio_custom_LDADD = $(top_builddir)/src/lib/ecore_audio/libecore_audio.la $(top_builddir)/src/lib/ecore/libecore.la $(top_builddir)/src/lib/eina/libeina.la @ECORE_LIBS@ 61ecore_audio_custom_LDADD = $(top_builddir)/src/lib/ecore_audio/libecore_audio.la $(top_builddir)/src/lib/ecore/libecore.la $(top_builddir)/src/lib/eina/libeina.la @ECORE_LIBS@
@@ -62,6 +63,8 @@ ecore_audio_custom_LDADD = $(top_builddir)/src/lib/ecore_audio/libecore_audio.la
62ecore_audio_playback_SOURCES = ecore_audio_playback.c 63ecore_audio_playback_SOURCES = ecore_audio_playback.c
63ecore_audio_playback_LDADD = $(top_builddir)/src/lib/ecore_audio/libecore_audio.la $(top_builddir)/src/lib/ecore/libecore.la $(top_builddir)/src/lib/eina/libeina.la @ECORE_LIBS@ 64ecore_audio_playback_LDADD = $(top_builddir)/src/lib/ecore_audio/libecore_audio.la $(top_builddir)/src/lib/ecore/libecore.la $(top_builddir)/src/lib/eina/libeina.la @ECORE_LIBS@
64 65
66ecore_audio_to_ogg_SOURCES = ecore_audio_to_ogg.c
67ecore_audio_to_ogg_LDADD = $(top_builddir)/src/lib/ecore_audio/libecore_audio.la $(top_builddir)/src/lib/ecore/libecore.la $(top_builddir)/src/lib/eina/libeina.la @ECORE_LIBS@
65endif 68endif
66 69
67ecore_animator_example_SOURCES = ecore_animator_example.c 70ecore_animator_example_SOURCES = ecore_animator_example.c
@@ -153,7 +156,6 @@ ecore_timer_example_LDADD = $(top_builddir)/src/lib/ecore/libecore.la @ECORE_LIB
153 156
154SRCS = \ 157SRCS = \
155ecore_animator_example \ 158ecore_animator_example \
156ecore_audio_playback \
157ecore_client_bench \ 159ecore_client_bench \
158ecore_con_client_simple_example \ 160ecore_con_client_simple_example \
159ecore_con_lookup_example \ 161ecore_con_lookup_example \
@@ -183,6 +185,13 @@ ecore_thread_example \
183ecore_time_functions_example \ 185ecore_time_functions_example \
184ecore_timer_example 186ecore_timer_example
185 187
188if HAVE_ECORE_AUDIO
189SRCS += \
190ecore_audio_custom \
191ecore_audio_playback \
192ecore_audio_to_ogg
193endif
194
186EXTRA_DIST = red.png 195EXTRA_DIST = red.png
187 196
188examples: $(EXTRA_PROGRAMS) 197examples: $(EXTRA_PROGRAMS)
diff --git a/src/examples/ecore/ecore_audio_to_ogg.c b/src/examples/ecore/ecore_audio_to_ogg.c
new file mode 100644
index 0000000000..120f9f91f4
--- /dev/null
+++ b/src/examples/ecore/ecore_audio_to_ogg.c
@@ -0,0 +1,69 @@
1#include <stdio.h>
2#include <libgen.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <unistd.h>
6#include <fcntl.h>
7#include <Ecore.h>
8#include <Ecore_Audio.h>
9#include <Eina.h>
10
11Ecore_Audio_Object *out = NULL;
12double volume = 1;
13Eina_List *inputs = NULL;
14
15static Eina_Bool _play_finished(void *data, int type, void *event)
16{
17 Ecore_Audio_Object *in = (Ecore_Audio_Object *)event;
18
19 printf("Done: %s\n", ecore_audio_input_name_get(in));
20
21 ecore_audio_output_input_del(out, in);
22 ecore_audio_input_del(in);
23 ecore_audio_output_del(out);
24
25 ecore_main_loop_quit();
26
27 return EINA_TRUE;
28}
29
30int
31main(int argc, const char *argv[])
32{
33
34 Ecore_Audio_Object *in;
35
36 if (argc < 2)
37 {
38 printf("Please provide a filename\n");
39 exit(EXIT_FAILURE);
40 }
41
42 ecore_init();
43 ecore_audio_init();
44
45 ecore_event_handler_add(ECORE_AUDIO_INPUT_ENDED, _play_finished, NULL);
46
47 in = ecore_audio_input_add(ECORE_AUDIO_TYPE_SNDFILE);
48 ecore_audio_input_name_set(in, basename(argv[1]));
49 ecore_audio_input_sndfile_filename_set(in, argv[1]);
50 if (!in)
51 {
52 printf("error when creating ecore audio source.\n");
53 goto end;
54 }
55
56 out = ecore_audio_output_add(ECORE_AUDIO_TYPE_SNDFILE);
57 ecore_audio_output_sndfile_filename_set(out, "foo.ogg");
58
59 ecore_audio_output_input_add(out, in);
60
61 ecore_main_loop_begin();
62
63end:
64 ecore_audio_shutdown();
65 ecore_shutdown();
66
67 return 0;
68}
69