forked from enlightenment/efl
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>
This commit is contained in:
parent
ffb518fcdd
commit
6baada490e
|
@ -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);
|
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 ***********************************/
|
/************************* SPECTRUM API ***********************************/
|
||||||
|
|
|
@ -1455,6 +1455,53 @@ edje_edit_sound_compression_type_set(Evas_Object *obj, const char *sound, Edje_E
|
||||||
return EINA_TRUE;
|
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 */
|
/* GROUPS API */
|
||||||
/****************/
|
/****************/
|
||||||
|
|
Loading…
Reference in New Issue