ecore_audio: Fix seeking in tone input

Also make seekable be a property of the input as this doesn't make sense
for the output.

Signed-off-by: Daniel Willmann <d.willmann@samsung.com>
This commit is contained in:
Daniel Willmann 2013-04-19 15:28:00 +01:00
parent de265a994a
commit 1c0107afd8
4 changed files with 12 additions and 10 deletions

View File

@ -128,11 +128,10 @@ static void _length_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
static void _remaining_get(Eo *eo_obj, void *_pd, va_list *list)
{
const Ecore_Audio_Input *obj = _pd;
Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
double *ret = va_arg(*list, double *);
if (!ea_obj->seekable && ret) {
if (!obj->seekable && ret) {
*ret = -1;
} else if (ret) {
eo_do(eo_obj, ecore_audio_obj_in_seek(0, SEEK_CUR, ret));
@ -156,7 +155,7 @@ static void _read(Eo *eo_obj, void *_pd, va_list *list)
} else {
eo_do(eo_obj, ecore_audio_obj_in_read_internal(buf, len, &len_read));
if (len_read == 0) {
if (!obj->looped || !ea_obj->seekable) {
if (!obj->looped || !obj->seekable) {
eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_EV_IN_STOPPED, NULL, NULL));
} else {
eo_do(eo_obj, ecore_audio_obj_in_seek(0, SEEK_SET, NULL));
@ -207,8 +206,9 @@ static void _free_vio(Ecore_Audio_Object *ea_obj)
ea_obj->vio = NULL;
}
static void _vio_set(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
static void _vio_set(Eo *eo_obj, void *_pd, va_list *list)
{
Ecore_Audio_Input *obj = _pd;
Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
Ecore_Audio_Vio *vio = va_arg(*list, Ecore_Audio_Vio *);
@ -226,7 +226,7 @@ static void _vio_set(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
ea_obj->vio->data = data;
ea_obj->vio->free_func = free_func;
//FIXME: Save previous value
ea_obj->seekable = (vio->seek != NULL);
obj->seekable = (vio->seek != NULL);
}
static void _constructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)

View File

@ -156,7 +156,7 @@ static void _source_set(Eo *eo_obj, void *_pd, va_list *list)
return;
}
ea_obj->seekable = EINA_TRUE;
in_obj->seekable = EINA_TRUE;
in_obj->length = (double)obj->sfinfo.frames / obj->sfinfo.samplerate;
in_obj->samplerate = obj->sfinfo.samplerate;
@ -254,7 +254,7 @@ static void _vio_set(Eo *eo_obj, void *_pd, va_list *list)
if (ea_obj->vio)
_free_vio(ea_obj);
ea_obj->seekable = EINA_FALSE;
in_obj->seekable = EINA_FALSE;
if (!vio)
return;
@ -263,7 +263,7 @@ static void _vio_set(Eo *eo_obj, void *_pd, va_list *list)
ea_obj->vio->vio = vio;
ea_obj->vio->data = data;
ea_obj->vio->free_func = free_func;
ea_obj->seekable = (vio->seek != NULL);
in_obj->seekable = (vio->seek != NULL);
obj->handle = sf_open_virtual(&vio_wrapper, SFM_READ, &obj->sfinfo, eo_obj);
@ -273,7 +273,7 @@ static void _vio_set(Eo *eo_obj, void *_pd, va_list *list)
return;
}
ea_obj->seekable = EINA_TRUE;
in_obj->seekable = EINA_TRUE;
in_obj->length = (double)obj->sfinfo.frames / obj->sfinfo.samplerate;
in_obj->samplerate = obj->sfinfo.samplerate;

View File

@ -85,6 +85,7 @@ static void _seek(Eo *eo_obj, void *_pd, va_list *list)
if (ret)
*ret = (double)obj->phase / in_obj->samplerate;
return;
err:
if (ret)
*ret = -1.0;
@ -196,6 +197,7 @@ static void _constructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
in_obj->channels = 1;
in_obj->samplerate = 44100;
in_obj->length = 1;
in_obj->seekable = EINA_TRUE;
obj->freq = 1000;
}

View File

@ -106,7 +106,6 @@ struct _Ecore_Audio_Object
const char *name;
const char *source;
Eina_Bool seekable;
Eina_Bool paused;
double volume;
Ecore_Audio_Format format;
@ -129,6 +128,7 @@ struct _Ecore_Audio_Output
struct _Ecore_Audio_Input
{
Eina_Bool paused; /**< Is the input paused? */
Eina_Bool seekable;
Eo *output; /**< The output this input is connected to */