forked from enlightenment/efl
ecore_audio: Add an example for libsndfile output: ogg encoder
Signed-off-by: Daniel Willmann <d.willmann@samsung.com> SVN revision: 81003
This commit is contained in:
parent
55f6091e3d
commit
1c68e42f25
|
@ -54,7 +54,8 @@ ecore_timer_example
|
||||||
if HAVE_ECORE_AUDIO
|
if HAVE_ECORE_AUDIO
|
||||||
EXTRA_PROGRAMS += \
|
EXTRA_PROGRAMS += \
|
||||||
ecore_audio_custom \
|
ecore_audio_custom \
|
||||||
ecore_audio_playback
|
ecore_audio_playback \
|
||||||
|
ecore_audio_to_ogg
|
||||||
|
|
||||||
ecore_audio_custom_SOURCES = ecore_audio_custom.c
|
ecore_audio_custom_SOURCES = ecore_audio_custom.c
|
||||||
ecore_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@
|
ecore_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
|
||||||
ecore_audio_playback_SOURCES = ecore_audio_playback.c
|
ecore_audio_playback_SOURCES = ecore_audio_playback.c
|
||||||
ecore_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@
|
ecore_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@
|
||||||
|
|
||||||
|
ecore_audio_to_ogg_SOURCES = ecore_audio_to_ogg.c
|
||||||
|
ecore_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@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ecore_animator_example_SOURCES = ecore_animator_example.c
|
ecore_animator_example_SOURCES = ecore_animator_example.c
|
||||||
|
@ -153,7 +156,6 @@ ecore_timer_example_LDADD = $(top_builddir)/src/lib/ecore/libecore.la @ECORE_LIB
|
||||||
|
|
||||||
SRCS = \
|
SRCS = \
|
||||||
ecore_animator_example \
|
ecore_animator_example \
|
||||||
ecore_audio_playback \
|
|
||||||
ecore_client_bench \
|
ecore_client_bench \
|
||||||
ecore_con_client_simple_example \
|
ecore_con_client_simple_example \
|
||||||
ecore_con_lookup_example \
|
ecore_con_lookup_example \
|
||||||
|
@ -183,6 +185,13 @@ ecore_thread_example \
|
||||||
ecore_time_functions_example \
|
ecore_time_functions_example \
|
||||||
ecore_timer_example
|
ecore_timer_example
|
||||||
|
|
||||||
|
if HAVE_ECORE_AUDIO
|
||||||
|
SRCS += \
|
||||||
|
ecore_audio_custom \
|
||||||
|
ecore_audio_playback \
|
||||||
|
ecore_audio_to_ogg
|
||||||
|
endif
|
||||||
|
|
||||||
EXTRA_DIST = red.png
|
EXTRA_DIST = red.png
|
||||||
|
|
||||||
examples: $(EXTRA_PROGRAMS)
|
examples: $(EXTRA_PROGRAMS)
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Ecore_Audio.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
Ecore_Audio_Object *out = NULL;
|
||||||
|
double volume = 1;
|
||||||
|
Eina_List *inputs = NULL;
|
||||||
|
|
||||||
|
static Eina_Bool _play_finished(void *data, int type, void *event)
|
||||||
|
{
|
||||||
|
Ecore_Audio_Object *in = (Ecore_Audio_Object *)event;
|
||||||
|
|
||||||
|
printf("Done: %s\n", ecore_audio_input_name_get(in));
|
||||||
|
|
||||||
|
ecore_audio_output_input_del(out, in);
|
||||||
|
ecore_audio_input_del(in);
|
||||||
|
ecore_audio_output_del(out);
|
||||||
|
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
Ecore_Audio_Object *in;
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
printf("Please provide a filename\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
ecore_init();
|
||||||
|
ecore_audio_init();
|
||||||
|
|
||||||
|
ecore_event_handler_add(ECORE_AUDIO_INPUT_ENDED, _play_finished, NULL);
|
||||||
|
|
||||||
|
in = ecore_audio_input_add(ECORE_AUDIO_TYPE_SNDFILE);
|
||||||
|
ecore_audio_input_name_set(in, basename(argv[1]));
|
||||||
|
ecore_audio_input_sndfile_filename_set(in, argv[1]);
|
||||||
|
if (!in)
|
||||||
|
{
|
||||||
|
printf("error when creating ecore audio source.\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
out = ecore_audio_output_add(ECORE_AUDIO_TYPE_SNDFILE);
|
||||||
|
ecore_audio_output_sndfile_filename_set(out, "foo.ogg");
|
||||||
|
|
||||||
|
ecore_audio_output_input_add(out, in);
|
||||||
|
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
|
||||||
|
end:
|
||||||
|
ecore_audio_shutdown();
|
||||||
|
ecore_shutdown();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue