asdfuser pushed a commit to branch master.

commit 845aeb5c63fb309041bde94f61a648ceb0504dc4
Author: Daniel Willmann <[email protected]>
Date:   Fri Apr 12 17:40:31 2013 +0100

    ecore_audio_obj_in: Implemented read and event sending
    
    A protected read function must now be implemented by the child class to
    perform the actual reading.
    
    Signals on playback loop and end are sent.
    
    Signed-off-by: Daniel Willmann <[email protected]>
---
 src/Makefile_Ecore_Audio.am                 |  3 ++-
 src/lib/ecore_audio/ecore_audio_obj_in.c    | 28 ++++++++++++++++++++++++----
 src/lib/ecore_audio/ecore_audio_obj_in.h    |  5 +++++
 src/lib/ecore_audio/ecore_audio_private.h   |  2 +-
 src/lib/ecore_audio/ecore_audio_protected.h | 10 ++++++++++
 5 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/src/Makefile_Ecore_Audio.am b/src/Makefile_Ecore_Audio.am
index 3af70cc..f19cae2 100644
--- a/src/Makefile_Ecore_Audio.am
+++ b/src/Makefile_Ecore_Audio.am
@@ -9,7 +9,8 @@ dist_installed_ecoreaudiomainheaders_DATA = \
 lib/ecore_audio/Ecore_Audio.h \
 lib/ecore_audio/ecore_audio_obj.h \
 lib/ecore_audio/ecore_audio_obj_in.h \
-lib/ecore_audio/ecore_audio_obj_out.h
+lib/ecore_audio/ecore_audio_obj_out.h \
+lib/ecore_audio/ecore_audio_protected.h
 
 
 lib_ecore_audio_libecore_audio_la_SOURCES = \
diff --git a/src/lib/ecore_audio/ecore_audio_obj_in.c 
b/src/lib/ecore_audio/ecore_audio_obj_in.c
index bd3a088..d5bb9a3 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in.c
+++ b/src/lib/ecore_audio/ecore_audio_obj_in.c
@@ -16,6 +16,11 @@
 
 EAPI Eo_Op ECORE_AUDIO_OBJ_IN_BASE_ID = EO_NOOP;
 
+EAPI const Eo_Event_Description _ECORE_AUDIO_EV_IN_LOOPED =
+         EO_EVENT_DESCRIPTION("in,looped", "Called when an input has looped.");
+EAPI const Eo_Event_Description _ECORE_AUDIO_EV_IN_STOPPED =
+         EO_EVENT_DESCRIPTION("in,stopped", "Called when an input has stopped 
playing.");
+
 #define MY_CLASS ECORE_AUDIO_OBJ_IN_CLASS
 #define MY_CLASS_NAME "ecore_audio_obj_in"
 
@@ -122,9 +127,17 @@ static void _read(Eo *eo_obj, void *_pd, va_list *list)
     memset(buf, 0, len);
     len_read = len;
   } else {
-      /* FIXME: Module read func */
-      len_read = 0;
-      /* FIXME: Signals for loop/EOF */
+      eo_do(eo_obj, ecore_audio_obj_in_read_internal(buf, len, &len_read));
+      if (len_read == 0) {
+          if (!obj->looped) {
+              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));
+              eo_do(eo_obj, ecore_audio_obj_in_read_internal(buf, len, 
&len_read));
+              eo_do(eo_obj, eo_event_callback_call(ECORE_AUDIO_EV_IN_LOOPED, 
NULL, NULL));
+          }
+      }
+
   }
 
   if (ret)
@@ -226,6 +239,7 @@ static const Eo_Op_Description op_desc[] = {
     EO_OP_DESCRIPTION(ECORE_AUDIO_OBJ_IN_SUB_ID_LOOPED_SET, S(looped)),
     EO_OP_DESCRIPTION(ECORE_AUDIO_OBJ_IN_SUB_ID_LOOPED_GET, G(looped)),
     EO_OP_DESCRIPTION(ECORE_AUDIO_OBJ_IN_SUB_ID_READ, "Read from the input"),
+    EO_OP_DESCRIPTION(ECORE_AUDIO_OBJ_IN_SUB_ID_READ_INTERNAL, "Internal 
implementation for the read"),
     EO_OP_DESCRIPTION(ECORE_AUDIO_OBJ_IN_SUB_ID_SEEK, "Seek within the input"),
     EO_OP_DESCRIPTION(ECORE_AUDIO_OBJ_IN_SUB_ID_OUTPUT_GET, G(output)),
     EO_OP_DESCRIPTION(ECORE_AUDIO_OBJ_IN_SUB_ID_LENGTH_GET, G(length)),
@@ -233,12 +247,18 @@ static const Eo_Op_Description op_desc[] = {
     EO_OP_DESCRIPTION_SENTINEL
 };
 
+static const Eo_Event_Description *event_desc[] = {
+    ECORE_AUDIO_EV_IN_LOOPED,
+    ECORE_AUDIO_EV_IN_STOPPED,
+    NULL
+};
+
 static const Eo_Class_Description class_desc = {
     EO_VERSION,
     MY_CLASS_NAME,
     EO_CLASS_TYPE_REGULAR,
     EO_CLASS_DESCRIPTION_OPS(&ECORE_AUDIO_OBJ_IN_BASE_ID, op_desc, 
ECORE_AUDIO_OBJ_IN_SUB_ID_LAST),
-    NULL,
+    event_desc,
     sizeof(Ecore_Audio_Input),
     _class_constructor,
     NULL
diff --git a/src/lib/ecore_audio/ecore_audio_obj_in.h 
b/src/lib/ecore_audio/ecore_audio_obj_in.h
index 57832b8..10becd0 100644
--- a/src/lib/ecore_audio/ecore_audio_obj_in.h
+++ b/src/lib/ecore_audio/ecore_audio_obj_in.h
@@ -52,6 +52,7 @@ enum Ecore_Audio_Obj_In_Sub_Ids
    ECORE_AUDIO_OBJ_IN_SUB_ID_LOOPED_SET,
    ECORE_AUDIO_OBJ_IN_SUB_ID_LOOPED_GET,
    ECORE_AUDIO_OBJ_IN_SUB_ID_READ,
+   ECORE_AUDIO_OBJ_IN_SUB_ID_READ_INTERNAL,
    ECORE_AUDIO_OBJ_IN_SUB_ID_SEEK,
    ECORE_AUDIO_OBJ_IN_SUB_ID_OUTPUT_GET,
    ECORE_AUDIO_OBJ_IN_SUB_ID_LENGTH_GET,
@@ -108,7 +109,11 @@ enum Ecore_Audio_Obj_In_Sub_Ids
 
 #define ecore_audio_obj_in_remaining_get(ret) 
ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_REMAINING_GET), 
EO_TYPECHECK(double *, ret)
 
+extern const Eo_Event_Description _ECORE_AUDIO_EV_IN_LOOPED;
+#define ECORE_AUDIO_EV_IN_LOOPED (&(_ECORE_AUDIO_EV_IN_LOOPED))
 
+extern const Eo_Event_Description _ECORE_AUDIO_EV_IN_STOPPED;
+#define ECORE_AUDIO_EV_IN_STOPPED (&(_ECORE_AUDIO_EV_IN_STOPPED))
 
 /**
  * @}
diff --git a/src/lib/ecore_audio/ecore_audio_private.h 
b/src/lib/ecore_audio/ecore_audio_private.h
index 3d6999f..7d74215 100644
--- a/src/lib/ecore_audio/ecore_audio_private.h
+++ b/src/lib/ecore_audio/ecore_audio_private.h
@@ -28,6 +28,7 @@
 #include "ecore_private.h"
 
 #include "Ecore_Audio.h"
+#include "ecore_audio_protected.h"
 
 extern int _ecore_audio_log_dom;
 
@@ -61,7 +62,6 @@ extern int _ecore_audio_log_dom;
 #endif
 #define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_audio_log_dom, __VA_ARGS__)
 
-
 /**
  * @defgroup Ecore_Audio_Module_API_Group Ecore_Audio_Module_API - API for 
modules
  * @ingroup Ecore_Audio_Group
diff --git a/src/lib/ecore_audio/ecore_audio_protected.h 
b/src/lib/ecore_audio/ecore_audio_protected.h
new file mode 100644
index 0000000..0e962ce
--- /dev/null
+++ b/src/lib/ecore_audio/ecore_audio_protected.h
@@ -0,0 +1,10 @@
+#ifndef ECORE_AUDIO_PROTECTED_H_
+#define ECORE_AUDIO_PROTECTED_H_
+
+#include "Eo.h"
+#include "Ecore.h"
+#include "Ecore_Audio.h"
+
+#define ecore_audio_obj_in_read_internal(buf, len, ret) 
ECORE_AUDIO_OBJ_IN_ID(ECORE_AUDIO_OBJ_IN_SUB_ID_READ_INTERNAL), 
EO_TYPECHECK(char *, buf), EO_TYPECHECK(int, len), EO_TYPECHECK(int *, ret)
+
+#endif

-- 

------------------------------------------------------------------------------
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