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_sndeffect.h"
24 #include "mm_player_ini.h"
25 #include "mm_player_priv.h"
30 mm_player_get_foreach_present_supported_filter_type(MMHandleType player, MMAudioFilterType filter_type, mmplayer_supported_sound_filter_cb foreach_cb, void *user_data)
33 int result = MM_ERROR_NONE;
34 gboolean is_earphone = NULL;
37 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
39 /* get status if earphone is activated */
40 result = mm_sound_is_route_available(MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY, &is_earphone);
42 debug_error("mm_sound_is_route_available() failed [%x]!!\n", result);
47 if (filter_type == MM_AUDIO_FILTER_TYPE_PRESET)
49 for ( i = 0; i < MM_AUDIO_FILTER_PRESET_NUM; i++ )
52 if (PLAYER_INI()->audio_filter_preset_list[i])
54 if (!foreach_cb(filter_type, i, user_data))
62 if (PLAYER_INI()->audio_filter_preset_list[i] && !PLAYER_INI()->audio_filter_preset_earphone_only_list[i])
64 if (!foreach_cb(filter_type, i, user_data))
74 else if (filter_type == MM_AUDIO_FILTER_TYPE_CUSTOM)
76 for ( i = 0; i < MM_AUDIO_FILTER_CUSTOM_NUM; i++ )
80 if (PLAYER_INI()->audio_filter_custom_list[i])
82 if (!foreach_cb(filter_type, i, user_data))
90 if (PLAYER_INI()->audio_filter_custom_list[i] && !PLAYER_INI()->audio_filter_custom_earphone_only_list[i])
92 if (!foreach_cb(filter_type,i, user_data))
102 debug_error("invalid filter type(%d)\n", filter_type);
103 result = MM_ERROR_INVALID_ARGUMENT;
109 debug_error("foreach cb returned error\n");
110 return MM_ERROR_PLAYER_INTERNAL;
115 __mmplayer_set_harmony_filter(mm_player_t *player, GstElement *filter_element)
118 gint *ext_filter_level_list = NULL;
119 int count = 1; /* start from 1, because of excepting eq index */
120 int ext_level_index = 0;
121 int result = MM_ERROR_NONE;
122 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
123 return_val_if_fail ( filter_element, MM_ERROR_INVALID_ARGUMENT );
126 if( PLAYER_INI()->audio_filter_custom_eq_num )
128 debug_log("pass custom EQ level list to sound effect plugin\n");
129 /* set custom-equalizer level list */
130 g_object_set(filter_element, "custom-eq", player->audio_filter_info.custom_eq_level, NULL);
134 debug_warning("no custom EQ\n");
137 /* Custom Extension filters */
138 if( PLAYER_INI()->audio_filter_custom_ext_num )
140 debug_log("pass custom extension level list to sound effect plugin\n");
141 ext_filter_level_list = player->audio_filter_info.custom_ext_level_for_plugin;
142 if (!ext_filter_level_list) {
143 ext_filter_level_list = (gint*) malloc (sizeof(gint)*PLAYER_INI()->audio_filter_custom_ext_num);
144 if (!ext_filter_level_list)
146 debug_error("memory allocation for extension filter list failed\n");
147 return MM_ERROR_OUT_OF_MEMORY;
151 memset (ext_filter_level_list, 0, PLAYER_INI()->audio_filter_custom_ext_num);
155 while ( count < MM_AUDIO_FILTER_CUSTOM_NUM )
157 if ( PLAYER_INI()->audio_filter_custom_list[count] )
159 ext_filter_level_list[ext_level_index] = player->audio_filter_info.custom_ext_level[count-1];
161 if (ext_level_index == PLAYER_INI()->audio_filter_custom_ext_num)
169 /* set custom-extension filters level list */
170 g_object_set(filter_element, "custom-ext", ext_filter_level_list, NULL);
174 debug_warning("no custom extension fliter\n");
177 /* order action to sound effect plugin */
178 g_object_set(filter_element, "filter-action", MM_AUDIO_FILTER_TYPE_CUSTOM, NULL);
179 debug_log("filter-action = %d\n", MM_AUDIO_FILTER_TYPE_CUSTOM);
188 __mmplayer_is_earphone_only_filter_type(mm_player_t *player, MMAudioFilterType filter_type, int filter)
190 gboolean result = FALSE;
194 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
197 if (filter_type == MM_AUDIO_FILTER_TYPE_PRESET)
199 if (PLAYER_INI()->audio_filter_preset_earphone_only_list[filter])
201 debug_msg("this preset filter(%d) is only available with earphone\n", filter);
206 else if (filter_type == MM_AUDIO_FILTER_TYPE_CUSTOM)
208 for (i = 1; i < MM_AUDIO_FILTER_CUSTOM_NUM; i++) /* it starts from 1(except testing for EQ) */
210 if (PLAYER_INI()->audio_filter_custom_earphone_only_list[i])
212 /* check if the earphone only custom filter was set */
213 if (player->audio_filter_info.custom_ext_level[i-1])
215 debug_msg("this custom filter(%d) is only available with earphone\n", i);
223 debug_error("invalid filter type(%d)\n", filter_type);
231 _mmplayer_is_supported_filter_type(MMAudioFilterType filter_type, int filter)
233 gboolean result = TRUE;
238 if (filter_type == MM_AUDIO_FILTER_TYPE_PRESET)
240 if ( filter < MM_AUDIO_FILTER_PRESET_AUTO || filter >= MM_AUDIO_FILTER_PRESET_NUM )
242 debug_error("out of range, preset filter(%d)\n", filter);
245 if (!PLAYER_INI()->audio_filter_preset_list[filter])
247 debug_error("this filter(%d) is not supported\n", filter);
252 else if (filter_type == MM_AUDIO_FILTER_TYPE_CUSTOM)
254 if ( filter < MM_AUDIO_FILTER_CUSTOM_EQ || filter >= MM_AUDIO_FILTER_CUSTOM_NUM )
256 debug_error("out of range, custom filter(%d)\n", filter);
259 if (!PLAYER_INI()->audio_filter_custom_list[filter])
261 debug_error("this custom filter(%d) is not supported\n", filter);
267 debug_error("invalid filter type(%d)\n", filter_type);
276 _mmplayer_sound_filter_preset_apply(mm_player_t *player, MMAudioFilterPresetType filter_type)
278 GstElement *filter_element = NULL;
279 int result = MM_ERROR_NONE;
281 bool is_earphone = FALSE;
284 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
286 /* Music Player can set sound effect value before Audiobin is created. */
287 if ( !player->pipeline || !player->pipeline->audiobin )
289 debug_warning("filter element is not created yet.\n");
291 player->bypass_sound_effect = FALSE;
293 /* store sound effect setting in order to apply it when audio filter is created */
294 player->audio_filter_info.filter_type = MM_AUDIO_FILTER_TYPE_PRESET;
295 player->audio_filter_info.preset = filter_type;
299 return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED );
301 filter_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
303 /* get status if earphone is activated */
304 result = mm_sound_is_route_available(MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY, &is_earphone);
306 debug_error("mm_sound_is_route_available() failed [%x]!!\n", result);
312 output_type = MM_AUDIO_FILTER_OUTPUT_EAR;
316 output_type = MM_AUDIO_FILTER_OUTPUT_SPK;
317 if (__mmplayer_is_earphone_only_filter_type(player, MM_AUDIO_FILTER_TYPE_PRESET, filter_type))
319 debug_error("earphone is not equipped, this filter will not be applied\n");
320 return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
324 /* set filter output mode as SPEAKER or EARPHONE */
325 g_object_set(filter_element, "filter-output-mode", output_type, NULL);
326 debug_log("filter-output-mode = %d (0:spk,1:ear)\n", output_type);
328 if (filter_type == MM_AUDIO_FILTER_PRESET_AUTO) {
329 /* TODO: Add codes about auto selecting preset mode according to ID3 tag */
330 /* set filter preset mode */
331 g_object_set(filter_element, "preset-mode", 0, NULL); /* forced set to 0(normal) temporarily */
332 debug_log("preset-mode = %d\n", filter_type);
335 /* set filter preset mode */
336 g_object_set(filter_element, "preset-mode", filter_type-1, NULL); /* filter_type-1, because of _PRESET_AUTO in MSL/CAPI which does not exist in soundAlive plugin */
337 debug_log("preset-mode = %d\n", filter_type);
340 /* order action to sound effect plugin */
341 g_object_set(filter_element, "filter-action", MM_AUDIO_FILTER_TYPE_PRESET, NULL);
342 debug_log("filter-action = %d\n", MM_AUDIO_FILTER_TYPE_PRESET);
352 _mmplayer_sound_filter_custom_apply(mm_player_t *player)
354 GstElement *filter_element = NULL;
355 int result = MM_ERROR_NONE;
359 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
361 /* Music Player can set sound effect value before Audiobin is created. */
362 if ( !player->pipeline || !player->pipeline->audiobin )
364 debug_warning("filter element is not created yet.\n");
366 player->bypass_sound_effect = FALSE;
368 /* store sound effect setting in order to apply it when audio filter is created */
369 player->audio_filter_info.filter_type = MM_AUDIO_FILTER_TYPE_CUSTOM;
374 bool is_earphone = FALSE;
375 return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED );
377 filter_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
379 /* get status if earphone is activated */
380 result = mm_sound_is_route_available(MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY, &is_earphone);
382 debug_error("mm_sound_is_route_available() failed [%x]!!\n", result);
388 output_type = MM_AUDIO_FILTER_OUTPUT_EAR;
392 output_type = MM_AUDIO_FILTER_OUTPUT_SPK;
393 if (__mmplayer_is_earphone_only_filter_type(player, MM_AUDIO_FILTER_TYPE_CUSTOM, NULL))
395 debug_error("earphone is not equipped, some custom filter should operate with earphone(%x)\n", result);
396 return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
400 /* set filter output mode as SPEAKER or EARPHONE */
401 g_object_set(filter_element, "filter-output-mode", output_type, NULL);
402 debug_log("filter output mode = %d(0:spk,1:ear)\n", output_type);
404 result = __mmplayer_set_harmony_filter(player, filter_element);
407 debug_error("_set_harmony_filter() failed(%x)\n", result);
418 mm_player_sound_filter_custom_clear_eq_all(MMHandleType hplayer)
420 int result = MM_ERROR_NONE;
421 mm_player_t* player = (mm_player_t*)hplayer;
424 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
426 /* clear EQ custom filter */
427 memset(player->audio_filter_info.custom_eq_level, MM_AUDIO_FILTER_CUSTOM_LEVEL_INIT, sizeof(int)*MM_AUDIO_FILTER_EQ_BAND_MAX);
429 debug_msg("All the EQ bands clearing success\n");
436 mm_player_sound_filter_custom_clear_ext_all(MMHandleType hplayer)
439 int result = MM_ERROR_NONE;
440 mm_player_t* player = (mm_player_t*)hplayer;
443 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
445 /* clear ALL custom filters, except EQ */
446 for ( i = 0 ; i < MM_AUDIO_FILTER_CUSTOM_NUM - 1 ; i++ )
448 player->audio_filter_info.custom_ext_level[i] = MM_AUDIO_FILTER_CUSTOM_LEVEL_INIT;
451 debug_msg("All the extension filters clearing success\n");
458 mm_player_is_supported_preset_filter_type(MMHandleType hplayer, MMAudioFilterPresetType filter)
460 mm_player_t* player = (mm_player_t*)hplayer;
461 int result = MM_ERROR_NONE;
464 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
466 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_PRESET, filter ) )
468 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
476 mm_player_is_supported_custom_filter_type(MMHandleType hplayer, MMAudioFilterCustomType filter)
478 mm_player_t* player = (mm_player_t*)hplayer;
479 int result = MM_ERROR_NONE;
482 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
484 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_CUSTOM, filter ) )
486 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
494 mm_player_sound_filter_preset_apply(MMHandleType hplayer, MMAudioFilterPresetType type)
496 mm_player_t* player = (mm_player_t*)hplayer;
497 int result = MM_ERROR_NONE;
500 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
502 if (!PLAYER_INI()->use_audio_filter_preset)
504 debug_error("sound filter(preset) is not suppported\n", type);
505 return MM_ERROR_NOT_SUPPORT_API;
508 if (type < MM_AUDIO_FILTER_PRESET_AUTO || type >= MM_AUDIO_FILTER_PRESET_NUM)
510 debug_error("out of range, type(%d)\n", type);
511 return MM_ERROR_INVALID_ARGUMENT;
514 /* check if this filter type is supported */
515 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_PRESET, type ) )
517 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
520 result = _mmplayer_sound_filter_preset_apply(player, type);
527 mm_player_sound_filter_custom_apply(MMHandleType hplayer)
529 mm_player_t* player = (mm_player_t*)hplayer;
530 int result = MM_ERROR_NONE;
533 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
535 if (!PLAYER_INI()->use_audio_filter_custom)
537 debug_error("sound filter(custom) is not suppported\n");
538 return MM_ERROR_NOT_SUPPORT_API;
541 result = _mmplayer_sound_filter_custom_apply(player);
548 mm_player_sound_filter_bypass (MMHandleType hplayer)
550 mm_player_t* player = (mm_player_t*)hplayer;
551 int result = MM_ERROR_NONE;
552 GstElement *filter_element = NULL;
555 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
557 if ( !PLAYER_INI()->use_audio_filter_preset && !PLAYER_INI()->use_audio_filter_custom )
559 debug_error("sound filter(preset/custom) is not suppported\n");
560 return MM_ERROR_NOT_SUPPORT_API;
562 if ( !player->pipeline || !player->pipeline->audiobin )
564 debug_warning("filter element is not created yet.\n");
568 return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED );
569 filter_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
571 /* order action to sound effect plugin */
572 g_object_set(filter_element, "filter-action", MM_AUDIO_FILTER_TYPE_NONE, NULL);
573 debug_log("filter-action = %d\n", MM_AUDIO_FILTER_TYPE_NONE);
582 _mmplayer_sound_filter_custom_set_level_ext(mm_player_t *player, MMAudioFilterCustomType custom_filter_type, int level)
584 int filter_level_max = 0;
585 int filter_level_min = 0;
586 int count = 1; /* start from 1, because of excepting eq index */
587 int ext_level_index = 1; /* start from 1, because of excepting eq index */
588 int result = MM_ERROR_NONE;
592 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
594 /* check if EQ is supported */
595 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_CUSTOM, custom_filter_type ) )
597 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
600 while ( count < MM_AUDIO_FILTER_CUSTOM_NUM )
602 if ( PLAYER_INI()->audio_filter_custom_list[count] )
604 if ( count == custom_filter_type )
606 filter_level_min = PLAYER_INI()->audio_filter_custom_min_level_list[ext_level_index];
607 filter_level_max = PLAYER_INI()->audio_filter_custom_max_level_list[ext_level_index];
608 debug_msg("level min value(%d), level max value(%d)\n", filter_level_min, filter_level_max);
612 if (ext_level_index == PLAYER_INI()->audio_filter_custom_ext_num + 1)
614 debug_error("could not find min, max value. maybe filter information in ini file is not proper for sound effect plugin\n");
621 if ( level < filter_level_min || level > filter_level_max )
623 debug_error("out of range, level(%d)\n", level);
624 result = MM_ERROR_INVALID_ARGUMENT;
628 player->audio_filter_info.custom_ext_level[custom_filter_type-1] = level;
629 debug_msg("set ext[%d] = %d\n", custom_filter_type-1, level);
638 _mmplayer_sound_filter_custom_set_level_eq(mm_player_t *player, int index, int level)
640 gint eq_level_max = 0;
641 gint eq_level_min = 0;
642 int result = MM_ERROR_NONE;
645 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
647 /* check if EQ is supported */
648 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_CUSTOM, MM_AUDIO_FILTER_CUSTOM_EQ ) )
650 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
653 if ( index < 0 || index > PLAYER_INI()->audio_filter_custom_eq_num - 1 )
655 debug_error("out of range, index(%d)\n", index);
656 result = MM_ERROR_INVALID_ARGUMENT;
660 eq_level_min = PLAYER_INI()->audio_filter_custom_min_level_list[MM_AUDIO_FILTER_CUSTOM_EQ];
661 eq_level_max = PLAYER_INI()->audio_filter_custom_max_level_list[MM_AUDIO_FILTER_CUSTOM_EQ];
662 debug_msg("EQ level min value(%d), EQ level max value(%d)\n", eq_level_min, eq_level_max);
664 if ( level < eq_level_min || level > eq_level_max )
666 debug_error("out of range, EQ level(%d)\n", level);
667 result = MM_ERROR_INVALID_ARGUMENT;
671 player->audio_filter_info.custom_eq_level[index] = level;
672 debug_msg("set EQ[%d] = %d\n", index, level);
681 /* NOTE : parameter eq_index is only used for _set_eq_level() */
683 mm_player_sound_filter_custom_set_level(MMHandleType hplayer, MMAudioFilterCustomType filter_custom_type, int eq_index, int level)
685 mm_player_t* player = (mm_player_t*)hplayer;
686 int result = MM_ERROR_NONE;
689 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
691 /* check if this filter type is supported */
692 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_CUSTOM, filter_custom_type ) )
694 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
697 if (filter_custom_type == MM_AUDIO_FILTER_CUSTOM_EQ)
699 result = _mmplayer_sound_filter_custom_set_level_eq(player, eq_index, level);
701 else if (filter_custom_type > MM_AUDIO_FILTER_CUSTOM_EQ || filter_custom_type < MM_AUDIO_FILTER_CUSTOM_NUM)
703 result = _mmplayer_sound_filter_custom_set_level_ext(player, filter_custom_type, level);
707 debug_error("out of range, filter type(%d)\n", filter_custom_type);
708 result = MM_ERROR_INVALID_ARGUMENT;
715 mm_player_sound_filter_custom_get_eq_bands_number(MMHandleType hplayer, int *bands)
717 mm_player_t* player = (mm_player_t*)hplayer;
718 int result = MM_ERROR_NONE;
721 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
723 /* check if EQ is supported */
724 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_CUSTOM, MM_AUDIO_FILTER_CUSTOM_EQ ) )
726 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
729 *bands = PLAYER_INI()->audio_filter_custom_eq_num;
730 debug_log("number of custom eq band = %d\n", *bands);
739 mm_player_sound_filter_custom_get_level(MMHandleType hplayer, MMAudioFilterCustomType type, int eq_index, int *level)
741 mm_player_t* player = (mm_player_t*)hplayer;
742 int result = MM_ERROR_NONE;
746 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
747 return_val_if_fail( level, MM_ERROR_PLAYER_NOT_INITIALIZED );
749 /* check if this filter type is supported */
750 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_CUSTOM, type ) )
752 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
755 if (type == MM_AUDIO_FILTER_CUSTOM_EQ)
757 if ( eq_index < 0 || eq_index > PLAYER_INI()->audio_filter_custom_eq_num - 1 )
759 debug_error("out of range, eq index(%d)\n", eq_index);
760 result = MM_ERROR_INVALID_ARGUMENT;
764 *level = player->audio_filter_info.custom_eq_level[eq_index];
765 debug_log("EQ index = %d, level = %d\n", eq_index, *level);
768 else if ( type > MM_AUDIO_FILTER_CUSTOM_EQ && type < MM_AUDIO_FILTER_CUSTOM_NUM )
770 *level = player->audio_filter_info.custom_ext_level[type-1];
771 debug_log("extention filter index = %d, level = %d\n", type, *level);
775 debug_error("out of range, type(%d)\n", type);
776 result = MM_ERROR_INVALID_ARGUMENT;
786 mm_player_sound_filter_custom_get_level_range(MMHandleType hplayer, MMAudioFilterCustomType type, int *min, int *max)
788 mm_player_t* player = (mm_player_t*)hplayer;
789 int result = MM_ERROR_NONE;
790 int count = 1; /* start from 1, because of excepting eq index */
791 int ext_level_index = 1; /* start from 1, because of excepting eq index */
795 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
796 return_val_if_fail( min, MM_ERROR_PLAYER_NOT_INITIALIZED );
797 return_val_if_fail( max, MM_ERROR_PLAYER_NOT_INITIALIZED );
799 /* check if this filter type is supported */
800 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_CUSTOM, type ) )
802 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
805 if ( type == MM_AUDIO_FILTER_CUSTOM_EQ )
807 *min = PLAYER_INI()->audio_filter_custom_min_level_list[MM_AUDIO_FILTER_CUSTOM_EQ];
808 *max = PLAYER_INI()->audio_filter_custom_max_level_list[MM_AUDIO_FILTER_CUSTOM_EQ];
809 debug_log("EQ min level = %d, max level = %d\n", *min, *max);
813 while ( count < MM_AUDIO_FILTER_CUSTOM_NUM )
815 if ( PLAYER_INI()->audio_filter_custom_list[count] )
819 *min = PLAYER_INI()->audio_filter_custom_min_level_list[ext_level_index];
820 *max = PLAYER_INI()->audio_filter_custom_max_level_list[ext_level_index];
821 debug_msg("Extension filter(%d) min level = %d, max level = %d\n", count, *min, *max);
825 if ( ext_level_index == PLAYER_INI()->audio_filter_custom_ext_num + 1 )
827 debug_error("could not find min, max value. maybe filter information in ini file is not proper for sound effect plugin\n");
842 mm_player_sound_filter_custom_set_level_eq_from_list(MMHandleType hplayer, int *level_list, int size)
844 mm_player_t *player = (mm_player_t*)hplayer;
846 gint eq_level_min = 0;
847 gint eq_level_max = 0;
848 int result = MM_ERROR_NONE;
852 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
854 /* check if EQ is supported */
855 if ( !_mmplayer_is_supported_filter_type( MM_AUDIO_FILTER_TYPE_CUSTOM, MM_AUDIO_FILTER_CUSTOM_EQ ) )
857 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
860 if ( size != PLAYER_INI()->audio_filter_custom_eq_num )
862 debug_error("input size variable(%d) does not match with number of eq band(%d)\n", size, PLAYER_INI()->audio_filter_custom_eq_num);
863 result = MM_ERROR_INVALID_ARGUMENT;
867 eq_level_min = PLAYER_INI()->audio_filter_custom_min_level_list[MM_AUDIO_FILTER_CUSTOM_EQ];
868 eq_level_max = PLAYER_INI()->audio_filter_custom_max_level_list[MM_AUDIO_FILTER_CUSTOM_EQ];
870 for ( i = 0 ; i < size ; i++ )
872 if ( level_list[i] < eq_level_min || level_list[i] > eq_level_max)
874 debug_error("out of range, level[%d]=%d\n", i, level_list[i]);
875 result = MM_ERROR_INVALID_ARGUMENT;
878 player->audio_filter_info.custom_eq_level[i] = level_list[i];