2013-02-08 09:35:17 -08:00
|
|
|
// Compile with:
|
|
|
|
// gcc -o ecore_audio_to_ogg ecore_audio_to_ogg.c `pkg-config --libs --cflags ecore eina ecore-audio`
|
|
|
|
|
2012-12-14 15:38:35 -08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <libgen.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
2013-04-12 09:46:20 -07:00
|
|
|
#include <Eo.h>
|
2012-12-14 15:38:35 -08:00
|
|
|
#include <Ecore.h>
|
|
|
|
#include <Ecore_Audio.h>
|
|
|
|
#include <Eina.h>
|
|
|
|
|
|
|
|
double volume = 1;
|
|
|
|
Eina_List *inputs = NULL;
|
|
|
|
|
2013-04-18 11:34:33 -07:00
|
|
|
static Eina_Bool _play_finished(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
|
2012-12-14 15:38:35 -08:00
|
|
|
{
|
2013-04-12 09:46:20 -07:00
|
|
|
const char *name;
|
|
|
|
Eo *out;
|
2012-12-14 15:38:35 -08:00
|
|
|
|
2013-04-12 09:46:20 -07:00
|
|
|
eo_do(obj, ecore_audio_obj_name_get(&name));
|
|
|
|
printf("Done: %s\n", name);
|
2012-12-14 15:38:35 -08:00
|
|
|
|
2013-04-12 09:46:20 -07:00
|
|
|
eo_do(obj, ecore_audio_obj_in_output_get(&out));
|
|
|
|
eo_del(obj);
|
|
|
|
eo_del(out);
|
2012-12-14 15:38:35 -08:00
|
|
|
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-04-18 11:34:33 -07:00
|
|
|
main(int argc, char *argv[])
|
2012-12-14 15:38:35 -08:00
|
|
|
{
|
2013-04-12 09:46:20 -07:00
|
|
|
Eo *out;
|
|
|
|
Eo *in;
|
2013-04-23 09:10:16 -07:00
|
|
|
Eina_Bool ret;
|
2012-12-14 15:38:35 -08:00
|
|
|
|
2013-04-23 09:11:48 -07:00
|
|
|
if (argc < 3)
|
2012-12-14 15:38:35 -08:00
|
|
|
{
|
2013-04-23 09:11:48 -07:00
|
|
|
printf("Usage: ./example <infile> <outfile>\n");
|
2012-12-14 15:38:35 -08:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_init();
|
|
|
|
ecore_audio_init();
|
|
|
|
|
|
|
|
|
2013-04-12 09:46:20 -07:00
|
|
|
in = eo_add(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL);
|
|
|
|
eo_do(in, ecore_audio_obj_name_set(basename(argv[1])));
|
2014-04-10 02:07:42 -07:00
|
|
|
eo_do(in, ret = ecore_audio_obj_source_set(argv[1]));
|
2013-04-23 09:10:16 -07:00
|
|
|
if (!ret) {
|
|
|
|
printf("Could not set %s as input\n", argv[1]);
|
|
|
|
eo_del(in);
|
|
|
|
return 1;
|
|
|
|
}
|
2013-04-12 09:46:20 -07:00
|
|
|
|
|
|
|
eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL));
|
2012-12-14 15:38:35 -08:00
|
|
|
|
2013-04-12 09:46:20 -07:00
|
|
|
out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL);
|
2014-04-10 02:07:42 -07:00
|
|
|
eo_do(out, ret = ecore_audio_obj_source_set(argv[2]));
|
2013-04-23 09:10:16 -07:00
|
|
|
if (!ret) {
|
2013-04-23 09:11:48 -07:00
|
|
|
printf("Could not set %s as output\n", argv[2]);
|
2013-04-23 09:10:16 -07:00
|
|
|
eo_del(in);
|
|
|
|
eo_del(out);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-04-10 02:07:42 -07:00
|
|
|
eo_do(out, ret = ecore_audio_obj_out_input_attach(in));
|
2013-04-23 09:10:16 -07:00
|
|
|
if (!ret) {
|
|
|
|
printf("Could not attach input\n");
|
|
|
|
eo_del(out);
|
|
|
|
eo_del(in);
|
|
|
|
return 1;
|
|
|
|
}
|
2012-12-14 15:38:35 -08:00
|
|
|
|
|
|
|
ecore_main_loop_begin();
|
|
|
|
|
|
|
|
ecore_audio_shutdown();
|
|
|
|
ecore_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|