summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Gala <i.gala@samsung.com>2014-09-22 14:24:32 +0200
committerCedric BAIL <cedric@osg.samsung.com>2014-09-22 14:59:27 +0200
commit6baada490e87fcdae3e0e053fb345d7c44053b20 (patch)
tree862d9ab27ac02d5b727a43df369347bcdee361e9
parentffb518fcdd7982290cd5e8d1d1b64a6bb4825bfb (diff)
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 <cedric@osg.samsung.com>
-rw-r--r--src/lib/edje/Edje_Edit.h10
-rw-r--r--src/lib/edje/edje_edit.c47
2 files changed, 57 insertions, 0 deletions
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,
5004 */ 5004 */
5005EAPI Eina_Bool edje_edit_sound_compression_type_set(Evas_Object *obj, const char* name, Edje_Edit_Sound_Comp sc); 5005EAPI Eina_Bool edje_edit_sound_compression_type_set(Evas_Object *obj, const char* name, Edje_Edit_Sound_Comp sc);
5006 5006
5007/** Get the certain sound data from the edje object.
5008 *
5009 * @param obj Object being edited.
5010 * @param sample_name The name of the sound.
5011 *
5012 * @return buf The buffer that contains data of the sound. To free the resources use eina_binbuf_free().
5013 * @since 1.11
5014 */
5015EAPI Eina_Binbuf *edje_edit_sound_samplebuffer_get(Evas_Object *obj, const char *sample_name);
5016
5007//@} 5017//@}
5008/******************************************************************************/ 5018/******************************************************************************/
5009/************************* SPECTRUM API ***********************************/ 5019/************************* 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
1455 return EINA_TRUE; 1455 return EINA_TRUE;
1456} 1456}
1457 1457
1458EAPI Eina_Binbuf *
1459edje_edit_sound_samplebuffer_get(Evas_Object *obj, const char *sample_name)
1460{
1461 Eet_File *ef;
1462 Edje_Sound_Sample *sample;
1463 char snd_id_str[PATH_MAX];
1464 int i, len;
1465 const void *data;
1466
1467 if (!sample_name)
1468 {
1469 ERR("Given Sample Name is NULL\n");
1470 return NULL;
1471 }
1472
1473 GET_ED_OR_RETURN(NULL);
1474
1475 if ((!ed) || (!ed->file) || (!ed->file->sound_dir))
1476 return NULL;
1477
1478 for(i = 0; i < (int)ed->file->sound_dir->samples_count; i++)
1479 {
1480 sample = &ed->file->sound_dir->samples[i];
1481 if (!strcmp(sample->name, sample_name))
1482 {
1483 ef = eet_mmap(ed->file->f);
1484 if (!ef)
1485 {
1486 ERR("Cannot open edje file '%s' for samples", ed->path);
1487 return NULL;
1488 }
1489 snprintf(snd_id_str, sizeof(snd_id_str), "edje/sounds/%i", sample->id);
1490 data = eet_read_direct(ef, snd_id_str, &len);
1491 if (len <= 0)
1492 {
1493 ERR("Sample from edj file '%s' has 0 length", ed->path);
1494 eet_close(ef);
1495 return NULL;
1496 }
1497 eet_close(ef);
1498 return eina_binbuf_manage_read_only_new_length(data, len);
1499 }
1500 }
1501 return NULL;
1502}
1503
1504
1458/****************/ 1505/****************/
1459/* GROUPS API */ 1506/* GROUPS API */
1460/****************/ 1507/****************/