asdfuser pushed a commit to branch master.

commit 1c0107afd8989a48841fd5bd94bfc0bd322b8030
Author: Daniel Willmann <[email protected]>
Date:   Fri Apr 19 15:28:00 2013 +0100

    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 <[email protected]>
---
 src/lib/ecore_audio/ecore_audio_obj_in.c         | 10 +++++-----
 src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c |  8 ++++----
 src/lib/ecore_audio/ecore_audio_obj_in_tone.c    |  2 ++
 src/lib/ecore_audio/ecore_audio_private.h        |  2 +-
 4 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/lib/ecore_audio/ecore_audio_obj_in.c 
b/src/lib/ecore_audio/ecore_audio_obj_in.c
index 72a0a23..1264939 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_in.c
@@ -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)
diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c 
b/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
index 08ff509..6dcc9fb 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_in_sndfile.c
@@ -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;
diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c 
b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c
index f00d5d4..11627f1 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c
@@ -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;
 }
diff --git a/src/lib/ecore_audio/ecore_audio_private.h 
b/src/lib/ecore_audio/ecore_audio_private.h
index e899a04..0b0bfec 100644
--- a/src/lib/ecore_audio/ecore_audio_private.h
+++ b/src/lib/ecore_audio/ecore_audio_private.h
@@ -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 */
 

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

Reply via email to