summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-02-09 19:08:12 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-02-09 19:08:12 +0900
commitdb1990020a9039d867bf620d9f9463dda443f31e (patch)
tree5eee2efd5fbca5563a5359adce32398c977b4508 /src/lib
parent7c7f2eb30032b520d66fe43fa7000ae18264de49 (diff)
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.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/edje/Edje_Common.h71
-rw-r--r--src/lib/edje/edje_data.c1
-rw-r--r--src/lib/edje/edje_embryo.c22
-rw-r--r--src/lib/edje/edje_multisense.c53
-rw-r--r--src/lib/edje/edje_private.h6
-rw-r--r--src/lib/edje/edje_program.c4
6 files changed, 142 insertions, 15 deletions
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h
index a2dbf1340a..9d83fb5144 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);
2026/** 2026/**
2027 * @} 2027 * @}
2028 */ 2028 */
2029
2030/**
2031 * @defgroup Edje_Audio Edje Audio
2032 *
2033 * @brief Functions to manipulate audio abilities in edje.
2034 *
2035 * Perspective is a graphical tool that makes objets represented in 2D
2036 * look like they have a 3D appearance.
2037 *
2038 * Edje allows us to use perspective on any edje object. This group of
2039 * functions deal with the use of perspective, by creating and configuring
2040 * a perspective object that must set to a edje object or a canvas,
2041 * affecting all the objects inside that have no particular perspective
2042 * set already.
2043 *
2044 * @ingroup Edje_Audio
2045 *
2046 * @{
2047 */
2048
2049/**
2050 * Identifiers of Edje message types, which can be sent back and forth
2051 * code and a given Edje object's theme file/group.
2052 *
2053 * @see edje_audio_channel_mute_set()
2054 * @see edje_audio_channel_mute_get()
2055 *
2056 * @since 1.9
2057 */
2058typedef enum _Edje_Channel
2059{
2060 EDJE_CHANNEL_EFFECT = 0, /**< Standard audio effects */
2061 EDJE_CHANNEL_BACKGROUND = 1, /**< Background audio sounds */
2062 EDJE_CHANNEL_MUSIC = 2, /**< Music audio */
2063 EDJE_CHANNEL_FOREGROUND = 3, /**< Foreground audio sounds */
2064 EDJE_CHANNEL_INTERFACE = 4, /**< Sounds related to the interface */
2065 EDJE_CHANNEL_INPUT = 5, /**< Sounds related to regular input */
2066 EDJE_CHANNEL_ALERT = 6, /**< Sounds for major alerts */
2067 EDJE_CHANNEL_ALL = 7 /**< All audio channels (convenience) */
2068} Edje_Channel;
2069
2070/**
2071 * Set the mute state of audio for the process as a whole
2072 *
2073 * @param channel The channel to set the mute state of
2074 * @param mute The mute state
2075 *
2076 * This sets the mute (no output) state of audio for the given channel.
2077 *
2078 * @see edje_audio_channel_mute_get()
2079 *
2080 * @since 1.9
2081 */
2082EAPI void edje_audio_channel_mute_set(Edje_Channel channel, Eina_Bool mute);
2083
2084/**
2085 * Get the mute state of the given channel
2086 *
2087 * @param channel The channel to get the mute state of
2088 * @return The mute state of the channel
2089 *
2090 * @see edje_audio_channel_mute_set()
2091 *
2092 * @since 1.9
2093 */
2094EAPI Eina_Bool edje_audio_channel_mute_get(Edje_Channel channel);
2095
2096/**
2097 * @}
2098 */
2099
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index 3a11cff0ae..fc76593bdb 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -477,6 +477,7 @@ _edje_edd_init(void)
477 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "physics.y", physics.y, EET_T_DOUBLE); 477 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "physics.y", physics.y, EET_T_DOUBLE);
478 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "physics.z", physics.z, EET_T_DOUBLE); 478 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "physics.z", physics.z, EET_T_DOUBLE);
479#endif 479#endif
480 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "channel", channel, EET_T_UCHAR);
480 481
481 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Image_Id); 482 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Image_Id);
482 _edje_edd_edje_part_image_id = 483 _edje_edd_edje_part_image_id =
diff --git a/src/lib/edje/edje_embryo.c b/src/lib/edje/edje_embryo.c
index cb20648433..d09ae72024 100644
--- a/src/lib/edje/edje_embryo.c
+++ b/src/lib/edje/edje_embryo.c
@@ -73,8 +73,8 @@
73 * set_state(part_id, state[], Float:state_val) 73 * set_state(part_id, state[], Float:state_val)
74 * get_state(part_id, dst[], maxlen, &Float:val) 74 * get_state(part_id, dst[], maxlen, &Float:val)
75 * set_tween_state(part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val) 75 * set_tween_state(part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val)
76 * play_sample(sample_name, speed) 76 * play_sample(sample_name, speed, ...)
77 * play_tone(tone_name, duration) 77 * play_tone(tone_name, duration, ...)
78 * run_program(program_id) 78 * run_program(program_id)
79 * Direction:get_drag_dir(part_id) 79 * Direction:get_drag_dir(part_id)
80 * get_drag(part_id, &Float:dx, &Float:&dy) 80 * get_drag(part_id, &Float:dx, &Float:&dy)
@@ -915,13 +915,18 @@ _edje_embryo_fn_play_sample(Embryo_Program *ep, Embryo_Cell *params)
915 Edje *ed; 915 Edje *ed;
916 char *sample_name = NULL; 916 char *sample_name = NULL;
917 float speed = 1.0; 917 float speed = 1.0;
918 int channel = 0;
918 919
919 CHKPARAM(2); 920 if (params[0] < (int) (sizeof(Embryo_Cell) * 2))
921 return 0;
920 ed = embryo_program_data_get(ep); 922 ed = embryo_program_data_get(ep);
921 GETSTR(sample_name, params[1]); 923 GETSTR(sample_name, params[1]);
922 if ((!sample_name)) return 0; 924 if ((!sample_name)) return 0;
923 speed = EMBRYO_CELL_TO_FLOAT(params[2]); 925 speed = EMBRYO_CELL_TO_FLOAT(params[2]);
924 _edje_multisense_internal_sound_sample_play(ed, sample_name, (double)speed); 926 if (params[0] == (int) (sizeof(Embryo_Cell) * 3))
927 GETINT(channel, params[3]);
928 _edje_multisense_internal_sound_sample_play(ed, sample_name,
929 (double)speed, channel);
925 return 0; 930 return 0;
926} 931}
927 932
@@ -931,13 +936,18 @@ _edje_embryo_fn_play_tone(Embryo_Program *ep, Embryo_Cell *params)
931 Edje *ed; 936 Edje *ed;
932 char *tone_name = NULL; 937 char *tone_name = NULL;
933 float duration = 0.1; 938 float duration = 0.1;
939 int channel = 0;
934 940
935 CHKPARAM(2); 941 if (params[0] < (int) (sizeof(Embryo_Cell) * 2))
942 return 0;
936 ed = embryo_program_data_get(ep); 943 ed = embryo_program_data_get(ep);
937 GETSTR(tone_name, params[1]); 944 GETSTR(tone_name, params[1]);
938 if ((!tone_name)) return 0; 945 if ((!tone_name)) return 0;
939 duration = EMBRYO_CELL_TO_FLOAT(params[2]); 946 duration = EMBRYO_CELL_TO_FLOAT(params[2]);
940 _edje_multisense_internal_sound_tone_play(ed, tone_name, (double) duration); 947 if (params[0] == (int) (sizeof(Embryo_Cell) * 3))
948 GETINT(channel, params[3]);
949 _edje_multisense_internal_sound_tone_play(ed, tone_name,
950 (double)duration, channel);
941 return 0; 951 return 0;
942} 952}
943 953
diff --git a/src/lib/edje/edje_multisense.c b/src/lib/edje/edje_multisense.c
index daa878ea0c..a8ae628c8d 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)
80 return vf->offset; 80 return vf->offset;
81} 81}
82 82
83static void _free(void *data) 83static void
84_free(void *data)
84{ 85{
85 struct _edje_multisense_eet_data *eet_data = data; 86 struct _edje_multisense_eet_data *eet_data = data;
86 87
@@ -90,18 +91,58 @@ static void _free(void *data)
90 free(data); 91 free(data);
91 outs--; 92 outs--;
92} 93}
94
95static Eina_Bool _channel_mute_states[8] = { 0 };
96
97static Eina_Bool
98_channel_mute(Edje *ed EINA_UNUSED, int channel)
99{
100 // ed lets use set mute per object... but for now no api's for this
101 // if all are muted ... then all!
102 if (_channel_mute_states[7]) return EINA_TRUE;
103 if ((channel < 0) || (channel > 7)) return EINA_FALSE;
104 return _channel_mute_states[channel];
105 return EINA_FALSE;
106}
107
108#endif
109
110EAPI void
111edje_audio_channel_mute_set(Edje_Channel channel, Eina_Bool mute)
112{
113#ifdef ENABLE_MULTISENSE
114 if ((channel < 0) || (channel > 7)) return;
115 _channel_mute_states[channel] = mute;
116#else
117 (void) channel;
118 (void) mute;
93#endif 119#endif
120}
121
122EAPI Eina_Bool
123edje_audio_channel_mute_get(Edje_Channel channel)
124{
125#ifdef ENABLE_MULTISENSE
126 if ((channel < 0) || (channel > 7)) return EINA_FALSE;
127 return _channel_mute_states[channel];
128#else
129 (void) channel;
130 return EINA_FALSE;
131#endif
132}
94 133
95Eina_Bool 134Eina_Bool
96_edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed) 135_edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed, int channel)
97{ 136{
98 #ifdef ENABLE_MULTISENSE 137#ifdef ENABLE_MULTISENSE
99 Eo *in; 138 Eo *in;
100 Edje_Sound_Sample *sample; 139 Edje_Sound_Sample *sample;
101 char snd_id_str[255]; 140 char snd_id_str[255];
102 int i; 141 int i;
103 Eina_Bool ret; 142 Eina_Bool ret;
104 143
144 if (_channel_mute(ed, channel)) return EINA_FALSE;
145
105 if (outfail) return EINA_FALSE; 146 if (outfail) return EINA_FALSE;
106 147
107 if (!sample_name) 148 if (!sample_name)
@@ -189,12 +230,13 @@ _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, c
189 (void) ed; 230 (void) ed;
190 (void) sample_name; 231 (void) sample_name;
191 (void) speed; 232 (void) speed;
233 (void) channel;
192 return EINA_FALSE; 234 return EINA_FALSE;
193#endif 235#endif
194} 236}
195 237
196Eina_Bool 238Eina_Bool
197_edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration) 239_edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration, int channel)
198{ 240{
199#ifdef ENABLE_MULTISENSE 241#ifdef ENABLE_MULTISENSE
200 unsigned int i; 242 unsigned int i;
@@ -208,6 +250,8 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
208 return EINA_FALSE; 250 return EINA_FALSE;
209 } 251 }
210 252
253 if (_channel_mute(ed, channel)) return EINA_FALSE;
254
211 if (outfail) return EINA_FALSE; 255 if (outfail) return EINA_FALSE;
212 256
213 if ((!ed) || (!ed->file) || (!ed->file->sound_dir)) 257 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
245 (void) ed; 289 (void) ed;
246 (void) duration; 290 (void) duration;
247 (void) tone_name; 291 (void) tone_name;
292 (void) channel;
248 return EINA_FALSE; 293 return EINA_FALSE;
249#endif 294#endif
250 295
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index a057d8e659..698d08599b 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 */
676 double z; 676 double z;
677 } physics; 677 } physics;
678#endif 678#endif
679 679 unsigned char channel;
680 Eina_Bool exec : 1; 680 Eina_Bool exec : 1;
681}; 681};
682 682
@@ -2427,8 +2427,8 @@ void _edje_subobj_unregister(Edje *ed, Evas_Object *ob);
2427 2427
2428void _edje_multisense_init(void); 2428void _edje_multisense_init(void);
2429void _edje_multisense_shutdown(void); 2429void _edje_multisense_shutdown(void);
2430Eina_Bool _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed); 2430Eina_Bool _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed, int channel);
2431Eina_Bool _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration); 2431Eina_Bool _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration, int channel);
2432 2432
2433void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state); 2433void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state);
2434 2434
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index a3b1747c46..ac32aa57e9 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -877,12 +877,12 @@ low_mem_current:
877 case EDJE_ACTION_TYPE_SOUND_SAMPLE: 877 case EDJE_ACTION_TYPE_SOUND_SAMPLE:
878 if (_edje_block_break(ed)) 878 if (_edje_block_break(ed))
879 goto break_prog; 879 goto break_prog;
880 _edje_multisense_internal_sound_sample_play(ed, pr->sample_name, pr->speed); 880 _edje_multisense_internal_sound_sample_play(ed, pr->sample_name, pr->speed, pr->channel);
881 break; 881 break;
882 case EDJE_ACTION_TYPE_SOUND_TONE: 882 case EDJE_ACTION_TYPE_SOUND_TONE:
883 if (_edje_block_break(ed)) 883 if (_edje_block_break(ed))
884 goto break_prog; 884 goto break_prog;
885 _edje_multisense_internal_sound_tone_play(ed, pr->tone_name, pr->duration); 885 _edje_multisense_internal_sound_tone_play(ed, pr->tone_name, pr->duration, pr->channel);
886 break; 886 break;
887 case EDJE_ACTION_TYPE_PARAM_COPY: 887 case EDJE_ACTION_TYPE_PARAM_COPY:
888 { 888 {