Examples: update ecore_audio
This commit is contained in:
parent
3474d867aa
commit
c73c270b33
|
@ -1,5 +1,6 @@
|
||||||
// Compile with:
|
// Compile with:
|
||||||
// gcc -o ecore_audio_custom ecore_audio_custom.c `pkg-config --libs --cflags ecore ecore-audio`
|
// gcc -o ecore_audio_custom ecore_audio_custom.c `pkg-config --libs --cflags ecore ecore-audio`
|
||||||
|
#define EFL_BETA_API_SUPPORT
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -25,7 +26,7 @@ int read_cb(void *data EINA_UNUSED, Eo *eo_obj, void *buf, int len)
|
||||||
float *val = buf;
|
float *val = buf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ecore_audio_obj_volume_get(eo_obj, &volume);
|
volume = ecore_audio_obj_volume_get(eo_obj);
|
||||||
|
|
||||||
for(i=0; i<len/4; i++, phase1++)
|
for(i=0; i<len/4; i++, phase1++)
|
||||||
{
|
{
|
||||||
|
@ -56,9 +57,9 @@ main(int argc, const char *argv[])
|
||||||
|
|
||||||
ecore_app_args_set(argc, argv);
|
ecore_app_args_set(argc, argv);
|
||||||
|
|
||||||
out = efl_add_ref(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
|
out = efl_add_ref(ECORE_AUDIO_OUT_PULSE_CLASS, NULL);
|
||||||
|
|
||||||
in = efl_add_ref(ECORE_AUDIO_OBJ_IN_CLASS, NULL);
|
in = efl_add_ref(ECORE_AUDIO_IN_CLASS, NULL);
|
||||||
if (!in)
|
if (!in)
|
||||||
{
|
{
|
||||||
printf("error when creating ecore audio source.\n");
|
printf("error when creating ecore audio source.\n");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// Compile with:
|
// Compile with:
|
||||||
// gcc -o ecore_audio_playback ecore_audio_playback.c `pkg-config --libs --cflags ecore eina ecore-audio`
|
// gcc -o ecore_audio_playback ecore_audio_playback.c `pkg-config --libs --cflags ecore eina ecore-audio`
|
||||||
|
#define EFL_BETA_API_SUPPORT
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -10,6 +11,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
|
#include <Ecore_Eo.h>
|
||||||
#include <Ecore_Audio.h>
|
#include <Ecore_Audio.h>
|
||||||
#include <Eina.h>
|
#include <Eina.h>
|
||||||
|
|
||||||
|
@ -30,19 +32,19 @@ handle_cmd(char *cmd, size_t bread)
|
||||||
if (!out)
|
if (!out)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ecore_audio_obj_out_inputs_get(out, &out_inputs);
|
out_inputs = ecore_audio_obj_out_inputs_get(out);
|
||||||
EINA_LIST_FOREACH(out_inputs, input, in)
|
EINA_LIST_FOREACH(out_inputs, input, in)
|
||||||
{
|
{
|
||||||
ecore_audio_obj_in_seek(in, 0, SEEK_CUR, &pos);
|
pos = ecore_audio_obj_in_seek(in, 0, SEEK_CUR);
|
||||||
if (!strncmp(cmd, "<", bread))
|
if (!strncmp(cmd, "<", bread))
|
||||||
ecore_audio_obj_in_seek(in, -10, SEEK_CUR, &pos);
|
pos = ecore_audio_obj_in_seek(in, -10, SEEK_CUR);/* */
|
||||||
else if (!strncmp(cmd, ">", bread))
|
else if (!strncmp(cmd, ">", bread))
|
||||||
ecore_audio_obj_in_seek(in, 10, SEEK_CUR, &pos);
|
pos = ecore_audio_obj_in_seek(in, 10, SEEK_CUR);
|
||||||
|
|
||||||
min = pos / 60;
|
min = pos / 60;
|
||||||
|
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
ecore_audio_obj_in_length_get(in, &length);
|
length = ecore_audio_obj_in_length_get(in);
|
||||||
printf("Position: %2im %5.02fs (%0.2f%%) - %s\n", min, pos - min * 60, pos/length*100, name);
|
printf("Position: %2im %5.02fs (%0.2f%%) - %s\n", min, pos - min * 60, pos/length*100, name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,8 +65,8 @@ handle_cmd(char *cmd, size_t bread)
|
||||||
{
|
{
|
||||||
in = (Eo *)eina_list_data_get(inputs);
|
in = (Eo *)eina_list_data_get(inputs);
|
||||||
|
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
ecore_audio_obj_in_length_get(in, &length);
|
length = ecore_audio_obj_in_length_get(in);
|
||||||
|
|
||||||
printf("Start: %s (%0.2fs)\n", name, length);
|
printf("Start: %s (%0.2fs)\n", name, length);
|
||||||
ret = ecore_audio_obj_out_input_attach(out, in);
|
ret = ecore_audio_obj_out_input_attach(out, in);
|
||||||
|
@ -84,8 +86,8 @@ handle_cmd(char *cmd, size_t bread)
|
||||||
{
|
{
|
||||||
in = (Eo *)eina_list_data_get(inputs);
|
in = (Eo *)eina_list_data_get(inputs);
|
||||||
|
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
ecore_audio_obj_in_length_get(in, &length);
|
length = ecore_audio_obj_in_length_get(in);
|
||||||
|
|
||||||
printf("Start: %s (%0.2fs)\n", name, length);
|
printf("Start: %s (%0.2fs)\n", name, length);
|
||||||
ret = ecore_audio_obj_out_input_attach(out, in);
|
ret = ecore_audio_obj_out_input_attach(out, in);
|
||||||
|
@ -98,8 +100,8 @@ handle_cmd(char *cmd, size_t bread)
|
||||||
EINA_LIST_FOREACH(out_inputs, input, in)
|
EINA_LIST_FOREACH(out_inputs, input, in)
|
||||||
{
|
{
|
||||||
Eina_Bool loop;
|
Eina_Bool loop;
|
||||||
ecore_audio_obj_in_looped_get(in, &loop);
|
loop = ecore_audio_obj_in_looped_get(in);
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
|
|
||||||
printf("%s song %s\n", !loop?"Looping":"Not looping", name);
|
printf("%s song %s\n", !loop?"Looping":"Not looping", name);
|
||||||
ecore_audio_obj_in_looped_set(in, !loop);
|
ecore_audio_obj_in_looped_set(in, !loop);
|
||||||
|
@ -124,11 +126,11 @@ handle_cmd(char *cmd, size_t bread)
|
||||||
double speed;
|
double speed;
|
||||||
EINA_LIST_FOREACH(out_inputs, input, in)
|
EINA_LIST_FOREACH(out_inputs, input, in)
|
||||||
{
|
{
|
||||||
ecore_audio_obj_in_speed_get(in, &speed);
|
speed = ecore_audio_obj_in_speed_get(in);
|
||||||
if (speed < 2.0)
|
if (speed < 2.0)
|
||||||
speed += 0.01;
|
speed += 0.01;
|
||||||
ecore_audio_obj_in_speed_set(in, speed);
|
ecore_audio_obj_in_speed_set(in, speed);
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
printf("Speed: %3.0f%% (%s)\n", speed * 100, name);
|
printf("Speed: %3.0f%% (%s)\n", speed * 100, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,11 +139,11 @@ handle_cmd(char *cmd, size_t bread)
|
||||||
double speed;
|
double speed;
|
||||||
EINA_LIST_FOREACH(out_inputs, input, in)
|
EINA_LIST_FOREACH(out_inputs, input, in)
|
||||||
{
|
{
|
||||||
ecore_audio_obj_in_speed_get(in, &speed);
|
speed = ecore_audio_obj_in_speed_get(in);
|
||||||
if (speed > 0.5)
|
if (speed > 0.5)
|
||||||
speed -= 0.01;
|
speed -= 0.01;
|
||||||
ecore_audio_obj_in_speed_set(in, speed);
|
ecore_audio_obj_in_speed_set(in, speed);
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
printf("Speed: %3.0f%% (%s)\n", speed * 100, name);
|
printf("Speed: %3.0f%% (%s)\n", speed * 100, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,9 +151,9 @@ handle_cmd(char *cmd, size_t bread)
|
||||||
{
|
{
|
||||||
EINA_LIST_FOREACH(out_inputs, input, in)
|
EINA_LIST_FOREACH(out_inputs, input, in)
|
||||||
{
|
{
|
||||||
ecore_audio_obj_paused_get(in, &paused);
|
paused = ecore_audio_obj_paused_get(in);
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
ecore_audio_obj_in_remaining_get(in, &length);
|
length = ecore_audio_obj_in_remaining_get(in);
|
||||||
printf("%s %s\n%0.2f remaining\n", !paused ? "Paused" : "Unpaused", name, length);
|
printf("%s %s\n%0.2f remaining\n", !paused ? "Paused" : "Unpaused", name, length);
|
||||||
ecore_audio_obj_paused_set(in, !paused);
|
ecore_audio_obj_paused_set(in, !paused);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +198,7 @@ static void _play_finished(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
const char *name;
|
const char *name;
|
||||||
Eina_Bool ret;
|
Eina_Bool ret;
|
||||||
|
|
||||||
ecore_audio_obj_name_get(event->object, &name);
|
name = ecore_audio_obj_name_get(event->object);
|
||||||
printf("Done: %s\n", name);
|
printf("Done: %s\n", name);
|
||||||
|
|
||||||
inputs = eina_list_remove(inputs, event->object);
|
inputs = eina_list_remove(inputs, event->object);
|
||||||
|
@ -212,7 +214,7 @@ static void _play_finished(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
const char *name;
|
const char *name;
|
||||||
Eo *in = (Eo *)eina_list_data_get(inputs);
|
Eo *in = (Eo *)eina_list_data_get(inputs);
|
||||||
|
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
printf("Start: %s\n", name);
|
printf("Start: %s\n", name);
|
||||||
ret = ecore_audio_obj_out_input_attach(out, in);
|
ret = ecore_audio_obj_out_input_attach(out, in);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
@ -252,7 +254,7 @@ main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
if (!strncmp(argv[i], "tone:", 5))
|
if (!strncmp(argv[i], "tone:", 5))
|
||||||
{
|
{
|
||||||
in = efl_add_ref(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL);
|
in = efl_add_ref(ECORE_AUDIO_IN_TONE_CLASS, NULL);
|
||||||
if (!in)
|
if (!in)
|
||||||
{
|
{
|
||||||
printf("error when creating ecore audio source.\n");
|
printf("error when creating ecore audio source.\n");
|
||||||
|
@ -276,7 +278,7 @@ main(int argc, const char *argv[])
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
in = efl_add_ref(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL);
|
in = efl_add_ref(ECORE_AUDIO_IN_SNDFILE_CLASS, NULL);
|
||||||
if (!in)
|
if (!in)
|
||||||
{
|
{
|
||||||
printf("error when creating ecore audio source.\n");
|
printf("error when creating ecore audio source.\n");
|
||||||
|
@ -291,7 +293,7 @@ main(int argc, const char *argv[])
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
efl_event_callback_add(in, ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL);
|
efl_event_callback_add(in, ECORE_AUDIO_IN_EVENT_IN_STOPPED, _play_finished, NULL);
|
||||||
inputs = eina_list_append(inputs, in);
|
inputs = eina_list_append(inputs, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,12 +304,12 @@ main(int argc, const char *argv[])
|
||||||
if (!in)
|
if (!in)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
ecore_audio_obj_name_get(in, &name);
|
name = ecore_audio_obj_name_get(in);
|
||||||
ecore_audio_obj_in_length_get(in, &length);
|
length = ecore_audio_obj_in_length_get(in);
|
||||||
|
|
||||||
printf("Start: %s (%0.2fs)\n", name, length);
|
printf("Start: %s (%0.2fs)\n", name, length);
|
||||||
|
|
||||||
out = efl_add_ref(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
|
out = efl_add_ref(ECORE_AUDIO_OUT_PULSE_CLASS, NULL);
|
||||||
ret = ecore_audio_obj_out_input_attach(out, in);
|
ret = ecore_audio_obj_out_input_attach(out, in);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
printf("Could not attach input %s\n", name);
|
printf("Could not attach input %s\n", name);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// Compile with:
|
// Compile with:
|
||||||
// gcc -o ecore_audio_to_ogg ecore_audio_to_ogg.c `pkg-config --libs --cflags ecore eina ecore-audio`
|
// gcc -o ecore_audio_to_ogg ecore_audio_to_ogg.c `pkg-config --libs --cflags ecore eina ecore-audio`
|
||||||
|
#define EFL_BETA_API_SUPPORT
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
@ -15,21 +16,20 @@
|
||||||
double volume = 1;
|
double volume = 1;
|
||||||
Eina_List *inputs = NULL;
|
Eina_List *inputs = NULL;
|
||||||
|
|
||||||
static void _play_finished(void *data EINA_UNUSED, const Efl_Event *event)
|
static void
|
||||||
|
_play_finished(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
Eo *out;
|
Eo *out;
|
||||||
|
|
||||||
ecore_audio_obj_name_get(event->object, &name);
|
name = ecore_audio_obj_name_get(event->object);
|
||||||
printf("Done: %s\n", name);
|
printf("Done: %s\n", name);
|
||||||
|
|
||||||
ecore_audio_obj_in_output_get(event->object, &out);
|
out = ecore_audio_obj_in_output_get(event->object);
|
||||||
efl_unref(event->object);
|
efl_unref(event->object);
|
||||||
efl_unref(out);
|
efl_unref(out);
|
||||||
|
|
||||||
ecore_main_loop_quit();
|
ecore_main_loop_quit();
|
||||||
|
|
||||||
return EINA_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -49,7 +49,7 @@ main(int argc, char *argv[])
|
||||||
ecore_audio_init();
|
ecore_audio_init();
|
||||||
|
|
||||||
|
|
||||||
in = efl_add_ref(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL);
|
in = efl_add_ref(ECORE_AUDIO_IN_SNDFILE_CLASS, NULL);
|
||||||
efl_name_set(in, basename(argv[1]));
|
efl_name_set(in, basename(argv[1]));
|
||||||
ret = ecore_audio_obj_source_set(in, argv[1]);
|
ret = ecore_audio_obj_source_set(in, argv[1]);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
@ -58,9 +58,9 @@ main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
efl_event_callback_add(in, ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL);
|
efl_event_callback_add(in, ECORE_AUDIO_IN_EVENT_IN_STOPPED, _play_finished, NULL);
|
||||||
|
|
||||||
out = efl_add_ref(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL);
|
out = efl_add_ref(ECORE_AUDIO_OUT_SNDFILE_CLASS, NULL);
|
||||||
ret = ecore_audio_obj_source_set(out, argv[2]);
|
ret = ecore_audio_obj_source_set(out, argv[2]);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
printf("Could not set %s as output\n", argv[2]);
|
printf("Could not set %s as output\n", argv[2]);
|
||||||
|
|
|
@ -39,9 +39,9 @@ endif
|
||||||
|
|
||||||
|
|
||||||
examples = [
|
examples = [
|
||||||
# 'ecore_audio_custom',
|
'ecore_audio_custom',
|
||||||
# 'ecore_audio_playback',
|
'ecore_audio_playback',
|
||||||
# 'ecore_audio_to_ogg',
|
'ecore_audio_to_ogg',
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach example : examples
|
foreach example : examples
|
||||||
|
|
Loading…
Reference in New Issue