4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>,YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 #include "mm_player_utils.h"
24 #include "mm_player_audioeffect.h"
25 #include "mm_player_ini.h"
26 #include "mm_player_priv.h"
31 mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudioEffectType effect_type, mmplayer_supported_audio_effect_cb foreach_cb, void *user_data)
33 mm_player_t *player = NULL;
34 int result = MM_ERROR_NONE;
35 mm_sound_device_flags_e flags = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG | MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
36 MMSoundDeviceList_t device_list;
37 MMSoundDevice_t device_h = NULL;
38 mm_sound_device_type_e device_type;
43 return_val_if_fail ( hplayer, MM_ERROR_PLAYER_NOT_INITIALIZED );
45 player = MM_PLAYER_CAST(hplayer);
47 /* get status if speaker is activated */
48 /* (1) get current device list */
49 result = mm_sound_get_current_device_list(flags, &device_list);
52 debug_error("mm_sound_get_current_device_list() failed [%x]!!", result);
57 /* (2) get device handle of device list */
58 result = mm_sound_get_next_device (device_list, &device_h);
61 debug_error("mm_sound_get_next_device() failed [%x]!!", result);
66 /* (3) get device type */
67 result = mm_sound_get_device_type(device_h, &device_type);
70 debug_error("mm_sound_get_device_type() failed [%x]!!", result);
76 if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
78 for ( i = 0; i < MM_AUDIO_EFFECT_PRESET_NUM; i++ )
80 if (player->ini.audio_effect_preset_list[i] )
82 if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
83 player->ini.audio_effect_preset_earphone_only_list[i])
87 if (!foreach_cb(effect_type,i, user_data))
95 else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
97 for ( i = 0; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++ )
99 if (player->ini.audio_effect_custom_list[i] )
101 if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
102 player->ini.audio_effect_custom_earphone_only_list[i])
106 if (!foreach_cb(effect_type,i, user_data))
115 debug_error("invalid effect type(%d)", effect_type);
116 result = MM_ERROR_INVALID_ARGUMENT;
124 debug_error("foreach callback returned error");
126 return MM_ERROR_PLAYER_INTERNAL;
131 __mmplayer_set_harmony_effect(mm_player_t *player, GstElement *audio_effect_element)
133 gint *ext_effect_level_list = NULL;
134 int count = 1; /* start from 1, because of excepting eq index */
135 int ext_level_index = 0;
136 int result = MM_ERROR_NONE;
140 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
141 return_val_if_fail ( audio_effect_element, MM_ERROR_INVALID_ARGUMENT );
144 if( player->ini.audio_effect_custom_eq_band_num )
146 debug_log("pass custom EQ level list to audio effect plugin");
147 /* set custom-equalizer level list */
148 g_object_set(audio_effect_element, "custom-eq", player->audio_effect_info.custom_eq_level, NULL);
152 debug_warning("no custom EQ");
155 /* Custom Extension effects */
156 if( player->ini.audio_effect_custom_ext_num )
158 debug_log("pass custom extension level list to audio effect plugin");
159 ext_effect_level_list = player->audio_effect_info.custom_ext_level_for_plugin;
160 if (!ext_effect_level_list) {
161 ext_effect_level_list = (gint*) malloc (sizeof(gint)*player->ini.audio_effect_custom_ext_num);
162 if (!ext_effect_level_list)
164 debug_error("memory allocation for extension effect list failed");
165 return MM_ERROR_OUT_OF_MEMORY;
169 memset (ext_effect_level_list, 0, player->ini.audio_effect_custom_ext_num);
171 /* associate it to player handle */
172 player->audio_effect_info.custom_ext_level_for_plugin = ext_effect_level_list;
176 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
178 if ( player->ini.audio_effect_custom_list[count] )
180 ext_effect_level_list[ext_level_index] = player->audio_effect_info.custom_ext_level[count-1];
182 if (ext_level_index == player->ini.audio_effect_custom_ext_num)
190 /* set custom-extension effects level list */
191 g_object_set(audio_effect_element, "custom-ext", ext_effect_level_list, NULL);
195 debug_warning("no custom extension effect");
198 /* order action to audio effect plugin */
199 g_object_set(audio_effect_element, "filter-action", MM_AUDIO_EFFECT_TYPE_CUSTOM, NULL);
200 debug_log("filter-action = %d", MM_AUDIO_EFFECT_TYPE_CUSTOM);
209 __mmplayer_is_earphone_only_effect_type(mm_player_t *player, MMAudioEffectType effect_type, int effect)
211 gboolean result = FALSE;
216 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
219 if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
221 for (i = 1; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++) /* it starts from 1(except testing for EQ) */
223 if (player->ini.audio_effect_custom_earphone_only_list[i])
225 /* check if the earphone only custom effect was set */
226 if (player->audio_effect_info.custom_ext_level[i-1])
228 debug_msg("this custom effect(%d) is only available with earphone", i);
236 debug_error("invalid effect type(%d)", effect_type);
245 __mmplayer_audio_set_output_type (mm_player_t *player, MMAudioEffectType effect_type, int effect)
247 GstElement *audio_effect_element = NULL;
248 mm_sound_device_flags_e flags = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
249 MMSoundDeviceList_t device_list;
250 MMSoundDevice_t device_h = NULL;
251 mm_sound_device_type_e device_type;
253 int result = MM_ERROR_NONE;
257 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
259 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
261 /* (1) get current device list */
262 result = mm_sound_get_current_device_list(flags, &device_list);
265 debug_error("mm_sound_get_current_device_list() failed [%x]!!", result);
270 /* (2) get device handle of device list */
271 result = mm_sound_get_next_device (device_list, &device_h);
274 debug_error("mm_sound_get_next_device() failed [%x]!!", result);
279 /* (3) get device type */
280 result = mm_sound_get_device_type(device_h, &device_type);
283 debug_error("mm_sound_get_device_type() failed [%x]!!", result);
289 if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER)
291 if ( MM_AUDIO_EFFECT_TYPE_SQUARE != effect_type ) {
292 if (__mmplayer_is_earphone_only_effect_type(player, effect_type, effect))
294 debug_error("earphone is not equipped, this filter will not be applied");
296 return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
300 output_type = MM_AUDIO_EFFECT_OUTPUT_SPK;
302 else if (device_type == MM_SOUND_DEVICE_TYPE_MIRRORING)
304 output_type = MM_AUDIO_EFFECT_OUTPUT_OTHERS;
306 else if (device_type == MM_SOUND_DEVICE_TYPE_HDMI)
308 output_type = MM_AUDIO_EFFECT_OUTPUT_HDMI;
310 else if (device_type == MM_SOUND_DEVICE_TYPE_BLUETOOTH)
312 output_type = MM_AUDIO_EFFECT_OUTPUT_BT;
314 else if (device_type == MM_SOUND_DEVICE_TYPE_USB_AUDIO)
316 output_type = MM_AUDIO_EFFECT_OUTPUT_USB_AUDIO;
318 /* Other case, include WIRED_ACCESSORY */
321 output_type = MM_AUDIO_EFFECT_OUTPUT_EAR;
323 debug_warning("output_type = %d (0:spk,1:ear,2:others)", output_type);
325 /* set filter output mode */
326 g_object_set(audio_effect_element, "filter-output-mode", output_type, NULL);
332 _mmplayer_is_supported_effect_type(mm_player_t* player, MMAudioEffectType effect_type, int effect)
334 gboolean result = TRUE;
335 mm_sound_device_flags_e flags = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
336 MMSoundDeviceList_t device_list;
337 MMSoundDevice_t device_h = NULL;
338 mm_sound_device_type_e device_type;
339 int ret = MM_ERROR_NONE;
343 /* get status if speaker is activated */
344 /* (1) get current device list */
345 ret = mm_sound_get_current_device_list(flags, &device_list);
348 debug_error("mm_sound_get_current_device_list() failed [%x]!!", ret);
352 /* (2) get device handle of device list */
353 ret = mm_sound_get_next_device (device_list, &device_h);
356 debug_error("mm_sound_get_next_device() failed [%x]!!", ret);
361 /* (3) get device type */
362 ret = mm_sound_get_device_type(device_h, &device_type);
365 debug_error("mm_sound_get_device_type() failed [%x]!!", ret);
371 if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
373 if ( effect < MM_AUDIO_EFFECT_PRESET_AUTO || effect >= MM_AUDIO_EFFECT_PRESET_NUM )
375 debug_error("out of range, preset effect(%d)", effect);
380 if (!player->ini.audio_effect_preset_list[effect])
382 debug_error("this effect(%d) is not supported", effect);
387 if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
388 player->ini.audio_effect_preset_earphone_only_list[effect])
396 else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
398 if ( effect < MM_AUDIO_EFFECT_CUSTOM_EQ || effect >= MM_AUDIO_EFFECT_CUSTOM_NUM )
400 debug_error("out of range, custom effect(%d)", effect);
405 if (!player->ini.audio_effect_custom_list[effect])
407 debug_error("this custom effect(%d) is not supported", effect);
412 if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
413 player->ini.audio_effect_custom_earphone_only_list[effect])
419 else if (effect_type == MM_AUDIO_EFFECT_TYPE_SQUARE)
421 if (!player->ini.use_audio_effect_custom)
423 debug_error("Square effect is not supported");
429 debug_error("invalid effect type(%d)", effect_type);
440 _mmplayer_audio_effect_custom_apply(mm_player_t *player)
442 GstElement *audio_effect_element = NULL;
443 int result = MM_ERROR_NONE;
447 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
449 /* Music Player can set audio effect value before Audiobin is created. */
450 if ( !player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst )
452 debug_warning("effect element is not created yet.");
454 player->bypass_audio_effect = FALSE;
456 /* store audio effect setting in order to apply it when audio effect plugin is created */
457 player->audio_effect_info.effect_type = MM_AUDIO_EFFECT_TYPE_CUSTOM;
461 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
463 /* get status if speaker is activated */
464 result = __mmplayer_audio_set_output_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, 0);
466 if ( result != MM_ERROR_NONE) {
467 debug_error("failed to set output mode");
472 result = __mmplayer_set_harmony_effect(player, audio_effect_element);
475 debug_error("_set_harmony_effect() failed(%x)", result);
480 player->set_mode.rich_audio = TRUE;
488 _mmplayer_audio_effect_custom_update_level(mm_player_t *player)
490 GstElement *audio_effect_element = NULL;
491 int result = MM_ERROR_NONE;
492 int ext_level_index = 0;
495 gint *custom_eq = NULL;
496 gint *custom_ext_effect_level_list = NULL;
500 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
502 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
504 /* get custom eq effect */
505 g_object_get(audio_effect_element, "custom-eq", &custom_eq, NULL);
507 memcpy(player->audio_effect_info.custom_eq_level, custom_eq, sizeof(gint) * player->ini.audio_effect_custom_eq_band_num);
509 for (i=0; i<player->ini.audio_effect_custom_eq_band_num;i++)
511 debug_log("updated custom-eq [%d] = %d", i, player->audio_effect_info.custom_eq_level[i]);
514 /* get custom ext effect */
516 g_object_get(audio_effect_element, "custom-ext", &custom_ext_effect_level_list, NULL);
518 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
520 if ( player->ini.audio_effect_custom_list[count] )
522 player->audio_effect_info.custom_ext_level[count-1]
523 = custom_ext_effect_level_list[ext_level_index];
524 debug_log("updated custom-ext [%d] = %d", count, player->audio_effect_info.custom_ext_level[count-1]);
537 mm_player_audio_effect_custom_clear_eq_all(MMHandleType hplayer)
539 int result = MM_ERROR_NONE;
540 mm_player_t* player = (mm_player_t*)hplayer;
544 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
546 /* clear EQ custom effect */
547 memset(player->audio_effect_info.custom_eq_level, MM_AUDIO_EFFECT_CUSTOM_LEVEL_INIT, sizeof(int)*MM_AUDIO_EFFECT_EQ_BAND_NUM_MAX);
549 debug_msg("All the EQ bands clearing success");
557 mm_player_is_supported_custom_effect_type(MMHandleType hplayer, MMAudioEffectCustomType effect)
559 mm_player_t* player = (mm_player_t*)hplayer;
560 int result = MM_ERROR_NONE;
564 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
566 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect ) )
568 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
577 mm_player_audio_effect_custom_apply(MMHandleType hplayer)
579 mm_player_t* player = (mm_player_t*)hplayer;
580 int result = MM_ERROR_NONE;
584 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
586 if (!player->ini.use_audio_effect_custom)
588 debug_error("audio effect(custom) is not supported");
590 return MM_ERROR_NOT_SUPPORT_API;
593 result = _mmplayer_audio_effect_custom_apply(player);
601 _mmplayer_audio_effect_custom_set_level_ext(mm_player_t *player, MMAudioEffectCustomType custom_effect_type, int level)
603 int effect_level_max = 0;
604 int effect_level_min = 0;
605 int count = 1; /* start from 1, because of excepting eq index */
606 int ext_level_index = 1; /* start from 1, because of excepting eq index */
607 int result = MM_ERROR_NONE;
611 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
613 /* check if EQ is supported */
614 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, custom_effect_type ) )
617 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
620 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
622 if ( player->ini.audio_effect_custom_list[count] )
624 if ( count == custom_effect_type )
626 effect_level_min = player->ini.audio_effect_custom_min_level_list[ext_level_index];
627 effect_level_max = player->ini.audio_effect_custom_max_level_list[ext_level_index];
628 debug_msg("level min value(%d), level max value(%d)", effect_level_min, effect_level_max);
632 if (ext_level_index == player->ini.audio_effect_custom_ext_num + 1)
634 debug_error("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin");
641 if ( level < effect_level_min || level > effect_level_max )
643 debug_error("out of range, level(%d)", level);
644 result = MM_ERROR_INVALID_ARGUMENT;
648 player->audio_effect_info.custom_ext_level[custom_effect_type-1] = level;
649 debug_msg("set ext[%d] = %d", custom_effect_type-1, level);
659 _mmplayer_audio_effect_custom_set_level_eq(mm_player_t *player, int index, int level)
661 gint eq_level_max = 0;
662 gint eq_level_min = 0;
663 int result = MM_ERROR_NONE;
667 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
669 /* check if EQ is supported */
670 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
673 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
676 if ( index < 0 || index > player->ini.audio_effect_custom_eq_band_num - 1 )
678 debug_error("out of range, index(%d)", index);
679 result = MM_ERROR_INVALID_ARGUMENT;
683 eq_level_min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
684 eq_level_max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
685 debug_msg("EQ level min value(%d), EQ level max value(%d)", eq_level_min, eq_level_max);
687 if ( level < eq_level_min || level > eq_level_max )
689 debug_error("out of range, EQ level(%d)", level);
690 result = MM_ERROR_INVALID_ARGUMENT;
694 player->audio_effect_info.custom_eq_level[index] = level;
695 debug_msg("set EQ[%d] = %d", index, level);
705 /* NOTE : parameter eq_index is only used for _set_eq_level() */
707 mm_player_audio_effect_custom_set_level(MMHandleType hplayer, MMAudioEffectCustomType effect_custom_type, int eq_index, int level)
709 mm_player_t* player = (mm_player_t*)hplayer;
710 int result = MM_ERROR_NONE;
714 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
716 /* check if this effect type is supported */
717 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect_custom_type ) )
719 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
723 if (effect_custom_type == MM_AUDIO_EFFECT_CUSTOM_EQ)
725 result = _mmplayer_audio_effect_custom_set_level_eq(player, eq_index, level);
727 else if (effect_custom_type > MM_AUDIO_EFFECT_CUSTOM_EQ && effect_custom_type < MM_AUDIO_EFFECT_CUSTOM_NUM)
729 result = _mmplayer_audio_effect_custom_set_level_ext(player, effect_custom_type, level);
733 debug_error("out of range, effect type(%d)", effect_custom_type);
734 result = MM_ERROR_INVALID_ARGUMENT;
745 mm_player_audio_effect_custom_get_eq_bands_number(MMHandleType hplayer, int *bands)
747 mm_player_t* player = (mm_player_t*)hplayer;
748 int result = MM_ERROR_NONE;
752 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
754 /* check if EQ is supported */
755 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
758 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
761 *bands = player->ini.audio_effect_custom_eq_band_num;
762 debug_log("number of custom EQ band = %d", *bands);
771 mm_player_audio_effect_custom_get_eq_bands_width(MMHandleType hplayer, int band_idx, int *width)
773 mm_player_t* player = (mm_player_t*)hplayer;
774 int result = MM_ERROR_NONE;
775 unsigned int eq_num = 0;
779 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
781 /* check if EQ is supported */
782 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
785 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
788 eq_num = player->ini.audio_effect_custom_eq_band_num;
789 if (band_idx < 0 || band_idx > eq_num-1)
791 debug_error("out of range, invalid band_idx(%d)", band_idx);
792 result = MM_ERROR_INVALID_ARGUMENT;
796 /* set the width of EQ band */
797 *width = player->ini.audio_effect_custom_eq_band_width[band_idx];
798 debug_log("width of band_idx(%d) = %dHz", band_idx, *width);
808 mm_player_audio_effect_custom_get_eq_bands_freq(MMHandleType hplayer, int band_idx, int *freq)
810 mm_player_t* player = (mm_player_t*)hplayer;
811 int result = MM_ERROR_NONE;
812 unsigned int eq_num = 0;
816 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
818 /* check if EQ is supported */
819 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
822 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
825 eq_num = player->ini.audio_effect_custom_eq_band_num;
826 if (band_idx < 0 || band_idx > eq_num-1)
828 debug_error("out of range, invalid band_idx(%d)", band_idx);
829 result = MM_ERROR_INVALID_ARGUMENT;
833 /* set the frequency of EQ band */
834 *freq = player->ini.audio_effect_custom_eq_band_freq[band_idx];
835 debug_log("frequency of band_idx(%d) = %dHz", band_idx, *freq);
845 mm_player_audio_effect_custom_get_level(MMHandleType hplayer, MMAudioEffectCustomType type, int eq_index, int *level)
847 mm_player_t* player = (mm_player_t*)hplayer;
848 int result = MM_ERROR_NONE;
852 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
853 return_val_if_fail( level, MM_ERROR_PLAYER_NOT_INITIALIZED );
855 /* check if this effect type is supported */
856 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) )
859 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
862 if (type == MM_AUDIO_EFFECT_CUSTOM_EQ)
864 if ( eq_index < 0 || eq_index > player->ini.audio_effect_custom_eq_band_num - 1 )
866 debug_error("out of range, EQ index(%d)", eq_index);
867 result = MM_ERROR_INVALID_ARGUMENT;
871 *level = player->audio_effect_info.custom_eq_level[eq_index];
872 debug_log("EQ index = %d, level = %d", eq_index, *level);
875 else if ( type > MM_AUDIO_EFFECT_CUSTOM_EQ && type < MM_AUDIO_EFFECT_CUSTOM_NUM )
877 *level = player->audio_effect_info.custom_ext_level[type-1];
878 debug_log("extension effect index = %d, level = %d", type, *level);
882 debug_error("out of range, type(%d)", type);
883 result = MM_ERROR_INVALID_ARGUMENT;
893 mm_player_audio_effect_custom_get_level_range(MMHandleType hplayer, MMAudioEffectCustomType type, int *min, int *max)
895 mm_player_t* player = (mm_player_t*)hplayer;
896 int result = MM_ERROR_NONE;
897 int count = 1; /* start from 1, because of excepting eq index */
898 int ext_level_index = 1; /* start from 1, because of excepting eq index */
902 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
903 return_val_if_fail( min, MM_ERROR_PLAYER_NOT_INITIALIZED );
904 return_val_if_fail( max, MM_ERROR_PLAYER_NOT_INITIALIZED );
906 /* check if this effect type is supported */
907 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) )
910 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
913 if ( type == MM_AUDIO_EFFECT_CUSTOM_EQ )
915 *min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
916 *max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
917 debug_log("EQ min level = %d, max level = %d", *min, *max);
921 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
923 if ( player->ini.audio_effect_custom_list[count] )
927 *min = player->ini.audio_effect_custom_min_level_list[ext_level_index];
928 *max = player->ini.audio_effect_custom_max_level_list[ext_level_index];
929 debug_msg("Extension effect(%d) min level = %d, max level = %d", count, *min, *max);
933 if ( ext_level_index == player->ini.audio_effect_custom_ext_num + 1 )
935 debug_error("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin");
950 mm_player_audio_effect_custom_set_level_eq_from_list(MMHandleType hplayer, int *level_list, int size)
952 mm_player_t *player = (mm_player_t*)hplayer;
954 gint eq_level_min = 0;
955 gint eq_level_max = 0;
956 int result = MM_ERROR_NONE;
960 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
962 /* check if EQ is supported */
963 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
966 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
969 if ( size != player->ini.audio_effect_custom_eq_band_num )
971 debug_error("input size variable(%d) does not match with number of eq band(%d)", size, player->ini.audio_effect_custom_eq_band_num);
972 result = MM_ERROR_INVALID_ARGUMENT;
976 eq_level_min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
977 eq_level_max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
979 for ( i = 0 ; i < size ; i++ )
981 if ( level_list[i] < eq_level_min || level_list[i] > eq_level_max)
983 debug_error("out of range, level[%d]=%d", i, level_list[i]);
984 result = MM_ERROR_INVALID_ARGUMENT;
987 player->audio_effect_info.custom_eq_level[i] = level_list[i];