ecore_audio_obj_in: Implemented read and event sending
authorDaniel Willmann <d.willmann@samsung.com>
Fri, 12 Apr 2013 16:40:31 +0000 (17:40 +0100)
committerDaniel Willmann <d.willmann@samsung.com>
Thu, 18 Apr 2013 18:12:17 +0000 (19:12 +0100)
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 <d.willmann@samsung.com>
src/Makefile_Ecore_Audio.am
src/lib/ecore_audio/ecore_audio_obj_in.c
src/lib/ecore_audio/ecore_audio_obj_in.h
src/lib/ecore_audio/ecore_audio_private.h
src/lib/ecore_audio/ecore_audio_protected.h [new file with mode: 0644]

index 3af70cc..f19cae2 100644 (file)
@@ -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 = \
index bd3a088..d5bb9a3 100644 (file)
 
 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
index 57832b8..10becd0 100644 (file)
@@ -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))
 
 /**
  * @}
index 3d6999f..7d74215 100644 (file)
@@ -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 (file)
index 0000000..0e962ce
--- /dev/null
@@ -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