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_audioeffect.h"
24 #include "mm_player_ini.h"
25 #include "mm_player_priv.h"
30 mm_player_get_foreach_present_supported_effect_type(MMHandleType player, MMAudioEffectType effect_type, mmplayer_supported_audio_effect_cb foreach_cb, void *user_data)
32 int result = MM_ERROR_NONE;
33 mm_sound_device_in device_in;
34 mm_sound_device_out device_out;
39 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
41 /* get status if speaker is activated */
42 result = mm_sound_get_active_device(&device_in, &device_out);
45 debug_error("mm_sound_get_active_device() failed [%x]!!", result);
50 if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
52 for ( i = 0; i < MM_AUDIO_EFFECT_PRESET_NUM; i++ )
54 if (PLAYER_INI()->audio_effect_preset_list[i] )
56 if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER &&
57 PLAYER_INI()->audio_effect_preset_earphone_only_list[i])
61 if (!foreach_cb(effect_type,i, user_data))
69 else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
71 for ( i = 0; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++ )
73 if (PLAYER_INI()->audio_effect_custom_list[i] )
75 if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER &&
76 PLAYER_INI()->audio_effect_custom_earphone_only_list[i])
80 if (!foreach_cb(effect_type,i, user_data))
89 debug_error("invalid effect type(%d)", effect_type);
90 result = MM_ERROR_INVALID_ARGUMENT;
98 debug_error("foreach callback returned error");
100 return MM_ERROR_PLAYER_INTERNAL;
105 __mmplayer_set_harmony_effect(mm_player_t *player, GstElement *audio_effect_element)
107 gint *ext_effect_level_list = NULL;
108 int count = 1; /* start from 1, because of excepting eq index */
109 int ext_level_index = 0;
110 int result = MM_ERROR_NONE;
114 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
115 return_val_if_fail ( audio_effect_element, MM_ERROR_INVALID_ARGUMENT );
118 if( PLAYER_INI()->audio_effect_custom_eq_band_num )
120 debug_log("pass custom EQ level list to audio effect plugin");
121 /* set custom-equalizer level list */
122 g_object_set(audio_effect_element, "custom-eq", player->audio_effect_info.custom_eq_level, NULL);
126 debug_warning("no custom EQ");
129 /* Custom Extension effects */
130 if( PLAYER_INI()->audio_effect_custom_ext_num )
132 debug_log("pass custom extension level list to audio effect plugin");
133 ext_effect_level_list = player->audio_effect_info.custom_ext_level_for_plugin;
134 if (!ext_effect_level_list) {
135 ext_effect_level_list = (gint*) malloc (sizeof(gint)*PLAYER_INI()->audio_effect_custom_ext_num);
136 if (!ext_effect_level_list)
138 debug_error("memory allocation for extension effect list failed");
139 return MM_ERROR_OUT_OF_MEMORY;
143 memset (ext_effect_level_list, 0, PLAYER_INI()->audio_effect_custom_ext_num);
147 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
149 if ( PLAYER_INI()->audio_effect_custom_list[count] )
151 ext_effect_level_list[ext_level_index] = player->audio_effect_info.custom_ext_level[count-1];
153 if (ext_level_index == PLAYER_INI()->audio_effect_custom_ext_num)
161 /* set custom-extension effects level list */
162 g_object_set(audio_effect_element, "custom-ext", ext_effect_level_list, NULL);
166 debug_warning("no custom extension effect");
169 /* order action to audio effect plugin */
170 g_object_set(audio_effect_element, "filter-action", MM_AUDIO_EFFECT_TYPE_CUSTOM, NULL);
171 debug_log("filter-action = %d", MM_AUDIO_EFFECT_TYPE_CUSTOM);
180 __mmplayer_is_earphone_only_effect_type(mm_player_t *player, MMAudioEffectType effect_type, int effect)
182 gboolean result = FALSE;
187 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
190 if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
192 if (PLAYER_INI()->audio_effect_preset_earphone_only_list[effect])
194 debug_msg("this preset effect(%d) is only available with earphone", effect);
199 else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
201 for (i = 1; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++) /* it starts from 1(except testing for EQ) */
203 if (PLAYER_INI()->audio_effect_custom_earphone_only_list[i])
205 /* check if the earphone only custom effect was set */
206 if (player->audio_effect_info.custom_ext_level[i-1])
208 debug_msg("this custom effect(%d) is only available with earphone", i);
216 debug_error("invalid effect type(%d)", effect_type);
226 _mmplayer_is_supported_effect_type(MMAudioEffectType effect_type, int effect)
228 gboolean result = TRUE;
229 mm_sound_device_in device_in;
230 mm_sound_device_out device_out;
231 int ret = MM_ERROR_NONE;
235 /* get status if speaker is activated */
236 ret = mm_sound_get_active_device(&device_in, &device_out);
239 debug_error("mm_sound_get_active_device() failed [%x]!!", ret);
245 if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
247 if ( effect < MM_AUDIO_EFFECT_PRESET_AUTO || effect >= MM_AUDIO_EFFECT_PRESET_NUM )
249 debug_error("out of range, preset effect(%d)", effect);
252 if (!PLAYER_INI()->audio_effect_preset_list[effect])
254 debug_error("this effect(%d) is not supported", effect);
259 if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER &&
260 PLAYER_INI()->audio_effect_preset_earphone_only_list[effect])
267 else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
269 if ( effect < MM_AUDIO_EFFECT_CUSTOM_EQ || effect >= MM_AUDIO_EFFECT_CUSTOM_NUM )
271 debug_error("out of range, custom effect(%d)", effect);
274 if (!PLAYER_INI()->audio_effect_custom_list[effect])
276 debug_error("this custom effect(%d) is not supported", effect);
281 if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER &&
282 PLAYER_INI()->audio_effect_custom_earphone_only_list[effect])
290 debug_error("invalid effect type(%d)", effect_type);
302 _mmplayer_audio_effect_preset_apply(mm_player_t *player, MMAudioEffectPresetType effect_type)
304 GstElement *audio_effect_element = NULL;
305 int result = MM_ERROR_NONE;
307 mm_sound_device_in device_in;
308 mm_sound_device_out device_out;
312 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
314 /* Music Player can set audio effect value before Audiobin is created. */
315 if ( !player->pipeline || !player->pipeline->audiobin )
317 debug_warning("effect element is not created yet.");
319 player->bypass_audio_effect = FALSE;
321 /* store audio effect setting in order to apply it when audio effect plugin is created */
322 player->audio_effect_info.effect_type = MM_AUDIO_EFFECT_TYPE_PRESET;
323 player->audio_effect_info.preset = effect_type;
327 return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED );
329 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
331 /* get status if speaker is activated */
332 result = mm_sound_get_active_device(&device_in, &device_out);
334 debug_error("mm_sound_get_active_device() failed [%x]!!", result);
340 if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER)
342 output_type = MM_AUDIO_EFFECT_OUTPUT_SPK;
343 if (__mmplayer_is_earphone_only_effect_type(player, MM_AUDIO_EFFECT_TYPE_PRESET, effect_type))
345 debug_error("earphone is not equipped, this filter will not be applied");
347 return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
350 /* Other case, include WIRED_ACCESSORY, BLUETOOTH, DOCK */
353 output_type = MM_AUDIO_EFFECT_OUTPUT_EAR;
356 /* set filter output mode as SPEAKER or EARPHONE */
357 g_object_set(audio_effect_element, "filter-output-mode", output_type, NULL);
358 debug_log("filter-output-mode = %d (0:spk,1:ear)", output_type);
360 if (effect_type == MM_AUDIO_EFFECT_PRESET_AUTO) {
361 /* TODO: Add codes about auto selecting preset mode according to ID3 tag */
362 /* set effect preset mode */
363 g_object_set(audio_effect_element, "preset-mode", 0, NULL); /* forced set to 0(normal) temporarily */
364 debug_log("preset-mode = %d", effect_type);
367 /* set effect preset mode */
368 g_object_set(audio_effect_element, "preset-mode", effect_type-1, NULL); /* effect_type-1, because of _PRESET_AUTO in MSL/CAPI which does not exist in soundAlive plugin */
369 debug_log("preset-mode = %d", effect_type);
372 /* order action to audio effect plugin */
373 g_object_set(audio_effect_element, "filter-action", MM_AUDIO_EFFECT_TYPE_PRESET, NULL);
374 debug_log("filter-action = %d", MM_AUDIO_EFFECT_TYPE_PRESET);
385 _mmplayer_audio_effect_custom_apply(mm_player_t *player)
387 GstElement *audio_effect_element = NULL;
388 int result = MM_ERROR_NONE;
392 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
394 /* Music Player can set audio effect value before Audiobin is created. */
395 if ( !player->pipeline || !player->pipeline->audiobin )
397 debug_warning("effect element is not created yet.");
399 player->bypass_audio_effect = FALSE;
401 /* store audio effect setting in order to apply it when audio effect plugin is created */
402 player->audio_effect_info.effect_type = MM_AUDIO_EFFECT_TYPE_CUSTOM;
407 mm_sound_device_in device_in;
408 mm_sound_device_out device_out;
410 return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED );
412 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
414 /* get status if speaker is activated */
415 result = mm_sound_get_active_device(&device_in, &device_out);
417 debug_error("mm_sound_get_active_device() failed [%x]!!", result);
423 if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER)
425 output_type = MM_AUDIO_EFFECT_OUTPUT_SPK;
426 if (__mmplayer_is_earphone_only_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, 0))
428 debug_error("earphone is not equipped, some custom effect should operate with earphone");
430 return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
433 /* Other case, include WIRED_ACCESSORY, BLUETOOTH, DOCK */
436 output_type = MM_AUDIO_EFFECT_OUTPUT_EAR;
439 /* set filter output mode as SPEAKER or EARPHONE */
440 g_object_set(audio_effect_element, "filter-output-mode", output_type, NULL);
441 debug_log("filter-output-mode = %d (0:spk,1:ear)", output_type);
443 result = __mmplayer_set_harmony_effect(player, audio_effect_element);
446 debug_error("_set_harmony_effect() failed(%x)", result);
459 mm_player_audio_effect_custom_clear_eq_all(MMHandleType hplayer)
461 int result = MM_ERROR_NONE;
462 mm_player_t* player = (mm_player_t*)hplayer;
466 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
468 /* clear EQ custom effect */
469 memset(player->audio_effect_info.custom_eq_level, MM_AUDIO_EFFECT_CUSTOM_LEVEL_INIT, sizeof(int)*MM_AUDIO_EFFECT_EQ_BAND_NUM_MAX);
471 debug_msg("All the EQ bands clearing success");
480 mm_player_audio_effect_custom_clear_ext_all(MMHandleType hplayer)
483 int result = MM_ERROR_NONE;
484 mm_player_t* player = (mm_player_t*)hplayer;
488 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
490 /* clear ALL custom effects, except EQ */
491 for ( i = 0 ; i < MM_AUDIO_EFFECT_CUSTOM_NUM - 1 ; i++ )
493 player->audio_effect_info.custom_ext_level[i] = MM_AUDIO_EFFECT_CUSTOM_LEVEL_INIT;
496 debug_msg("All the extension effects clearing success");
505 mm_player_is_supported_preset_effect_type(MMHandleType hplayer, MMAudioEffectPresetType effect)
507 mm_player_t* player = (mm_player_t*)hplayer;
508 int result = MM_ERROR_NONE;
512 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
514 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_PRESET, effect ) )
516 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
526 mm_player_is_supported_custom_effect_type(MMHandleType hplayer, MMAudioEffectCustomType effect)
528 mm_player_t* player = (mm_player_t*)hplayer;
529 int result = MM_ERROR_NONE;
533 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
535 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, effect ) )
537 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
547 mm_player_audio_effect_preset_apply(MMHandleType hplayer, MMAudioEffectPresetType type)
549 mm_player_t* player = (mm_player_t*)hplayer;
550 int result = MM_ERROR_NONE;
554 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
556 if (!PLAYER_INI()->use_audio_effect_preset)
558 debug_error("audio effect(preset) is not supported", type);
560 return MM_ERROR_NOT_SUPPORT_API;
563 if (type < MM_AUDIO_EFFECT_PRESET_AUTO || type >= MM_AUDIO_EFFECT_PRESET_NUM)
565 debug_error("out of range, type(%d)", type);
567 return MM_ERROR_INVALID_ARGUMENT;
570 /* check if this effect type is supported */
571 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_PRESET, type ) )
574 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
577 result = _mmplayer_audio_effect_preset_apply(player, type);
586 mm_player_audio_effect_custom_apply(MMHandleType hplayer)
588 mm_player_t* player = (mm_player_t*)hplayer;
589 int result = MM_ERROR_NONE;
593 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
595 if (!PLAYER_INI()->use_audio_effect_custom)
597 debug_error("audio effect(custom) is not supported");
599 return MM_ERROR_NOT_SUPPORT_API;
602 result = _mmplayer_audio_effect_custom_apply(player);
611 mm_player_audio_effect_bypass (MMHandleType hplayer)
613 mm_player_t* player = (mm_player_t*)hplayer;
614 int result = MM_ERROR_NONE;
615 GstElement *audio_effect_element = NULL;
619 return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
621 if ( !PLAYER_INI()->use_audio_effect_preset && !PLAYER_INI()->use_audio_effect_custom )
623 debug_error("audio effect(preset/custom) is not supported");
625 return MM_ERROR_NOT_SUPPORT_API;
627 if ( !player->pipeline || !player->pipeline->audiobin )
629 debug_warning("effect element is not created yet.");
633 return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED );
634 audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
636 /* order action to audio effect plugin */
637 g_object_set(audio_effect_element, "filter-action", MM_AUDIO_EFFECT_TYPE_NONE, NULL);
638 debug_log("filter-action = %d", MM_AUDIO_EFFECT_TYPE_NONE);
648 _mmplayer_audio_effect_custom_set_level_ext(mm_player_t *player, MMAudioEffectCustomType custom_effect_type, int level)
650 int effect_level_max = 0;
651 int effect_level_min = 0;
652 int count = 1; /* start from 1, because of excepting eq index */
653 int ext_level_index = 1; /* start from 1, because of excepting eq index */
654 int result = MM_ERROR_NONE;
658 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
660 /* check if EQ is supported */
661 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, custom_effect_type ) )
664 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
667 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
669 if ( PLAYER_INI()->audio_effect_custom_list[count] )
671 if ( count == custom_effect_type )
673 effect_level_min = PLAYER_INI()->audio_effect_custom_min_level_list[ext_level_index];
674 effect_level_max = PLAYER_INI()->audio_effect_custom_max_level_list[ext_level_index];
675 debug_msg("level min value(%d), level max value(%d)", effect_level_min, effect_level_max);
679 if (ext_level_index == PLAYER_INI()->audio_effect_custom_ext_num + 1)
681 debug_error("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin");
688 if ( level < effect_level_min || level > effect_level_max )
690 debug_error("out of range, level(%d)", level);
691 result = MM_ERROR_INVALID_ARGUMENT;
695 player->audio_effect_info.custom_ext_level[custom_effect_type-1] = level;
696 debug_msg("set ext[%d] = %d", custom_effect_type-1, level);
706 _mmplayer_audio_effect_custom_set_level_eq(mm_player_t *player, int index, int level)
708 gint eq_level_max = 0;
709 gint eq_level_min = 0;
710 int result = MM_ERROR_NONE;
714 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
716 /* check if EQ is supported */
717 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
720 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
723 if ( index < 0 || index > PLAYER_INI()->audio_effect_custom_eq_band_num - 1 )
725 debug_error("out of range, index(%d)", index);
726 result = MM_ERROR_INVALID_ARGUMENT;
730 eq_level_min = PLAYER_INI()->audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
731 eq_level_max = PLAYER_INI()->audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
732 debug_msg("EQ level min value(%d), EQ level max value(%d)", eq_level_min, eq_level_max);
734 if ( level < eq_level_min || level > eq_level_max )
736 debug_error("out of range, EQ level(%d)", level);
737 result = MM_ERROR_INVALID_ARGUMENT;
741 player->audio_effect_info.custom_eq_level[index] = level;
742 debug_msg("set EQ[%d] = %d", index, level);
752 /* NOTE : parameter eq_index is only used for _set_eq_level() */
754 mm_player_audio_effect_custom_set_level(MMHandleType hplayer, MMAudioEffectCustomType effect_custom_type, int eq_index, int level)
756 mm_player_t* player = (mm_player_t*)hplayer;
757 int result = MM_ERROR_NONE;
761 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
763 /* check if this effect type is supported */
764 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, effect_custom_type ) )
766 result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
770 if (effect_custom_type == MM_AUDIO_EFFECT_CUSTOM_EQ)
772 result = _mmplayer_audio_effect_custom_set_level_eq(player, eq_index, level);
774 else if (effect_custom_type > MM_AUDIO_EFFECT_CUSTOM_EQ || effect_custom_type < MM_AUDIO_EFFECT_CUSTOM_NUM)
776 result = _mmplayer_audio_effect_custom_set_level_ext(player, effect_custom_type, level);
780 debug_error("out of range, effect type(%d)", effect_custom_type);
781 result = MM_ERROR_INVALID_ARGUMENT;
792 mm_player_audio_effect_custom_get_eq_bands_number(MMHandleType hplayer, int *bands)
794 mm_player_t* player = (mm_player_t*)hplayer;
795 int result = MM_ERROR_NONE;
799 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
801 /* check if EQ is supported */
802 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
805 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
808 *bands = PLAYER_INI()->audio_effect_custom_eq_band_num;
809 debug_log("number of custom EQ band = %d", *bands);
818 mm_player_audio_effect_custom_get_eq_bands_width(MMHandleType hplayer, int band_idx, int *width)
820 mm_player_t* player = (mm_player_t*)hplayer;
821 int result = MM_ERROR_NONE;
822 unsigned int eq_num = 0;
826 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
828 /* check if EQ is supported */
829 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
832 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
835 return_val_if_fail( player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED );
837 eq_num = PLAYER_INI()->audio_effect_custom_eq_band_num;
838 if (band_idx < 0 || band_idx > eq_num-1)
840 debug_error("out of range, invalid band_idx(%d)", band_idx);
841 result = MM_ERROR_PLAYER_INTERNAL;
845 /* set the width of EQ band */
846 *width = PLAYER_INI()->audio_effect_custom_eq_band_width[band_idx];
847 debug_log("width of band_idx(%d) = %dHz", band_idx, *width);
857 mm_player_audio_effect_custom_get_eq_bands_freq(MMHandleType hplayer, int band_idx, int *freq)
859 mm_player_t* player = (mm_player_t*)hplayer;
860 int result = MM_ERROR_NONE;
861 unsigned int eq_num = 0;
865 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
867 /* check if EQ is supported */
868 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
871 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
874 return_val_if_fail( player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED );
876 eq_num = PLAYER_INI()->audio_effect_custom_eq_band_num;
877 if (band_idx < 0 || band_idx > eq_num-1)
879 debug_error("out of range, invalid band_idx(%d)", band_idx);
880 result = MM_ERROR_PLAYER_INTERNAL;
884 /* set the frequency of EQ band */
885 *freq = PLAYER_INI()->audio_effect_custom_eq_band_freq[band_idx];
886 debug_log("frequency of band_idx(%d) = %dHz", band_idx, *freq);
896 mm_player_audio_effect_custom_get_level(MMHandleType hplayer, MMAudioEffectCustomType type, int eq_index, int *level)
898 mm_player_t* player = (mm_player_t*)hplayer;
899 int result = MM_ERROR_NONE;
903 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
904 return_val_if_fail( level, MM_ERROR_PLAYER_NOT_INITIALIZED );
906 /* check if this effect type is supported */
907 if ( !_mmplayer_is_supported_effect_type( 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 if ( eq_index < 0 || eq_index > PLAYER_INI()->audio_effect_custom_eq_band_num - 1 )
917 debug_error("out of range, EQ index(%d)", eq_index);
918 result = MM_ERROR_INVALID_ARGUMENT;
922 *level = player->audio_effect_info.custom_eq_level[eq_index];
923 debug_log("EQ index = %d, level = %d", eq_index, *level);
926 else if ( type > MM_AUDIO_EFFECT_CUSTOM_EQ && type < MM_AUDIO_EFFECT_CUSTOM_NUM )
928 *level = player->audio_effect_info.custom_ext_level[type-1];
929 debug_log("extension effect index = %d, level = %d", type, *level);
933 debug_error("out of range, type(%d)", type);
934 result = MM_ERROR_INVALID_ARGUMENT;
944 mm_player_audio_effect_custom_get_level_range(MMHandleType hplayer, MMAudioEffectCustomType type, int *min, int *max)
946 mm_player_t* player = (mm_player_t*)hplayer;
947 int result = MM_ERROR_NONE;
948 int count = 1; /* start from 1, because of excepting eq index */
949 int ext_level_index = 1; /* start from 1, because of excepting eq index */
953 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
954 return_val_if_fail( min, MM_ERROR_PLAYER_NOT_INITIALIZED );
955 return_val_if_fail( max, MM_ERROR_PLAYER_NOT_INITIALIZED );
957 /* check if this effect type is supported */
958 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) )
961 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
964 if ( type == MM_AUDIO_EFFECT_CUSTOM_EQ )
966 *min = PLAYER_INI()->audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
967 *max = PLAYER_INI()->audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
968 debug_log("EQ min level = %d, max level = %d", *min, *max);
972 while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
974 if ( PLAYER_INI()->audio_effect_custom_list[count] )
978 *min = PLAYER_INI()->audio_effect_custom_min_level_list[ext_level_index];
979 *max = PLAYER_INI()->audio_effect_custom_max_level_list[ext_level_index];
980 debug_msg("Extension effect(%d) min level = %d, max level = %d", count, *min, *max);
984 if ( ext_level_index == PLAYER_INI()->audio_effect_custom_ext_num + 1 )
986 debug_error("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin");
1001 mm_player_audio_effect_custom_set_level_eq_from_list(MMHandleType hplayer, int *level_list, int size)
1003 mm_player_t *player = (mm_player_t*)hplayer;
1005 gint eq_level_min = 0;
1006 gint eq_level_max = 0;
1007 int result = MM_ERROR_NONE;
1011 return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
1013 /* check if EQ is supported */
1014 if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
1017 return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
1020 if ( size != PLAYER_INI()->audio_effect_custom_eq_band_num )
1022 debug_error("input size variable(%d) does not match with number of eq band(%d)", size, PLAYER_INI()->audio_effect_custom_eq_band_num);
1023 result = MM_ERROR_INVALID_ARGUMENT;
1027 eq_level_min = PLAYER_INI()->audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
1028 eq_level_max = PLAYER_INI()->audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
1030 for ( i = 0 ; i < size ; i++ )
1032 if ( level_list[i] < eq_level_min || level_list[i] > eq_level_max)
1034 debug_error("out of range, level[%d]=%d", i, level_list[i]);
1035 result = MM_ERROR_INVALID_ARGUMENT;
1038 player->audio_effect_info.custom_eq_level[i] = level_list[i];