Hello, this does not look like a wrapper of ecore_audio. ecore_audio and edje_audio support audio features in different layers?
Daniel Juyung Seo (SeoZ) On Sun, Feb 9, 2014 at 7:19 PM, Carsten Haitzler <ras...@rasterman.com>wrote: > raster pushed a commit to branch master. > > > http://git.enlightenment.org/core/efl.git/commit/?id=db1990020a9039d867bf620d9f9463dda443f31e > > commit db1990020a9039d867bf620d9f9463dda443f31e > Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com> > Date: Sun Feb 9 19:08:12 2014 +0900 > > edje - feature - add channel types for sounds and ability to mute them > > this adds a new feature to be able to assign a sample to a given > "type" of audio channel, and then to be able to mute these from code. > --- > data/edje/include/edje.inc | 4 +-- > src/bin/edje/edje_cc_handlers.c | 14 +++++++- > src/lib/edje/Edje_Common.h | 71 > +++++++++++++++++++++++++++++++++++++++++ > src/lib/edje/edje_data.c | 1 + > src/lib/edje/edje_embryo.c | 22 +++++++++---- > src/lib/edje/edje_multisense.c | 53 +++++++++++++++++++++++++++--- > src/lib/edje/edje_private.h | 6 ++-- > src/lib/edje/edje_program.c | 4 +-- > 8 files changed, 157 insertions(+), 18 deletions(-) > > diff --git a/data/edje/include/edje.inc b/data/edje/include/edje.inc > index 1cf7b89..828380b 100644 > --- a/data/edje/include/edje.inc > +++ b/data/edje/include/edje.inc > @@ -235,8 +235,8 @@ native set_state_val(part_id, State_Param:p, ...); > native get_state_val(part_id, State_Param:p, ...); > > /* Multisense */ > -native play_sample (sample_name[], Float:speed); > -native play_tone (tone_name[], Float:duration); > +native play_sample (sample_name[], Float:speed, ...); > +native play_tone (tone_name[], Float:duration, ...); > > /***********************************************************/ > /* Edje physics calls. */ > diff --git a/src/bin/edje/edje_cc_handlers.c > b/src/bin/edje/edje_cc_handlers.c > index 0ea056d..dda4116 100644 > --- a/src/bin/edje/edje_cc_handlers.c > +++ b/src/bin/edje/edje_cc_handlers.c > @@ -9126,7 +9126,7 @@ st_collections_group_programs_program_in(void) > action: FOCUS_OBJECT;\n > action: PARAM_COPY "src_part" "src_param" "dst_part" > "dst_param";\n > action: PARAM_SET "part" "param" "value";\n > - action: PLAY_SAMPLE "sample name" speed (speed of sample - 1.0 > is original speed - faster is higher pitch);\n > + action: PLAY_SAMPLE "sample name" speed (speed of sample - 1.0 > is original speed - faster is higher pitch) [channel optional EFFECT/FX | > BACKGROUND/BG | MUSIC/MUS | FOREGROUND/FG | INTERFACE/UI | INPUT | ALERT;\n > action: PLAY_TONE "tone name" duration in seconds ( Range 0.1 > to 10.0 );\n > action: PHYSICS_IMPULSE 10 -23.4 0;\n > action: PHYSICS_TORQUE_IMPULSE 0 2.1 0.95;\n > @@ -9199,6 +9199,16 @@ st_collections_group_programs_program_action(void) > } > } > ep->speed = parse_float_range(2, 0.0, 100.0); > + if (get_arg_count() >= 4) > + ep->channel = parse_enum(3, > + "EFFECT", 0, "FX", 0, > + "BACKGROUND", 1, "BG", 1, > + "MUSIC", 2, "MUS", 2, > + "FOREGROUND", 3, "FG", 3, > + "INTERFACE", 4, "UI", 4, > + "INPUT", 5, > + "ALERT", 6, > + NULL); > } > else if (ep->action == EDJE_ACTION_TYPE_SOUND_TONE) > { > @@ -9303,6 +9313,8 @@ st_collections_group_programs_program_action(void) > case EDJE_ACTION_TYPE_PHYSICS_ROT_SET: > check_arg_count(5); > break; > + case EDJE_ACTION_TYPE_SOUND_SAMPLE: > + break; > default: > check_arg_count(3); > } > diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h > index a2dbf13..9d83fb5 100644 > --- a/src/lib/edje/Edje_Common.h > +++ b/src/lib/edje/Edje_Common.h > @@ -2026,3 +2026,74 @@ EAPI const Edje_Perspective > *edje_evas_global_perspective_get(const Evas *e); > /** > * @} > */ > + > +/** > + * @defgroup Edje_Audio Edje Audio > + * > + * @brief Functions to manipulate audio abilities in edje. > + * > + * Perspective is a graphical tool that makes objets represented in 2D > + * look like they have a 3D appearance. > + * > + * Edje allows us to use perspective on any edje object. This group of > + * functions deal with the use of perspective, by creating and configuring > + * a perspective object that must set to a edje object or a canvas, > + * affecting all the objects inside that have no particular perspective > + * set already. > + * > + * @ingroup Edje_Audio > + * > + * @{ > + */ > + > +/** > + * Identifiers of Edje message types, which can be sent back and forth > + * code and a given Edje object's theme file/group. > + * > + * @see edje_audio_channel_mute_set() > + * @see edje_audio_channel_mute_get() > + * > + * @since 1.9 > + */ > +typedef enum _Edje_Channel > +{ > + EDJE_CHANNEL_EFFECT = 0, /**< Standard audio effects */ > + EDJE_CHANNEL_BACKGROUND = 1, /**< Background audio sounds */ > + EDJE_CHANNEL_MUSIC = 2, /**< Music audio */ > + EDJE_CHANNEL_FOREGROUND = 3, /**< Foreground audio sounds */ > + EDJE_CHANNEL_INTERFACE = 4, /**< Sounds related to the interface */ > + EDJE_CHANNEL_INPUT = 5, /**< Sounds related to regular input */ > + EDJE_CHANNEL_ALERT = 6, /**< Sounds for major alerts */ > + EDJE_CHANNEL_ALL = 7 /**< All audio channels (convenience) */ > +} Edje_Channel; > + > +/** > + * Set the mute state of audio for the process as a whole > + * > + * @param channel The channel to set the mute state of > + * @param mute The mute state > + * > + * This sets the mute (no output) state of audio for the given channel. > + * > + * @see edje_audio_channel_mute_get() > + * > + * @since 1.9 > + */ > +EAPI void edje_audio_channel_mute_set(Edje_Channel channel, Eina_Bool > mute); > + > +/** > + * Get the mute state of the given channel > + * > + * @param channel The channel to get the mute state of > + * @return The mute state of the channel > + * > + * @see edje_audio_channel_mute_set() > + * > + * @since 1.9 > + */ > +EAPI Eina_Bool edje_audio_channel_mute_get(Edje_Channel channel); > + > +/** > + * @} > + */ > + > diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c > index 3a11cff..fc76593 100644 > --- a/src/lib/edje/edje_data.c > +++ b/src/lib/edje/edje_data.c > @@ -477,6 +477,7 @@ _edje_edd_init(void) > EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, > "physics.y", physics.y, EET_T_DOUBLE); > EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, > "physics.z", physics.z, EET_T_DOUBLE); > #endif > + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, > "channel", channel, EET_T_UCHAR); > > EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Image_Id); > _edje_edd_edje_part_image_id = > diff --git a/src/lib/edje/edje_embryo.c b/src/lib/edje/edje_embryo.c > index cb20648..d09ae72 100644 > --- a/src/lib/edje/edje_embryo.c > +++ b/src/lib/edje/edje_embryo.c > @@ -73,8 +73,8 @@ > * set_state(part_id, state[], Float:state_val) > * get_state(part_id, dst[], maxlen, &Float:val) > * set_tween_state(part_id, Float:tween, state1[], Float:state1_val, > state2[], Float:state2_val) > - * play_sample(sample_name, speed) > - * play_tone(tone_name, duration) > + * play_sample(sample_name, speed, ...) > + * play_tone(tone_name, duration, ...) > * run_program(program_id) > * Direction:get_drag_dir(part_id) > * get_drag(part_id, &Float:dx, &Float:&dy) > @@ -915,13 +915,18 @@ _edje_embryo_fn_play_sample(Embryo_Program *ep, > Embryo_Cell *params) > Edje *ed; > char *sample_name = NULL; > float speed = 1.0; > + int channel = 0; > > - CHKPARAM(2); > + if (params[0] < (int) (sizeof(Embryo_Cell) * 2)) > + return 0; > ed = embryo_program_data_get(ep); > GETSTR(sample_name, params[1]); > if ((!sample_name)) return 0; > speed = EMBRYO_CELL_TO_FLOAT(params[2]); > - _edje_multisense_internal_sound_sample_play(ed, sample_name, > (double)speed); > + if (params[0] == (int) (sizeof(Embryo_Cell) * 3)) > + GETINT(channel, params[3]); > + _edje_multisense_internal_sound_sample_play(ed, sample_name, > + (double)speed, channel); > return 0; > } > > @@ -931,13 +936,18 @@ _edje_embryo_fn_play_tone(Embryo_Program *ep, > Embryo_Cell *params) > Edje *ed; > char *tone_name = NULL; > float duration = 0.1; > + int channel = 0; > > - CHKPARAM(2); > + if (params[0] < (int) (sizeof(Embryo_Cell) * 2)) > + return 0; > ed = embryo_program_data_get(ep); > GETSTR(tone_name, params[1]); > if ((!tone_name)) return 0; > duration = EMBRYO_CELL_TO_FLOAT(params[2]); > - _edje_multisense_internal_sound_tone_play(ed, tone_name, (double) > duration); > + if (params[0] == (int) (sizeof(Embryo_Cell) * 3)) > + GETINT(channel, params[3]); > + _edje_multisense_internal_sound_tone_play(ed, tone_name, > + (double)duration, channel); > return 0; > } > > diff --git a/src/lib/edje/edje_multisense.c > b/src/lib/edje/edje_multisense.c > index daa878e..a8ae628 100644 > --- a/src/lib/edje/edje_multisense.c > +++ b/src/lib/edje/edje_multisense.c > @@ -80,7 +80,8 @@ eet_snd_file_tell(void *data, Eo *eo_obj EINA_UNUSED) > return vf->offset; > } > > -static void _free(void *data) > +static void > +_free(void *data) > { > struct _edje_multisense_eet_data *eet_data = data; > > @@ -90,18 +91,58 @@ static void _free(void *data) > free(data); > outs--; > } > + > +static Eina_Bool _channel_mute_states[8] = { 0 }; > + > +static Eina_Bool > +_channel_mute(Edje *ed EINA_UNUSED, int channel) > +{ > + // ed lets use set mute per object... but for now no api's for this > + // if all are muted ... then all! > + if (_channel_mute_states[7]) return EINA_TRUE; > + if ((channel < 0) || (channel > 7)) return EINA_FALSE; > + return _channel_mute_states[channel]; > + return EINA_FALSE; > +} > + > +#endif > + > +EAPI void > +edje_audio_channel_mute_set(Edje_Channel channel, Eina_Bool mute) > +{ > +#ifdef ENABLE_MULTISENSE > + if ((channel < 0) || (channel > 7)) return; > + _channel_mute_states[channel] = mute; > +#else > + (void) channel; > + (void) mute; > #endif > +} > + > +EAPI Eina_Bool > +edje_audio_channel_mute_get(Edje_Channel channel) > +{ > +#ifdef ENABLE_MULTISENSE > + if ((channel < 0) || (channel > 7)) return EINA_FALSE; > + return _channel_mute_states[channel]; > +#else > + (void) channel; > + return EINA_FALSE; > +#endif > +} > > Eina_Bool > -_edje_multisense_internal_sound_sample_play(Edje *ed, const char > *sample_name, const double speed) > +_edje_multisense_internal_sound_sample_play(Edje *ed, const char > *sample_name, const double speed, int channel) > { > - #ifdef ENABLE_MULTISENSE > +#ifdef ENABLE_MULTISENSE > Eo *in; > Edje_Sound_Sample *sample; > char snd_id_str[255]; > int i; > Eina_Bool ret; > > + if (_channel_mute(ed, channel)) return EINA_FALSE; > + > if (outfail) return EINA_FALSE; > > if (!sample_name) > @@ -189,12 +230,13 @@ _edje_multisense_internal_sound_sample_play(Edje > *ed, const char *sample_name, c > (void) ed; > (void) sample_name; > (void) speed; > + (void) channel; > return EINA_FALSE; > #endif > } > > Eina_Bool > -_edje_multisense_internal_sound_tone_play(Edje *ed, const char > *tone_name, const double duration) > +_edje_multisense_internal_sound_tone_play(Edje *ed, const char > *tone_name, const double duration, int channel) > { > #ifdef ENABLE_MULTISENSE > unsigned int i; > @@ -208,6 +250,8 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, > const char *tone_name, const > return EINA_FALSE; > } > > + if (_channel_mute(ed, channel)) return EINA_FALSE; > + > if (outfail) return EINA_FALSE; > > if ((!ed) || (!ed->file) || (!ed->file->sound_dir)) > @@ -245,6 +289,7 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, > const char *tone_name, const > (void) ed; > (void) duration; > (void) tone_name; > + (void) channel; > return EINA_FALSE; > #endif > > diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h > index a057d8e..698d085 100644 > --- a/src/lib/edje/edje_private.h > +++ b/src/lib/edje/edje_private.h > @@ -676,7 +676,7 @@ struct _Edje_Program /* a conditional program to be > run */ > double z; > } physics; > #endif > - > + unsigned char channel; > Eina_Bool exec : 1; > }; > > @@ -2427,8 +2427,8 @@ void _edje_subobj_unregister(Edje *ed, Evas_Object > *ob); > > void _edje_multisense_init(void); > void _edje_multisense_shutdown(void); > -Eina_Bool _edje_multisense_internal_sound_sample_play(Edje *ed, const > char *sample_name, const double speed); > -Eina_Bool _edje_multisense_internal_sound_tone_play(Edje *ed, const char > *tone_name, const double duration); > +Eina_Bool _edje_multisense_internal_sound_sample_play(Edje *ed, const > char *sample_name, const double speed, int channel); > +Eina_Bool _edje_multisense_internal_sound_tone_play(Edje *ed, const char > *tone_name, const double duration, int channel); > > void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, > Edje_Calc_Params *state); > > diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c > index a3b1747..ac32aa5 100644 > --- a/src/lib/edje/edje_program.c > +++ b/src/lib/edje/edje_program.c > @@ -877,12 +877,12 @@ low_mem_current: > case EDJE_ACTION_TYPE_SOUND_SAMPLE: > if (_edje_block_break(ed)) > goto break_prog; > - _edje_multisense_internal_sound_sample_play(ed, pr->sample_name, > pr->speed); > + _edje_multisense_internal_sound_sample_play(ed, pr->sample_name, > pr->speed, pr->channel); > break; > case EDJE_ACTION_TYPE_SOUND_TONE: > if (_edje_block_break(ed)) > goto break_prog; > - _edje_multisense_internal_sound_tone_play(ed, pr->tone_name, > pr->duration); > + _edje_multisense_internal_sound_tone_play(ed, pr->tone_name, > pr->duration, pr->channel); > break; > case EDJE_ACTION_TYPE_PARAM_COPY: > { > > -- > > > ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel