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_PRESET)
221 if (player->ini.audio_effect_preset_earphone_only_list[effect])
223 debug_msg("this preset effect(%d) is only available with earphone", effect);
228 else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
230 for (i = 1; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++) /* it starts from 1(except testing for EQ) */
232 if (player->ini.audio_effect_custom_earphone_only_list[i])
234 /* check if the earphone only custom effect was set */
235 if (player->audio_effect_info.custom_ext_level[i-1])
237 debug_msg("this custom effect(%d) is only available with earphone", i);
245 debug_error("invalid effect type(%d)", effect_type);
254 __mmplayer_audio_set_output_type (mm_player_t *player, MMAudioEffectType effect_type, int effect)
256 GstElement *audio_effect_element = NULL;
257 mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
258 MMSoundDeviceList_t device_list;
259 MMSoundDevice_t device_h = NULL;
260 mm_sound_device_type_e device_type;
262 int result = MM_ERROR_NONE;
266 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
268 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
270 /* (1) get current device list */
271 result = mm_sound_get_current_device_list(flags, &device_list);
274 debug_error("mm_sound_get_current_device_list() failed [%x]!!", result);
279 /* (2) get device handle of device list */
280 result = mm_sound_get_next_device (device_list, &device_h);
283 debug_error("mm_sound_get_next_device() failed [%x]!!", result);
288 /* (3) get device type */
289 result = mm_sound_get_device_type(device_h, &device_type);
292 debug_error("mm_sound_get_device_type() failed [%x]!!", result);
298 if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER)
300 if ( MM_AUDIO_EFFECT_TYPE_SQUARE != effect_type ) {
301 if (__mmplayer_is_earphone_only_effect_type(player, effect_type, effect))
303 debug_error("earphone is not equipped, this filter will not be applied");
305 return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
309 output_type = MM_AUDIO_EFFECT_OUTPUT_SPK;
311 else if (device_type == MM_SOUND_DEVICE_TYPE_MIRRORING)
313 output_type = MM_AUDIO_EFFECT_OUTPUT_OTHERS;
315 else if (device_type == MM_SOUND_DEVICE_TYPE_HDMI)
317 output_type = MM_AUDIO_EFFECT_OUTPUT_HDMI;
319 else if (device_type == MM_SOUND_DEVICE_TYPE_BLUETOOTH)
321 output_type = MM_AUDIO_EFFECT_OUTPUT_BT;
323 else if (device_type == MM_SOUND_DEVICE_TYPE_USB_AUDIO)
325 output_type = MM_AUDIO_EFFECT_OUTPUT_USB_AUDIO;
327 /* Other case, include WIRED_ACCESSORY */
330 output_type = MM_AUDIO_EFFECT_OUTPUT_EAR;
332 debug_warning("output_type = %d (0:spk,1:ear,2:others)", output_type);
334 /* set filter output mode */
335 g_object_set(audio_effect_element, "filter-output-mode", output_type, NULL);
341 _mmplayer_is_supported_effect_type(mm_player_t* player, MMAudioEffectType effect_type, int effect)
343 gboolean result = TRUE;
344 mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
345 MMSoundDeviceList_t device_list;
346 MMSoundDevice_t device_h = NULL;
347 mm_sound_device_type_e device_type;
348 int ret = MM_ERROR_NONE;
352 /* get status if speaker is activated */
353 /* (1) get current device list */
354 ret = mm_sound_get_current_device_list(flags, &device_list);
357 debug_error("mm_sound_get_current_device_list() failed [%x]!!", ret);
361 /* (2) get device handle of device list */
362 ret = mm_sound_get_next_device (device_list, &device_h);
365 debug_error("mm_sound_get_next_device() failed [%x]!!", ret);
370 /* (3) get device type */
371 ret = mm_sound_get_device_type(device_h, &device_type);
374 debug_error("mm_sound_get_device_type() failed [%x]!!", ret);
380 if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
382 if ( effect < MM_AUDIO_EFFECT_PRESET_AUTO || effect >= MM_AUDIO_EFFECT_PRESET_NUM )
384 debug_error("out of range, preset effect(%d)", effect);
389 if (!player->ini.audio_effect_preset_list[effect])
391 debug_error("this effect(%d) is not supported", effect);
396 if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
397 player->ini.audio_effect_preset_earphone_only_list[effect])
405 else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
407 if ( effect < MM_AUDIO_EFFECT_CUSTOM_EQ || effect >= MM_AUDIO_EFFECT_CUSTOM_NUM )
409 debug_error("out of range, custom effect(%d)", effect);
414 if (!player->ini.audio_effect_custom_list[effect])
416 debug_error("this custom effect(%d) is not supported", effect);
421 if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
422 player->ini.audio_effect_custom_earphone_only_list[effect])
429 else if (effect_type == MM_AUDIO_EFFECT_TYPE_SQUARE)
431 if (!player->ini.use_audio_effect_custom)
433 debug_error("Square effect is not supported");
439 debug_error("invalid effect type(%d)", effect_type);
450 _mmplayer_audio_effect_custom_apply(mm_player_t *player)
452 GstElement *audio_effect_element = NULL;
453 int result = MM_ERROR_NONE;
457 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
459 /* Music Player can set audio effect value before Audiobin is created. */
460 if ( !player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst )
462 debug_warning("effect element is not created yet.");
464 player->bypass_audio_effect = FALSE;
466 /* store audio effect setting in order to apply it when audio effect plugin is created */
467 player->audio_effect_info.effect_type = MM_AUDIO_EFFECT_TYPE_CUSTOM;
471 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
473 /* get status if speaker is activated */
474 result = __mmplayer_audio_set_output_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, 0);
476 if ( result != MM_ERROR_NONE) {
477 debug_error("failed to set output mode");
482 result = __mmplayer_set_harmony_effect(player, audio_effect_element);
485 debug_error("_set_harmony_effect() failed(%x)", result);
490 player->set_mode.rich_audio = TRUE;
498 _mmplayer_audio_effect_custom_update_level(mm_player_t *player)
500 GstElement *audio_effect_element = NULL;
501 int result = MM_ERROR_NONE;
502 int ext_level_index = 0;
505 gint *custom_eq = NULL;
506 gint *custom_ext_effect_level_list = NULL;
510 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
512 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
514 /* get custom eq effect */
515 g_object_get(audio_effect_element, "custom-eq", &custom_eq, NULL);
517 memcpy(player->audio_effect_info.custom_eq_level, custom_eq, sizeof(gint) * player->ini.audio_effect_custom_eq_band_num);
519 for (i=0; i<player->ini.audio_effect_custom_eq_band_num;i++)
521 debug_log("updated custom-eq [%d] = %d", i, player->audio_effect_info.custom_eq_level[i]);
524 /* get custom ext effect */
526 g_object_get(audio_effect_element, "custom-ext", &custom_ext_effect_level_list, NULL);
528 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
530 if ( player->ini.audio_effect_custom_list[count] )
532 player->audio_effect_info.custom_ext_level[count-1]
533 = custom_ext_effect_level_list[ext_level_index];
534 debug_log("updated custom-ext [%d] = %d", count, player->audio_effect_info.custom_ext_level[count-1]);
547 mm_player_audio_effect_custom_clear_eq_all(MMHandleType hplayer)
549 int result = MM_ERROR_NONE;
550 mm_player_t* player = (mm_player_t*)hplayer;
554 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
556 /* clear EQ custom effect */
557 memset(player->audio_effect_info.custom_eq_level, MM_AUDIO_EFFECT_CUSTOM_LEVEL_INIT, sizeof(int)*MM_AUDIO_EFFECT_EQ_BAND_NUM_MAX);
559 debug_msg("All the EQ bands clearing success");
568 mm_player_audio_effect_custom_clear_ext_all(MMHandleType hplayer)
571 int result = MM_ERROR_NONE;
572 mm_player_t* player = (mm_player_t*)hplayer;
576 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
578 /* clear ALL custom effects, except EQ */
579 for ( i = 0 ; i < MM_AUDIO_EFFECT_CUSTOM_NUM - 1 ; i++ )
581 player->audio_effect_info.custom_ext_level[i] = MM_AUDIO_EFFECT_CUSTOM_LEVEL_INIT;
584 debug_msg("All the extension effects clearing success");
593 mm_player_is_supported_preset_effect_type(MMHandleType hplayer, MMAudioEffectPresetType effect)
595 mm_player_t* player = (mm_player_t*)hplayer;
596 int result = MM_ERROR_NONE;
600 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
602 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_PRESET, effect ) )
604 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
614 mm_player_is_supported_custom_effect_type(MMHandleType hplayer, MMAudioEffectCustomType effect)
616 mm_player_t* player = (mm_player_t*)hplayer;
617 int result = MM_ERROR_NONE;
621 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
623 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect ) )
625 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
634 mm_player_audio_effect_custom_apply(MMHandleType hplayer)
636 mm_player_t* player = (mm_player_t*)hplayer;
637 int result = MM_ERROR_NONE;
641 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
643 if (!player->ini.use_audio_effect_custom)
645 debug_error("audio effect(custom) is not supported");
647 return MM_ERROR_NOT_SUPPORT_API;
650 result = _mmplayer_audio_effect_custom_apply(player);
659 mm_player_audio_effect_bypass (MMHandleType hplayer)
661 mm_player_t* player = (mm_player_t*)hplayer;
662 int result = MM_ERROR_NONE;
663 GstElement *audio_effect_element = NULL;
667 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
669 if ( !player->ini.use_audio_effect_preset && !player->ini.use_audio_effect_custom )
671 debug_error("audio effect(preset/custom) is not supported");
673 return MM_ERROR_NOT_SUPPORT_API;
675 if ( !player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst )
677 debug_warning("effect element is not created yet.");
681 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
683 /* order action to audio effect plugin */
684 g_object_set(audio_effect_element, "filter-action", MM_AUDIO_EFFECT_TYPE_NONE, NULL);
685 debug_log("filter-action = %d", MM_AUDIO_EFFECT_TYPE_NONE);
695 _mmplayer_audio_effect_custom_set_level_ext(mm_player_t *player, MMAudioEffectCustomType custom_effect_type, int level)
697 int effect_level_max = 0;
698 int effect_level_min = 0;
699 int count = 1; /* start from 1, because of excepting eq index */
700 int ext_level_index = 1; /* start from 1, because of excepting eq index */
701 int result = MM_ERROR_NONE;
705 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
707 /* check if EQ is supported */
708 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, custom_effect_type ) )
711 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
714 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
716 if ( player->ini.audio_effect_custom_list[count] )
718 if ( count == custom_effect_type )
720 effect_level_min = player->ini.audio_effect_custom_min_level_list[ext_level_index];
721 effect_level_max = player->ini.audio_effect_custom_max_level_list[ext_level_index];
722 debug_msg("level min value(%d), level max value(%d)", effect_level_min, effect_level_max);
726 if (ext_level_index == player->ini.audio_effect_custom_ext_num + 1)
728 debug_error("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin");
735 if ( level < effect_level_min || level > effect_level_max )
737 debug_error("out of range, level(%d)", level);
738 result = MM_ERROR_INVALID_ARGUMENT;
742 player->audio_effect_info.custom_ext_level[custom_effect_type-1] = level;
743 debug_msg("set ext[%d] = %d", custom_effect_type-1, level);
753 _mmplayer_audio_effect_custom_set_level_eq(mm_player_t *player, int index, int level)
755 gint eq_level_max = 0;
756 gint eq_level_min = 0;
757 int result = MM_ERROR_NONE;
761 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
763 /* check if EQ is supported */
764 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
767 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
770 if ( index < 0 || index > player->ini.audio_effect_custom_eq_band_num - 1 )
772 debug_error("out of range, index(%d)", index);
773 result = MM_ERROR_INVALID_ARGUMENT;
777 eq_level_min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
778 eq_level_max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
779 debug_msg("EQ level min value(%d), EQ level max value(%d)", eq_level_min, eq_level_max);
781 if ( level < eq_level_min || level > eq_level_max )
783 debug_error("out of range, EQ level(%d)", level);
784 result = MM_ERROR_INVALID_ARGUMENT;
788 player->audio_effect_info.custom_eq_level[index] = level;
789 debug_msg("set EQ[%d] = %d", index, level);
799 /* NOTE : parameter eq_index is only used for _set_eq_level() */
801 mm_player_audio_effect_custom_set_level(MMHandleType hplayer, MMAudioEffectCustomType effect_custom_type, int eq_index, int level)
803 mm_player_t* player = (mm_player_t*)hplayer;
804 int result = MM_ERROR_NONE;
808 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
810 /* check if this effect type is supported */
811 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect_custom_type ) )
813 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
817 if (effect_custom_type == MM_AUDIO_EFFECT_CUSTOM_EQ)
819 result = _mmplayer_audio_effect_custom_set_level_eq(player, eq_index, level);
821 else if (effect_custom_type > MM_AUDIO_EFFECT_CUSTOM_EQ && effect_custom_type < MM_AUDIO_EFFECT_CUSTOM_NUM)
823 result = _mmplayer_audio_effect_custom_set_level_ext(player, effect_custom_type, level);
827 debug_error("out of range, effect type(%d)", effect_custom_type);
828 result = MM_ERROR_INVALID_ARGUMENT;
839 mm_player_audio_effect_custom_get_eq_bands_number(MMHandleType hplayer, int *bands)
841 mm_player_t* player = (mm_player_t*)hplayer;
842 int result = MM_ERROR_NONE;
846 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
848 /* check if EQ is supported */
849 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
852 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
855 *bands = player->ini.audio_effect_custom_eq_band_num;
856 debug_log("number of custom EQ band = %d", *bands);
865 mm_player_audio_effect_custom_get_eq_bands_width(MMHandleType hplayer, int band_idx, int *width)
867 mm_player_t* player = (mm_player_t*)hplayer;
868 int result = MM_ERROR_NONE;
869 unsigned int eq_num = 0;
873 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
875 /* check if EQ is supported */
876 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
879 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
882 eq_num = player->ini.audio_effect_custom_eq_band_num;
883 if (band_idx < 0 || band_idx > eq_num-1)
885 debug_error("out of range, invalid band_idx(%d)", band_idx);
886 result = MM_ERROR_INVALID_ARGUMENT;
890 /* set the width of EQ band */
891 *width = player->ini.audio_effect_custom_eq_band_width[band_idx];
892 debug_log("width of band_idx(%d) = %dHz", band_idx, *width);
902 mm_player_audio_effect_custom_get_eq_bands_freq(MMHandleType hplayer, int band_idx, int *freq)
904 mm_player_t* player = (mm_player_t*)hplayer;
905 int result = MM_ERROR_NONE;
906 unsigned int eq_num = 0;
910 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
912 /* check if EQ is supported */
913 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
916 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
919 eq_num = player->ini.audio_effect_custom_eq_band_num;
920 if (band_idx < 0 || band_idx > eq_num-1)
922 debug_error("out of range, invalid band_idx(%d)", band_idx);
923 result = MM_ERROR_INVALID_ARGUMENT;
927 /* set the frequency of EQ band */
928 *freq = player->ini.audio_effect_custom_eq_band_freq[band_idx];
929 debug_log("frequency of band_idx(%d) = %dHz", band_idx, *freq);
939 mm_player_audio_effect_custom_get_level(MMHandleType hplayer, MMAudioEffectCustomType type, int eq_index, int *level)
941 mm_player_t* player = (mm_player_t*)hplayer;
942 int result = MM_ERROR_NONE;
946 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
947 return_val_if_fail( level, MM_ERROR_PLAYER_NOT_INITIALIZED );
949 /* check if this effect type is supported */
950 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) )
953 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
956 if (type == MM_AUDIO_EFFECT_CUSTOM_EQ)
958 if ( eq_index < 0 || eq_index > player->ini.audio_effect_custom_eq_band_num - 1 )
960 debug_error("out of range, EQ index(%d)", eq_index);
961 result = MM_ERROR_INVALID_ARGUMENT;
965 *level = player->audio_effect_info.custom_eq_level[eq_index];
966 debug_log("EQ index = %d, level = %d", eq_index, *level);
969 else if ( type > MM_AUDIO_EFFECT_CUSTOM_EQ && type < MM_AUDIO_EFFECT_CUSTOM_NUM )
971 *level = player->audio_effect_info.custom_ext_level[type-1];
972 debug_log("extension effect index = %d, level = %d", type, *level);
976 debug_error("out of range, type(%d)", type);
977 result = MM_ERROR_INVALID_ARGUMENT;
987 mm_player_audio_effect_custom_get_level_range(MMHandleType hplayer, MMAudioEffectCustomType type, int *min, int *max)
989 mm_player_t* player = (mm_player_t*)hplayer;
990 int result = MM_ERROR_NONE;
991 int count = 1; /* start from 1, because of excepting eq index */
992 int ext_level_index = 1; /* start from 1, because of excepting eq index */
996 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
997 return_val_if_fail( min, MM_ERROR_PLAYER_NOT_INITIALIZED );
998 return_val_if_fail( max, MM_ERROR_PLAYER_NOT_INITIALIZED );
1000 /* check if this effect type is supported */
1001 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) )
1004 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
1007 if ( type == MM_AUDIO_EFFECT_CUSTOM_EQ )
1009 *min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
1010 *max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
1011 debug_log("EQ min level = %d, max level = %d", *min, *max);
1015 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
1017 if ( player->ini.audio_effect_custom_list[count] )
1019 if ( count == type )
1021 *min = player->ini.audio_effect_custom_min_level_list[ext_level_index];
1022 *max = player->ini.audio_effect_custom_max_level_list[ext_level_index];
1023 debug_msg("Extension effect(%d) min level = %d, max level = %d", count, *min, *max);
1027 if ( ext_level_index == player->ini.audio_effect_custom_ext_num + 1 )
1029 debug_error("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin");
1044 mm_player_audio_effect_custom_set_level_eq_from_list(MMHandleType hplayer, int *level_list, int size)
1046 mm_player_t *player = (mm_player_t*)hplayer;
1048 gint eq_level_min = 0;
1049 gint eq_level_max = 0;
1050 int result = MM_ERROR_NONE;
1054 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
1056 /* check if EQ is supported */
1057 if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
1060 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
1063 if ( size != player->ini.audio_effect_custom_eq_band_num )
1065 debug_error("input size variable(%d) does not match with number of eq band(%d)", size, player->ini.audio_effect_custom_eq_band_num);
1066 result = MM_ERROR_INVALID_ARGUMENT;
1070 eq_level_min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
1071 eq_level_max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
1073 for ( i = 0 ; i < size ; i++ )
1075 if ( level_list[i] < eq_level_min || level_list[i] > eq_level_max)
1077 debug_error("out of range, level[%d]=%d", i, level_list[i]);
1078 result = MM_ERROR_INVALID_ARGUMENT;
1081 player->audio_effect_info.custom_eq_level[i] = level_list[i];