edje_multisense: Now works with eo rewrite

Signed-off-by: Daniel Willmann <d.willmann@samsung.com>
This commit is contained in:
Daniel Willmann 2013-04-17 20:37:19 +01:00
parent e93ddc9bb3
commit 43299ade45
1 changed files with 29 additions and 30 deletions

View File

@ -4,13 +4,13 @@
#include <sndfile.h> #include <sndfile.h>
#include "Ecore_Audio.h" #include "Ecore_Audio.h"
static Ecore_Audio_Object *out = NULL; static Eo *out = NULL;
static Eina_Bool _play_finished(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) static Eina_Bool _play_finished(void *data EINA_UNUSED, Eo *in, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
{ {
Ecore_Audio_Object *in = (Ecore_Audio_Object *)event; eo_del(in);
ecore_audio_input_del(in);
return EINA_FALSE; return EINA_TRUE;
} }
struct _edje_multisense_eet_data struct _edje_multisense_eet_data
@ -21,16 +21,16 @@ struct _edje_multisense_eet_data
}; };
static int static int
eet_snd_file_get_length(Ecore_Audio_Object *in) eet_snd_file_get_length(void *data, Eo *eo_obj EINA_UNUSED)
{ {
struct _edje_multisense_eet_data *vf = ecore_audio_input_data_get(in); struct _edje_multisense_eet_data *vf = data;
return vf->length; return vf->length;
} }
static int static int
eet_snd_file_seek(Ecore_Audio_Object *in, int offset, int whence) eet_snd_file_seek(void *data, Eo *eo_obj EINA_UNUSED, int offset, int whence)
{ {
struct _edje_multisense_eet_data *vf = ecore_audio_input_data_get(in); struct _edje_multisense_eet_data *vf = data;
switch (whence) switch (whence)
{ {
@ -50,9 +50,9 @@ eet_snd_file_seek(Ecore_Audio_Object *in, int offset, int whence)
} }
static int static int
eet_snd_file_read(Ecore_Audio_Object *in, void *buffer, int count) eet_snd_file_read(void *data, Eo *eo_obj EINA_UNUSED, void *buffer, int count)
{ {
struct _edje_multisense_eet_data *vf = ecore_audio_input_data_get(in); struct _edje_multisense_eet_data *vf = data;
if ((vf->offset + count) > vf->length) if ((vf->offset + count) > vf->length)
count = vf->length - vf->offset; count = vf->length - vf->offset;
@ -62,9 +62,9 @@ eet_snd_file_read(Ecore_Audio_Object *in, void *buffer, int count)
} }
static int static int
eet_snd_file_tell(Ecore_Audio_Object *in) eet_snd_file_tell(void *data, Eo *eo_obj EINA_UNUSED)
{ {
struct _edje_multisense_eet_data *vf = ecore_audio_input_data_get(in); struct _edje_multisense_eet_data *vf = data;
return vf->offset; return vf->offset;
} }
@ -74,7 +74,7 @@ Eina_Bool
_edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed) _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed)
{ {
#ifdef ENABLE_MULTISENSE #ifdef ENABLE_MULTISENSE
Ecore_Audio_Object *in; Eo *in;
Edje_Sound_Sample *sample; Edje_Sound_Sample *sample;
char snd_id_str[255]; char snd_id_str[255];
int i; int i;
@ -96,9 +96,9 @@ _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, c
struct _edje_multisense_eet_data *eet_data; struct _edje_multisense_eet_data *eet_data;
snprintf(snd_id_str, sizeof(snd_id_str), "edje/sounds/%i", sample->id); snprintf(snd_id_str, sizeof(snd_id_str), "edje/sounds/%i", sample->id);
in = ecore_audio_input_add(ECORE_AUDIO_TYPE_SNDFILE); in = eo_add(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL);
ecore_audio_input_name_set(in, snd_id_str); eo_do(in, ecore_audio_obj_name_set(snd_id_str));
ecore_audio_input_speed_set(in, speed); eo_do(in, ecore_audio_obj_in_speed_set(speed));
eet_data = calloc(1, sizeof(struct _edje_multisense_eet_data)); eet_data = calloc(1, sizeof(struct _edje_multisense_eet_data));
@ -113,13 +113,13 @@ _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, c
eet_data->offset = 0; eet_data->offset = 0;
ecore_audio_input_data_set(in, eet_data); eo_do(in, ecore_audio_obj_vio_set(&eet_data->vio, eet_data, free));
ecore_audio_input_sndfile_vio_set(in, &eet_data->vio); eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL));
if (!out) if (!out)
out = ecore_audio_output_add(ECORE_AUDIO_TYPE_PULSE); out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
ecore_audio_output_input_add(out, in); eo_do(out, ecore_audio_obj_out_input_attach(in));
} }
} }
return EINA_TRUE; return EINA_TRUE;
@ -139,7 +139,7 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
unsigned int i; unsigned int i;
Edje_Sound_Tone *tone; Edje_Sound_Tone *tone;
Ecore_Audio_Object *in; Eo *in;
if (!tone_name) if (!tone_name)
{ {
ERR("Given Tone Name is NULL\n"); ERR("Given Tone Name is NULL\n");
@ -153,15 +153,16 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
tone = &ed->file->sound_dir->tones[i]; tone = &ed->file->sound_dir->tones[i];
if (!strcmp(tone->name, tone_name)) if (!strcmp(tone->name, tone_name))
{ {
in = ecore_audio_input_add(ECORE_AUDIO_TYPE_TONE); in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL);
ecore_audio_input_name_set(in, "tone"); eo_do(in, ecore_audio_obj_name_set("tone"));
ecore_audio_input_tone_frequency_set(in, tone->value); eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &tone->value, NULL));
ecore_audio_input_tone_duration_set(in, duration); eo_do(in, ecore_audio_obj_in_length_set(duration));
eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL));
if (!out) if (!out)
out = ecore_audio_output_add(ECORE_AUDIO_TYPE_PULSE); out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
ecore_audio_output_input_add(out, in); eo_do(out, ecore_audio_obj_out_input_attach(in));
} }
} }
return EINA_TRUE; return EINA_TRUE;
@ -175,13 +176,11 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
} }
/* Initialize the modules in main thread. to avoid dlopen issue in the Threads */
void void
_edje_multisense_init(void) _edje_multisense_init(void)
{ {
#ifdef ENABLE_MULTISENSE #ifdef ENABLE_MULTISENSE
ecore_audio_init(); ecore_audio_init();
ecore_event_handler_add(ECORE_AUDIO_INPUT_ENDED, _play_finished, NULL);
#endif #endif
} }