cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6baada490e87fcdae3e0e053fb345d7c44053b20

commit 6baada490e87fcdae3e0e053fb345d7c44053b20
Author: Igor Gala <[email protected]>
Date:   Mon Sep 22 14:24:32 2014 +0200

    edje: Edje_Edit - get the buffer with sound's data
    
    Summary:
    add opportunity get the buffer with sound data for certain sound
    from the given edje object. It is needed to play some sound with logic API.
    @feature
    
    Reviewers: Hermet, raster, seoz, reutskiy.v.v, NikaWhite, cedric
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D1422
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/lib/edje/Edje_Edit.h | 10 ++++++++++
 src/lib/edje/edje_edit.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 82175f8..14bbb72 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -5004,6 +5004,16 @@ EAPI Edje_Edit_Sound_Comp 
edje_edit_sound_compression_type_get(Evas_Object *obj,
  */
 EAPI Eina_Bool edje_edit_sound_compression_type_set(Evas_Object *obj, const 
char* name, Edje_Edit_Sound_Comp sc);
 
+/** Get the certain sound data from the edje object.
+ *
+ * @param obj Object being edited.
+ * @param sample_name The name of the sound.
+ *
+ * @return buf The buffer that contains data of the sound. To free the 
resources use eina_binbuf_free().
+ * @since 1.11
+ */
+EAPI Eina_Binbuf *edje_edit_sound_samplebuffer_get(Evas_Object *obj, const 
char *sample_name);
+
 //@}
 
/******************************************************************************/
 /*************************   SPECTRUM API   
***********************************/
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 82f69ab..f51e229 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -1455,6 +1455,53 @@ edje_edit_sound_compression_type_set(Evas_Object *obj, 
const char *sound, Edje_E
    return EINA_TRUE;
 }
 
+EAPI Eina_Binbuf *
+edje_edit_sound_samplebuffer_get(Evas_Object *obj, const char *sample_name)
+{
+   Eet_File *ef;
+   Edje_Sound_Sample *sample;
+   char snd_id_str[PATH_MAX];
+   int i, len;
+   const void *data;
+
+   if (!sample_name)
+    {
+       ERR("Given Sample Name is NULL\n");
+       return NULL;
+    }
+
+   GET_ED_OR_RETURN(NULL);
+
+   if ((!ed) || (!ed->file) || (!ed->file->sound_dir))
+     return NULL;
+
+   for(i = 0; i < (int)ed->file->sound_dir->samples_count; i++)
+     {
+        sample = &ed->file->sound_dir->samples[i];
+        if (!strcmp(sample->name, sample_name))
+          {
+             ef = eet_mmap(ed->file->f);
+             if (!ef)
+               {
+                  ERR("Cannot open edje file '%s' for samples", ed->path);
+                  return NULL;
+               }
+             snprintf(snd_id_str, sizeof(snd_id_str), "edje/sounds/%i", 
sample->id);
+             data = eet_read_direct(ef, snd_id_str, &len);
+             if (len <= 0)
+               {
+                  ERR("Sample from edj file '%s' has 0 length", ed->path);
+                  eet_close(ef);
+                  return NULL;
+               }
+             eet_close(ef);
+             return eina_binbuf_manage_read_only_new_length(data, len);
+          }
+     }
+   return NULL;
+}
+
+
 /****************/
 /*  GROUPS API  */
 /****************/

-- 


Reply via email to