forked from enlightenment/efl
Eolian: Integration of Ecore Audio In Tone
This commit is contained in:
parent
7876846f01
commit
07da26add9
|
@ -14,7 +14,9 @@ BUILT_SOURCES += \
|
||||||
lib/ecore_audio/ecore_audio_out_sndfile.eo.c \
|
lib/ecore_audio/ecore_audio_out_sndfile.eo.c \
|
||||||
lib/ecore_audio/ecore_audio_out_sndfile.eo.h \
|
lib/ecore_audio/ecore_audio_out_sndfile.eo.h \
|
||||||
lib/ecore_audio/ecore_audio_out_pulse.eo.c \
|
lib/ecore_audio/ecore_audio_out_pulse.eo.c \
|
||||||
lib/ecore_audio/ecore_audio_out_pulse.eo.h
|
lib/ecore_audio/ecore_audio_out_pulse.eo.h \
|
||||||
|
lib/ecore_audio/ecore_audio_in_tone.eo.c \
|
||||||
|
lib/ecore_audio/ecore_audio_in_tone.eo.h
|
||||||
|
|
||||||
ecore_audioeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
|
ecore_audioeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
|
||||||
ecore_audioeolianfiles_DATA = \
|
ecore_audioeolianfiles_DATA = \
|
||||||
|
@ -23,7 +25,8 @@ ecore_audioeolianfiles_DATA = \
|
||||||
lib/ecore_audio/ecore_audio_out.eo \
|
lib/ecore_audio/ecore_audio_out.eo \
|
||||||
lib/ecore_audio/ecore_audio_in_sndfile.eo \
|
lib/ecore_audio/ecore_audio_in_sndfile.eo \
|
||||||
lib/ecore_audio/ecore_audio_out_sndfile.eo \
|
lib/ecore_audio/ecore_audio_out_sndfile.eo \
|
||||||
lib/ecore_audio/ecore_audio_out_pulse.eo
|
lib/ecore_audio/ecore_audio_out_pulse.eo \
|
||||||
|
lib/ecore_audio/ecore_audio_in_tone.eo
|
||||||
|
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
${ecore_audioeolianfiles_DATA}
|
${ecore_audioeolianfiles_DATA}
|
||||||
|
@ -45,7 +48,8 @@ nodist_installed_ecoreaudiomainheaders_DATA = \
|
||||||
lib/ecore_audio/ecore_audio_out.eo.h \
|
lib/ecore_audio/ecore_audio_out.eo.h \
|
||||||
lib/ecore_audio/ecore_audio_in_sndfile.eo.h \
|
lib/ecore_audio/ecore_audio_in_sndfile.eo.h \
|
||||||
lib/ecore_audio/ecore_audio_out_sndfile.eo.h \
|
lib/ecore_audio/ecore_audio_out_sndfile.eo.h \
|
||||||
lib/ecore_audio/ecore_audio_out_pulse.eo.h
|
lib/ecore_audio/ecore_audio_out_pulse.eo.h \
|
||||||
|
lib/ecore_audio/ecore_audio_in_tone.eo.h
|
||||||
|
|
||||||
lib_ecore_audio_libecore_audio_la_SOURCES = \
|
lib_ecore_audio_libecore_audio_la_SOURCES = \
|
||||||
lib/ecore_audio/ecore_audio.c \
|
lib/ecore_audio/ecore_audio.c \
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
class Ecore_Audio_In_Tone (Ecore_Audio_In)
|
||||||
|
{
|
||||||
|
eo_prefix: ecore_audio_obj_in_tone;
|
||||||
|
implements {
|
||||||
|
Eo_Base::constructor;
|
||||||
|
Eo_Base::data_set;
|
||||||
|
Eo_Base::data_get;
|
||||||
|
Ecore_Audio_In::length::set;
|
||||||
|
Ecore_Audio_In::seek;
|
||||||
|
Ecore_Audio_In::read_internal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,30 +14,23 @@
|
||||||
#include "ecore_audio_private.h"
|
#include "ecore_audio_private.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
EAPI Eo_Op ECORE_AUDIO_OBJ_IN_TONE_BASE_ID = EO_NOOP;
|
|
||||||
|
|
||||||
#define MY_CLASS ECORE_AUDIO_OBJ_IN_TONE_CLASS
|
#define MY_CLASS ECORE_AUDIO_OBJ_IN_TONE_CLASS
|
||||||
#define MY_CLASS_NAME "Ecore_Audio_In_Tone"
|
#define MY_CLASS_NAME "Ecore_Audio_In_Tone"
|
||||||
|
|
||||||
struct _Ecore_Audio_Tone
|
struct _Ecore_Audio_In_Tone_Data
|
||||||
{
|
{
|
||||||
int freq;
|
int freq;
|
||||||
int phase;
|
int phase;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _Ecore_Audio_Tone Ecore_Audio_Tone;
|
typedef struct _Ecore_Audio_In_Tone_Data Ecore_Audio_In_Tone_Data;
|
||||||
|
|
||||||
static void _tone_read(Eo *eo_obj, void *_pd, va_list *list)
|
EOLIAN static ssize_t
|
||||||
|
_ecore_audio_in_tone_ecore_audio_in_read_internal(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, void *data, size_t len)
|
||||||
{
|
{
|
||||||
int i, remain;
|
size_t i, remain;
|
||||||
Ecore_Audio_Tone *obj = _pd;
|
|
||||||
Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
|
Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
|
||||||
|
|
||||||
|
|
||||||
void *data = va_arg(*list, void *);
|
|
||||||
int len = va_arg(*list, int);
|
|
||||||
int *ret = va_arg(*list, int *);
|
|
||||||
|
|
||||||
float *val = data;
|
float *val = data;
|
||||||
|
|
||||||
remain = in_obj->length * in_obj->samplerate * 4 - obj->phase * 4;
|
remain = in_obj->length * in_obj->samplerate * 4 - obj->phase * 4;
|
||||||
|
@ -50,20 +43,15 @@ static void _tone_read(Eo *eo_obj, void *_pd, va_list *list)
|
||||||
|
|
||||||
obj->phase += i;
|
obj->phase += i;
|
||||||
|
|
||||||
if (ret)
|
return remain;
|
||||||
*ret = remain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _seek(Eo *eo_obj, void *_pd, va_list *list)
|
EOLIAN static double
|
||||||
|
_ecore_audio_in_tone_ecore_audio_in_seek(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, double offs, int mode)
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
Ecore_Audio_Tone *obj = _pd;
|
|
||||||
Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
|
Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
|
||||||
|
|
||||||
double offs = va_arg(*list, double);
|
|
||||||
int mode = va_arg(*list, int);
|
|
||||||
double *ret = va_arg(*list, double *);
|
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
tmp = offs * in_obj->samplerate;
|
tmp = offs * in_obj->samplerate;
|
||||||
|
@ -82,32 +70,21 @@ static void _seek(Eo *eo_obj, void *_pd, va_list *list)
|
||||||
|
|
||||||
obj->phase = tmp;
|
obj->phase = tmp;
|
||||||
|
|
||||||
if (ret)
|
return (double)obj->phase / in_obj->samplerate;
|
||||||
*ret = (double)obj->phase / in_obj->samplerate;
|
|
||||||
|
|
||||||
return;
|
|
||||||
err:
|
err:
|
||||||
if (ret)
|
return -1.0;
|
||||||
*ret = -1.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _length_set(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
|
EOLIAN static void
|
||||||
|
_ecore_audio_in_tone_ecore_audio_in_length_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *_pd EINA_UNUSED, double length)
|
||||||
{
|
{
|
||||||
Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
|
Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
|
||||||
|
|
||||||
double length= va_arg(*list, double);
|
|
||||||
|
|
||||||
in_obj->length = length;
|
in_obj->length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _data_set(Eo *eo_obj, void *_pd, va_list *list)
|
EOLIAN static void
|
||||||
|
_ecore_audio_in_tone_eo_base_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key, const void *val, eo_base_data_free_func func)
|
||||||
{
|
{
|
||||||
Ecore_Audio_Tone *obj = _pd;
|
|
||||||
|
|
||||||
const char *key = va_arg(*list, const char *);
|
|
||||||
const void *val = va_arg(*list, const void *);
|
|
||||||
eo_base_data_free_func func = va_arg(*list, eo_base_data_free_func);
|
|
||||||
|
|
||||||
if (!key) return;
|
if (!key) return;
|
||||||
|
|
||||||
if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) {
|
if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) {
|
||||||
|
@ -118,25 +95,21 @@ static void _data_set(Eo *eo_obj, void *_pd, va_list *list)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _data_get(Eo *eo_obj, void *_pd, va_list *list)
|
EOLIAN static void*
|
||||||
|
_ecore_audio_in_tone_eo_base_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key)
|
||||||
{
|
{
|
||||||
Ecore_Audio_Tone *obj = _pd;
|
|
||||||
|
|
||||||
const char *key = va_arg(*list, const char*);
|
|
||||||
void **ret = va_arg(*list, void **);
|
|
||||||
|
|
||||||
if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) {
|
if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) {
|
||||||
if (ret)
|
return (void *)obj->freq;
|
||||||
*(int *)ret = obj->freq;
|
|
||||||
} else {
|
} else {
|
||||||
eo_do_super(eo_obj, MY_CLASS, eo_base_data_get(key, ret));
|
void *ret = NULL;
|
||||||
|
eo_do_super(eo_obj, MY_CLASS, eo_base_data_get(key, &ret));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _constructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
|
EOLIAN static void
|
||||||
|
_ecore_audio_in_tone_eo_base_constructor(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj)
|
||||||
{
|
{
|
||||||
Ecore_Audio_Tone *obj = _pd;
|
|
||||||
Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
|
Ecore_Audio_Input *in_obj = eo_data_scope_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
|
||||||
|
|
||||||
eo_do_super(eo_obj, MY_CLASS, eo_constructor());
|
eo_do_super(eo_obj, MY_CLASS, eo_constructor());
|
||||||
|
@ -149,39 +122,4 @@ static void _constructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
|
||||||
obj->freq = 1000;
|
obj->freq = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _class_constructor(Eo_Class *klass)
|
#include "ecore_audio_in_tone.eo.c"
|
||||||
{
|
|
||||||
const Eo_Op_Func_Description func_desc[] = {
|
|
||||||
/* Virtual functions of parent class implemented in this class */
|
|
||||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
|
|
||||||
//EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
|
|
||||||
|
|
||||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), _data_get),
|
|
||||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), _data_set),
|
|
||||||
|
|
||||||
EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_LENGTH_SET), _length_set),
|
|
||||||
EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_SEEK), _seek),
|
|
||||||
EO_OP_FUNC(ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_READ_INTERNAL), _tone_read),
|
|
||||||
|
|
||||||
EO_OP_FUNC_SENTINEL
|
|
||||||
};
|
|
||||||
|
|
||||||
eo_class_funcs_set(klass, func_desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const Eo_Op_Description op_desc[] = {
|
|
||||||
EO_OP_DESCRIPTION_SENTINEL
|
|
||||||
};
|
|
||||||
|
|
||||||
static const Eo_Class_Description class_desc = {
|
|
||||||
EO_VERSION,
|
|
||||||
MY_CLASS_NAME,
|
|
||||||
EO_CLASS_TYPE_REGULAR,
|
|
||||||
EO_CLASS_DESCRIPTION_OPS(&ECORE_AUDIO_OBJ_IN_TONE_BASE_ID, op_desc, ECORE_AUDIO_OBJ_IN_TONE_SUB_ID_LAST),
|
|
||||||
NULL,
|
|
||||||
sizeof(Ecore_Audio_Tone),
|
|
||||||
_class_constructor,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
EO_DEFINE_CLASS(ecore_audio_obj_in_tone_class_get, &class_desc, ECORE_AUDIO_OBJ_IN_CLASS, NULL);
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ extern "C"
|
||||||
*/
|
*/
|
||||||
#define ECORE_AUDIO_ATTR_TONE_FREQ "ecore_audio_freq"
|
#define ECORE_AUDIO_ATTR_TONE_FREQ "ecore_audio_freq"
|
||||||
|
|
||||||
|
#include "ecore_audio_in_tone.eo.h"
|
||||||
|
#if 0
|
||||||
#define ECORE_AUDIO_OBJ_IN_TONE_CLASS ecore_audio_obj_in_tone_class_get() /**< Ecore_Audio tone input */
|
#define ECORE_AUDIO_OBJ_IN_TONE_CLASS ecore_audio_obj_in_tone_class_get() /**< Ecore_Audio tone input */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +60,7 @@ enum Ecore_Audio_Obj_In_Tone_Sub_Ids
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ECORE_AUDIO_OBJ_IN_TONE_ID(sub_id) (ECORE_AUDIO_OBJ_IN_TONE_BASE_ID + EO_TYPECHECK(enum Ecore_Audio_Obj_In_Tone_Sub_Ids, sub_id)
|
#define ECORE_AUDIO_OBJ_IN_TONE_ID(sub_id) (ECORE_AUDIO_OBJ_IN_TONE_BASE_ID + EO_TYPECHECK(enum Ecore_Audio_Obj_In_Tone_Sub_Ids, sub_id)
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue