X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmm_player_audioeffect.c;h=ab90b2d9f2c96e30fcd3629c1d6cf45ba610899e;hb=1acc07520abedc9715378ebbed2f024614eac8f2;hp=8fea0556fa53e44634caa1d2a25568f5c2eb0daf;hpb=8de0eae4f0a13bfe4cf0ef20cd8ed2899095bb51;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git diff --git a/src/mm_player_audioeffect.c b/src/mm_player_audioeffect.c old mode 100644 new mode 100755 index 8fea055..ab90b2d --- a/src/mm_player_audioeffect.c +++ b/src/mm_player_audioeffect.c @@ -20,6 +20,7 @@ */ #include +#include "mm_player_utils.h" #include "mm_player_audioeffect.h" #include "mm_player_ini.h" #include "mm_player_priv.h" @@ -27,22 +28,47 @@ int -mm_player_get_foreach_present_supported_effect_type(MMHandleType player, MMAudioEffectType effect_type, mmplayer_supported_audio_effect_cb foreach_cb, void *user_data) +mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudioEffectType effect_type, mmplayer_supported_audio_effect_cb foreach_cb, void *user_data) { + mm_player_t *player = NULL; int result = MM_ERROR_NONE; - mm_sound_device_in device_in; - mm_sound_device_out device_out; + mm_sound_device_flags_e flags = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG | MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; + MMSoundDeviceList_t device_list; + MMSoundDevice_t device_h = NULL; + mm_sound_device_type_e device_type; int i = 0; - debug_fenter(); + MMPLAYER_FENTER(); - return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); + return_val_if_fail ( hplayer, MM_ERROR_PLAYER_NOT_INITIALIZED ); + + player = MM_PLAYER_CAST(hplayer); /* get status if speaker is activated */ - result = mm_sound_get_active_device(&device_in, &device_out); + /* (1) get current device list */ + result = mm_sound_get_current_device_list(flags, &device_list); + + if ( result ) { + debug_error("mm_sound_get_current_device_list() failed [%x]!!", result); + MMPLAYER_FLEAVE(); + return result; + } + + /* (2) get device handle of device list */ + result = mm_sound_get_next_device (device_list, &device_h); + + if ( result ) { + debug_error("mm_sound_get_next_device() failed [%x]!!", result); + MMPLAYER_FLEAVE(); + return result; + } + + /* (3) get device type */ + result = mm_sound_get_device_type(device_h, &device_type); + if ( result ) { - debug_fleave(); - debug_error("mm_sound_get_active_device() failed [%x]!!", result); + debug_error("mm_sound_get_device_type() failed [%x]!!", result); + MMPLAYER_FLEAVE(); return result; } @@ -51,10 +77,10 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType player, MMAudio { for ( i = 0; i < MM_AUDIO_EFFECT_PRESET_NUM; i++ ) { - if (PLAYER_INI()->audio_effect_preset_list[i] ) + if (player->ini.audio_effect_preset_list[i] ) { - if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER && - PLAYER_INI()->audio_effect_preset_earphone_only_list[i]) + if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER && + player->ini.audio_effect_preset_earphone_only_list[i]) { continue; } @@ -70,10 +96,10 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType player, MMAudio { for ( i = 0; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++ ) { - if (PLAYER_INI()->audio_effect_custom_list[i] ) + if (player->ini.audio_effect_custom_list[i] ) { - if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER && - PLAYER_INI()->audio_effect_custom_earphone_only_list[i]) + if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER && + player->ini.audio_effect_custom_earphone_only_list[i]) { continue; } @@ -90,13 +116,13 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType player, MMAudio result = MM_ERROR_INVALID_ARGUMENT; } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; CALLBACK_ERROR: debug_error("foreach callback returned error"); - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_INTERNAL; } @@ -109,13 +135,13 @@ __mmplayer_set_harmony_effect(mm_player_t *player, GstElement *audio_effect_elem int ext_level_index = 0; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); return_val_if_fail ( audio_effect_element, MM_ERROR_INVALID_ARGUMENT ); /* Custom EQ */ - if( PLAYER_INI()->audio_effect_custom_eq_band_num ) + if( player->ini.audio_effect_custom_eq_band_num ) { debug_log("pass custom EQ level list to audio effect plugin"); /* set custom-equalizer level list */ @@ -127,12 +153,12 @@ __mmplayer_set_harmony_effect(mm_player_t *player, GstElement *audio_effect_elem } /* Custom Extension effects */ - if( PLAYER_INI()->audio_effect_custom_ext_num ) + if( player->ini.audio_effect_custom_ext_num ) { debug_log("pass custom extension level list to audio effect plugin"); ext_effect_level_list = player->audio_effect_info.custom_ext_level_for_plugin; if (!ext_effect_level_list) { - ext_effect_level_list = (gint*) malloc (sizeof(gint)*PLAYER_INI()->audio_effect_custom_ext_num); + ext_effect_level_list = (gint*) malloc (sizeof(gint)*player->ini.audio_effect_custom_ext_num); if (!ext_effect_level_list) { debug_error("memory allocation for extension effect list failed"); @@ -140,17 +166,20 @@ __mmplayer_set_harmony_effect(mm_player_t *player, GstElement *audio_effect_elem } else { - memset (ext_effect_level_list, 0, PLAYER_INI()->audio_effect_custom_ext_num); + memset (ext_effect_level_list, 0, player->ini.audio_effect_custom_ext_num); + + /* associate it to player handle */ + player->audio_effect_info.custom_ext_level_for_plugin = ext_effect_level_list; } } while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM ) { - if ( PLAYER_INI()->audio_effect_custom_list[count] ) + if ( player->ini.audio_effect_custom_list[count] ) { ext_effect_level_list[ext_level_index] = player->audio_effect_info.custom_ext_level[count-1]; ext_level_index++; - if (ext_level_index == PLAYER_INI()->audio_effect_custom_ext_num) + if (ext_level_index == player->ini.audio_effect_custom_ext_num) { break; } @@ -170,7 +199,7 @@ __mmplayer_set_harmony_effect(mm_player_t *player, GstElement *audio_effect_elem g_object_set(audio_effect_element, "filter-action", MM_AUDIO_EFFECT_TYPE_CUSTOM, NULL); debug_log("filter-action = %d", MM_AUDIO_EFFECT_TYPE_CUSTOM); - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -182,14 +211,14 @@ __mmplayer_is_earphone_only_effect_type(mm_player_t *player, MMAudioEffectType e gboolean result = FALSE; int i = 0; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); /* preset */ if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET) { - if (PLAYER_INI()->audio_effect_preset_earphone_only_list[effect]) + if (player->ini.audio_effect_preset_earphone_only_list[effect]) { debug_msg("this preset effect(%d) is only available with earphone", effect); result = TRUE; @@ -200,7 +229,7 @@ __mmplayer_is_earphone_only_effect_type(mm_player_t *player, MMAudioEffectType e { for (i = 1; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++) /* it starts from 1(except testing for EQ) */ { - if (PLAYER_INI()->audio_effect_custom_earphone_only_list[i]) + if (player->ini.audio_effect_custom_earphone_only_list[i]) { /* check if the earphone only custom effect was set */ if (player->audio_effect_info.custom_ext_level[i-1]) @@ -216,241 +245,300 @@ __mmplayer_is_earphone_only_effect_type(mm_player_t *player, MMAudioEffectType e debug_error("invalid effect type(%d)", effect_type); } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } +int +__mmplayer_audio_set_output_type (mm_player_t *player, MMAudioEffectType effect_type, int effect) +{ + GstElement *audio_effect_element = NULL; + mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG; + MMSoundDeviceList_t device_list; + MMSoundDevice_t device_h = NULL; + mm_sound_device_type_e device_type; + int output_type = 0; + int result = MM_ERROR_NONE; + + MMPLAYER_FENTER(); + + return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst; + + /* (1) get current device list */ + result = mm_sound_get_current_device_list(flags, &device_list); + + if ( result ) { + debug_error("mm_sound_get_current_device_list() failed [%x]!!", result); + MMPLAYER_FLEAVE(); + return result; + } + + /* (2) get device handle of device list */ + result = mm_sound_get_next_device (device_list, &device_h); + + if ( result ) { + debug_error("mm_sound_get_next_device() failed [%x]!!", result); + MMPLAYER_FLEAVE(); + return result; + } + + /* (3) get device type */ + result = mm_sound_get_device_type(device_h, &device_type); + + if ( result ) { + debug_error("mm_sound_get_device_type() failed [%x]!!", result); + MMPLAYER_FLEAVE(); + return result; + } + + /* SPEAKER case */ + if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER) + { + if ( MM_AUDIO_EFFECT_TYPE_SQUARE != effect_type ) { + if (__mmplayer_is_earphone_only_effect_type(player, effect_type, effect)) + { + debug_error("earphone is not equipped, this filter will not be applied"); + MMPLAYER_FLEAVE(); + return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS; + } + } + + output_type = MM_AUDIO_EFFECT_OUTPUT_SPK; + } + else if (device_type == MM_SOUND_DEVICE_TYPE_MIRRORING) + { + output_type = MM_AUDIO_EFFECT_OUTPUT_OTHERS; + } + else if (device_type == MM_SOUND_DEVICE_TYPE_HDMI) + { + output_type = MM_AUDIO_EFFECT_OUTPUT_HDMI; + } + else if (device_type == MM_SOUND_DEVICE_TYPE_BLUETOOTH) + { + output_type = MM_AUDIO_EFFECT_OUTPUT_BT; + } + else if (device_type == MM_SOUND_DEVICE_TYPE_USB_AUDIO) + { + output_type = MM_AUDIO_EFFECT_OUTPUT_USB_AUDIO; + } + /* Other case, include WIRED_ACCESSORY */ + else + { + output_type = MM_AUDIO_EFFECT_OUTPUT_EAR; + } + debug_warning("output_type = %d (0:spk,1:ear,2:others)", output_type); + + /* set filter output mode */ + g_object_set(audio_effect_element, "filter-output-mode", output_type, NULL); + + return result; +} gboolean -_mmplayer_is_supported_effect_type(MMAudioEffectType effect_type, int effect) +_mmplayer_is_supported_effect_type(mm_player_t* player, MMAudioEffectType effect_type, int effect) { gboolean result = TRUE; - mm_sound_device_in device_in; - mm_sound_device_out device_out; + mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG; + MMSoundDeviceList_t device_list; + MMSoundDevice_t device_h = NULL; + mm_sound_device_type_e device_type; int ret = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); /* get status if speaker is activated */ - ret = mm_sound_get_active_device(&device_in, &device_out); - if ( ret ) { - debug_fleave(); - debug_error("mm_sound_get_active_device() failed [%x]!!", ret); - result = FALSE; + /* (1) get current device list */ + ret = mm_sound_get_current_device_list(flags, &device_list); + if (ret) { + MMPLAYER_FLEAVE(); + debug_error("mm_sound_get_current_device_list() failed [%x]!!", ret); + return FALSE; } - else + + /* (2) get device handle of device list */ + ret = mm_sound_get_next_device (device_list, &device_h); + + if (ret) { + debug_error("mm_sound_get_next_device() failed [%x]!!", ret); + MMPLAYER_FLEAVE(); + return FALSE; + } + + /* (3) get device type */ + ret = mm_sound_get_device_type(device_h, &device_type); + + if (ret) { + debug_error("mm_sound_get_device_type() failed [%x]!!", ret); + MMPLAYER_FLEAVE(); + return FALSE; + } + + /* preset */ + if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET) { - /* preset */ - if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET) + if ( effect < MM_AUDIO_EFFECT_PRESET_AUTO || effect >= MM_AUDIO_EFFECT_PRESET_NUM ) { - if ( effect < MM_AUDIO_EFFECT_PRESET_AUTO || effect >= MM_AUDIO_EFFECT_PRESET_NUM ) - { - debug_error("out of range, preset effect(%d)", effect); - result = FALSE; - } - if (!PLAYER_INI()->audio_effect_preset_list[effect]) + debug_error("out of range, preset effect(%d)", effect); + result = FALSE; + } + else + { + if (!player->ini.audio_effect_preset_list[effect]) { debug_error("this effect(%d) is not supported", effect); result = FALSE; } else { - if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER && - PLAYER_INI()->audio_effect_preset_earphone_only_list[effect]) + if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER && + player->ini.audio_effect_preset_earphone_only_list[effect]) { result = FALSE; } } } - /* custom */ - else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) + } + /* custom */ + else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) + { + if ( effect < MM_AUDIO_EFFECT_CUSTOM_EQ || effect >= MM_AUDIO_EFFECT_CUSTOM_NUM ) { - if ( effect < MM_AUDIO_EFFECT_CUSTOM_EQ || effect >= MM_AUDIO_EFFECT_CUSTOM_NUM ) - { - debug_error("out of range, custom effect(%d)", effect); - result = FALSE; - } - if (!PLAYER_INI()->audio_effect_custom_list[effect]) + debug_error("out of range, custom effect(%d)", effect); + result = FALSE; + } + else + { + if (!player->ini.audio_effect_custom_list[effect]) { debug_error("this custom effect(%d) is not supported", effect); result = FALSE; } else { - if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER && - PLAYER_INI()->audio_effect_custom_earphone_only_list[effect]) + if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER && + player->ini.audio_effect_custom_earphone_only_list[effect]) { result = FALSE; } } } - else + } + else if (effect_type == MM_AUDIO_EFFECT_TYPE_SQUARE) + { + if (!player->ini.use_audio_effect_custom) { - debug_error("invalid effect type(%d)", effect_type); + debug_error("Square effect is not supported"); result = FALSE; } } + else + { + debug_error("invalid effect type(%d)", effect_type); + result = FALSE; + } + - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } - int -_mmplayer_audio_effect_preset_apply(mm_player_t *player, MMAudioEffectPresetType effect_type) +_mmplayer_audio_effect_custom_apply(mm_player_t *player) { GstElement *audio_effect_element = NULL; int result = MM_ERROR_NONE; - int output_type = 0; - mm_sound_device_in device_in; - mm_sound_device_out device_out; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* Music Player can set audio effect value before Audiobin is created. */ - if ( !player->pipeline || !player->pipeline->audiobin ) + if ( !player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst ) { debug_warning("effect element is not created yet."); player->bypass_audio_effect = FALSE; /* store audio effect setting in order to apply it when audio effect plugin is created */ - player->audio_effect_info.effect_type = MM_AUDIO_EFFECT_TYPE_PRESET; - player->audio_effect_info.preset = effect_type; + player->audio_effect_info.effect_type = MM_AUDIO_EFFECT_TYPE_CUSTOM; } else { - return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED ); - audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst; /* get status if speaker is activated */ - result = mm_sound_get_active_device(&device_in, &device_out); - if ( result ) { - debug_error("mm_sound_get_active_device() failed [%x]!!", result); - debug_fleave(); + result = __mmplayer_audio_set_output_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, 0); + + if ( result != MM_ERROR_NONE) { + debug_error("failed to set output mode"); + MMPLAYER_FLEAVE(); return result; } - /* SPEAKER case */ - if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER) - { - output_type = MM_AUDIO_EFFECT_OUTPUT_SPK; - if (__mmplayer_is_earphone_only_effect_type(player, MM_AUDIO_EFFECT_TYPE_PRESET, effect_type)) - { - debug_error("earphone is not equipped, this filter will not be applied"); - debug_fleave(); - return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS; - } - } - /* Other case, include WIRED_ACCESSORY, BLUETOOTH, DOCK */ - else + result = __mmplayer_set_harmony_effect(player, audio_effect_element); + if ( result ) { - output_type = MM_AUDIO_EFFECT_OUTPUT_EAR; - } - - /* set filter output mode as SPEAKER or EARPHONE */ - g_object_set(audio_effect_element, "filter-output-mode", output_type, NULL); - debug_log("filter-output-mode = %d (0:spk,1:ear)", output_type); - - if (effect_type == MM_AUDIO_EFFECT_PRESET_AUTO) { - /* TODO: Add codes about auto selecting preset mode according to ID3 tag */ - /* set effect preset mode */ - g_object_set(audio_effect_element, "preset-mode", 0, NULL); /* forced set to 0(normal) temporarily */ - debug_log("preset-mode = %d", effect_type); - - } else { - /* set effect preset mode */ - 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 */ - debug_log("preset-mode = %d", effect_type); + debug_error("_set_harmony_effect() failed(%x)", result); + MMPLAYER_FLEAVE(); + return result; } - - /* order action to audio effect plugin */ - g_object_set(audio_effect_element, "filter-action", MM_AUDIO_EFFECT_TYPE_PRESET, NULL); - debug_log("filter-action = %d", MM_AUDIO_EFFECT_TYPE_PRESET); - } + player->set_mode.rich_audio = TRUE; - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } - int -_mmplayer_audio_effect_custom_apply(mm_player_t *player) +_mmplayer_audio_effect_custom_update_level(mm_player_t *player) { GstElement *audio_effect_element = NULL; int result = MM_ERROR_NONE; + int ext_level_index = 0; + int count = 1; + int i = 0; + gint *custom_eq = NULL; + gint *custom_ext_effect_level_list = NULL; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); - /* Music Player can set audio effect value before Audiobin is created. */ - if ( !player->pipeline || !player->pipeline->audiobin ) - { - debug_warning("effect element is not created yet."); + audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst; - player->bypass_audio_effect = FALSE; + /* get custom eq effect */ + g_object_get(audio_effect_element, "custom-eq", &custom_eq, NULL); - /* store audio effect setting in order to apply it when audio effect plugin is created */ - player->audio_effect_info.effect_type = MM_AUDIO_EFFECT_TYPE_CUSTOM; - } - else - { - int output_type = 0; - mm_sound_device_in device_in; - mm_sound_device_out device_out; + memcpy(player->audio_effect_info.custom_eq_level, custom_eq, sizeof(gint) * player->ini.audio_effect_custom_eq_band_num); - return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED ); - - audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst; - - /* get status if speaker is activated */ - result = mm_sound_get_active_device(&device_in, &device_out); - if ( result ) { - debug_error("mm_sound_get_active_device() failed [%x]!!", result); - debug_fleave(); - return result; - } + for (i=0; iini.audio_effect_custom_eq_band_num;i++) + { + debug_log("updated custom-eq [%d] = %d", i, player->audio_effect_info.custom_eq_level[i]); + } - /* SPEAKER case */ - if (device_out == MM_SOUND_DEVICE_OUT_SPEAKER) - { - output_type = MM_AUDIO_EFFECT_OUTPUT_SPK; - if (__mmplayer_is_earphone_only_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, 0)) - { - debug_error("earphone is not equipped, some custom effect should operate with earphone"); - debug_fleave(); - return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS; - } - } - /* Other case, include WIRED_ACCESSORY, BLUETOOTH, DOCK */ - else - { - output_type = MM_AUDIO_EFFECT_OUTPUT_EAR; - } + /* get custom ext effect */ - /* set filter output mode as SPEAKER or EARPHONE */ - g_object_set(audio_effect_element, "filter-output-mode", output_type, NULL); - debug_log("filter-output-mode = %d (0:spk,1:ear)", output_type); + g_object_get(audio_effect_element, "custom-ext", &custom_ext_effect_level_list, NULL); - result = __mmplayer_set_harmony_effect(player, audio_effect_element); - if ( result ) + while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM ) + { + if ( player->ini.audio_effect_custom_list[count] ) { - debug_error("_set_harmony_effect() failed(%x)", result); - debug_fleave(); - return result; + player->audio_effect_info.custom_ext_level[count-1] + = custom_ext_effect_level_list[ext_level_index]; + debug_log("updated custom-ext [%d] = %d", count, player->audio_effect_info.custom_ext_level[count-1]); + ext_level_index++; } + count++; } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -461,7 +549,7 @@ mm_player_audio_effect_custom_clear_eq_all(MMHandleType hplayer) int result = MM_ERROR_NONE; mm_player_t* player = (mm_player_t*)hplayer; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); @@ -470,7 +558,7 @@ mm_player_audio_effect_custom_clear_eq_all(MMHandleType hplayer) debug_msg("All the EQ bands clearing success"); - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -483,7 +571,7 @@ mm_player_audio_effect_custom_clear_ext_all(MMHandleType hplayer) int result = MM_ERROR_NONE; mm_player_t* player = (mm_player_t*)hplayer; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); @@ -495,7 +583,7 @@ mm_player_audio_effect_custom_clear_ext_all(MMHandleType hplayer) debug_msg("All the extension effects clearing success"); - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -507,16 +595,16 @@ mm_player_is_supported_preset_effect_type(MMHandleType hplayer, MMAudioEffectPre mm_player_t* player = (mm_player_t*)hplayer; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_PRESET, effect ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_PRESET, effect ) ) { result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -528,80 +616,40 @@ mm_player_is_supported_custom_effect_type(MMHandleType hplayer, MMAudioEffectCus mm_player_t* player = (mm_player_t*)hplayer; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, effect ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect ) ) { result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } - -int -mm_player_audio_effect_preset_apply(MMHandleType hplayer, MMAudioEffectPresetType type) -{ - mm_player_t* player = (mm_player_t*)hplayer; - int result = MM_ERROR_NONE; - - debug_fenter(); - - return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - - if (!PLAYER_INI()->use_audio_effect_preset) - { - debug_error("audio effect(preset) is not supported", type); - debug_fleave(); - return MM_ERROR_NOT_SUPPORT_API; - } - - if (type < MM_AUDIO_EFFECT_PRESET_AUTO || type >= MM_AUDIO_EFFECT_PRESET_NUM) - { - debug_error("out of range, type(%d)", type); - debug_fleave(); - return MM_ERROR_INVALID_ARGUMENT; - } - - /* check if this effect type is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_PRESET, type ) ) - { - debug_fleave(); - return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; - } - - result = _mmplayer_audio_effect_preset_apply(player, type); - - debug_fleave(); - - return result; -} - - int mm_player_audio_effect_custom_apply(MMHandleType hplayer) { mm_player_t* player = (mm_player_t*)hplayer; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - if (!PLAYER_INI()->use_audio_effect_custom) + if (!player->ini.use_audio_effect_custom) { debug_error("audio effect(custom) is not supported"); - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_NOT_SUPPORT_API; } result = _mmplayer_audio_effect_custom_apply(player); - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -614,23 +662,22 @@ mm_player_audio_effect_bypass (MMHandleType hplayer) int result = MM_ERROR_NONE; GstElement *audio_effect_element = NULL; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - if ( !PLAYER_INI()->use_audio_effect_preset && !PLAYER_INI()->use_audio_effect_custom ) + if ( !player->ini.use_audio_effect_preset && !player->ini.use_audio_effect_custom ) { debug_error("audio effect(preset/custom) is not supported"); - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_NOT_SUPPORT_API; } - if ( !player->pipeline || !player->pipeline->audiobin ) + if ( !player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst ) { debug_warning("effect element is not created yet."); } else { - return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED ); audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst; /* order action to audio effect plugin */ @@ -638,7 +685,7 @@ mm_player_audio_effect_bypass (MMHandleType hplayer) debug_log("filter-action = %d", MM_AUDIO_EFFECT_TYPE_NONE); } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -653,30 +700,30 @@ _mmplayer_audio_effect_custom_set_level_ext(mm_player_t *player, MMAudioEffectCu int ext_level_index = 1; /* start from 1, because of excepting eq index */ int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if EQ is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, custom_effect_type ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, custom_effect_type ) ) { - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM ) { - if ( PLAYER_INI()->audio_effect_custom_list[count] ) + if ( player->ini.audio_effect_custom_list[count] ) { if ( count == custom_effect_type ) { - effect_level_min = PLAYER_INI()->audio_effect_custom_min_level_list[ext_level_index]; - effect_level_max = PLAYER_INI()->audio_effect_custom_max_level_list[ext_level_index]; + effect_level_min = player->ini.audio_effect_custom_min_level_list[ext_level_index]; + effect_level_max = player->ini.audio_effect_custom_max_level_list[ext_level_index]; debug_msg("level min value(%d), level max value(%d)", effect_level_min, effect_level_max); break; } ext_level_index++; - if (ext_level_index == PLAYER_INI()->audio_effect_custom_ext_num + 1) + if (ext_level_index == player->ini.audio_effect_custom_ext_num + 1) { debug_error("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin"); break; @@ -696,7 +743,7 @@ _mmplayer_audio_effect_custom_set_level_ext(mm_player_t *player, MMAudioEffectCu debug_msg("set ext[%d] = %d", custom_effect_type-1, level); } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -709,26 +756,26 @@ _mmplayer_audio_effect_custom_set_level_eq(mm_player_t *player, int index, int l gint eq_level_min = 0; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if EQ is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) { - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } - if ( index < 0 || index > PLAYER_INI()->audio_effect_custom_eq_band_num - 1 ) + if ( index < 0 || index > player->ini.audio_effect_custom_eq_band_num - 1 ) { debug_error("out of range, index(%d)", index); result = MM_ERROR_INVALID_ARGUMENT; } else { - eq_level_min = PLAYER_INI()->audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; - eq_level_max = PLAYER_INI()->audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; + eq_level_min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; + eq_level_max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; debug_msg("EQ level min value(%d), EQ level max value(%d)", eq_level_min, eq_level_max); if ( level < eq_level_min || level > eq_level_max ) @@ -743,7 +790,7 @@ _mmplayer_audio_effect_custom_set_level_eq(mm_player_t *player, int index, int l } } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -756,12 +803,12 @@ mm_player_audio_effect_custom_set_level(MMHandleType hplayer, MMAudioEffectCusto mm_player_t* player = (mm_player_t*)hplayer; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if this effect type is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, effect_custom_type ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect_custom_type ) ) { result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } @@ -771,7 +818,7 @@ mm_player_audio_effect_custom_set_level(MMHandleType hplayer, MMAudioEffectCusto { result = _mmplayer_audio_effect_custom_set_level_eq(player, eq_index, level); } - else if (effect_custom_type > MM_AUDIO_EFFECT_CUSTOM_EQ || effect_custom_type < MM_AUDIO_EFFECT_CUSTOM_NUM) + else if (effect_custom_type > MM_AUDIO_EFFECT_CUSTOM_EQ && effect_custom_type < MM_AUDIO_EFFECT_CUSTOM_NUM) { result = _mmplayer_audio_effect_custom_set_level_ext(player, effect_custom_type, level); } @@ -782,7 +829,7 @@ mm_player_audio_effect_custom_set_level(MMHandleType hplayer, MMAudioEffectCusto } } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -794,21 +841,21 @@ mm_player_audio_effect_custom_get_eq_bands_number(MMHandleType hplayer, int *ban mm_player_t* player = (mm_player_t*)hplayer; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if EQ is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) { - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } - *bands = PLAYER_INI()->audio_effect_custom_eq_band_num; + *bands = player->ini.audio_effect_custom_eq_band_num; debug_log("number of custom EQ band = %d", *bands); - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -821,18 +868,18 @@ mm_player_audio_effect_custom_get_eq_bands_width(MMHandleType hplayer, int band_ int result = MM_ERROR_NONE; unsigned int eq_num = 0; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if EQ is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) { - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } - eq_num = PLAYER_INI()->audio_effect_custom_eq_band_num; + eq_num = player->ini.audio_effect_custom_eq_band_num; if (band_idx < 0 || band_idx > eq_num-1) { debug_error("out of range, invalid band_idx(%d)", band_idx); @@ -841,11 +888,11 @@ mm_player_audio_effect_custom_get_eq_bands_width(MMHandleType hplayer, int band_ else { /* set the width of EQ band */ - *width = PLAYER_INI()->audio_effect_custom_eq_band_width[band_idx]; + *width = player->ini.audio_effect_custom_eq_band_width[band_idx]; debug_log("width of band_idx(%d) = %dHz", band_idx, *width); } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -858,18 +905,18 @@ mm_player_audio_effect_custom_get_eq_bands_freq(MMHandleType hplayer, int band_i int result = MM_ERROR_NONE; unsigned int eq_num = 0; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if EQ is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) { - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } - eq_num = PLAYER_INI()->audio_effect_custom_eq_band_num; + eq_num = player->ini.audio_effect_custom_eq_band_num; if (band_idx < 0 || band_idx > eq_num-1) { debug_error("out of range, invalid band_idx(%d)", band_idx); @@ -878,11 +925,11 @@ mm_player_audio_effect_custom_get_eq_bands_freq(MMHandleType hplayer, int band_i else { /* set the frequency of EQ band */ - *freq = PLAYER_INI()->audio_effect_custom_eq_band_freq[band_idx]; + *freq = player->ini.audio_effect_custom_eq_band_freq[band_idx]; debug_log("frequency of band_idx(%d) = %dHz", band_idx, *freq); } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -894,21 +941,21 @@ mm_player_audio_effect_custom_get_level(MMHandleType hplayer, MMAudioEffectCusto mm_player_t* player = (mm_player_t*)hplayer; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); return_val_if_fail( level, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if this effect type is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) ) { - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } if (type == MM_AUDIO_EFFECT_CUSTOM_EQ) { - if ( eq_index < 0 || eq_index > PLAYER_INI()->audio_effect_custom_eq_band_num - 1 ) + if ( eq_index < 0 || eq_index > player->ini.audio_effect_custom_eq_band_num - 1 ) { debug_error("out of range, EQ index(%d)", eq_index); result = MM_ERROR_INVALID_ARGUMENT; @@ -930,7 +977,7 @@ mm_player_audio_effect_custom_get_level(MMHandleType hplayer, MMAudioEffectCusto result = MM_ERROR_INVALID_ARGUMENT; } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -944,40 +991,40 @@ mm_player_audio_effect_custom_get_level_range(MMHandleType hplayer, MMAudioEffec int count = 1; /* start from 1, because of excepting eq index */ int ext_level_index = 1; /* start from 1, because of excepting eq index */ - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); return_val_if_fail( min, MM_ERROR_PLAYER_NOT_INITIALIZED ); return_val_if_fail( max, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if this effect type is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) ) { - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } if ( type == MM_AUDIO_EFFECT_CUSTOM_EQ ) { - *min = PLAYER_INI()->audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; - *max = PLAYER_INI()->audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; + *min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; + *max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; debug_log("EQ min level = %d, max level = %d", *min, *max); } else { while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM ) { - if ( PLAYER_INI()->audio_effect_custom_list[count] ) + if ( player->ini.audio_effect_custom_list[count] ) { if ( count == type ) { - *min = PLAYER_INI()->audio_effect_custom_min_level_list[ext_level_index]; - *max = PLAYER_INI()->audio_effect_custom_max_level_list[ext_level_index]; + *min = player->ini.audio_effect_custom_min_level_list[ext_level_index]; + *max = player->ini.audio_effect_custom_max_level_list[ext_level_index]; debug_msg("Extension effect(%d) min level = %d, max level = %d", count, *min, *max); break; } ext_level_index++; - if ( ext_level_index == PLAYER_INI()->audio_effect_custom_ext_num + 1 ) + if ( ext_level_index == player->ini.audio_effect_custom_ext_num + 1 ) { debug_error("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin"); break; @@ -987,7 +1034,7 @@ mm_player_audio_effect_custom_get_level_range(MMHandleType hplayer, MMAudioEffec } } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; } @@ -1002,26 +1049,26 @@ mm_player_audio_effect_custom_set_level_eq_from_list(MMHandleType hplayer, int * gint eq_level_max = 0; int result = MM_ERROR_NONE; - debug_fenter(); + MMPLAYER_FENTER(); return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); /* check if EQ is supported */ - if ( !_mmplayer_is_supported_effect_type( MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) + if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) ) { - debug_fleave(); + MMPLAYER_FLEAVE(); return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER; } - if ( size != PLAYER_INI()->audio_effect_custom_eq_band_num ) + if ( size != player->ini.audio_effect_custom_eq_band_num ) { - debug_error("input size variable(%d) does not match with number of eq band(%d)", size, PLAYER_INI()->audio_effect_custom_eq_band_num); + debug_error("input size variable(%d) does not match with number of eq band(%d)", size, player->ini.audio_effect_custom_eq_band_num); result = MM_ERROR_INVALID_ARGUMENT; } else { - eq_level_min = PLAYER_INI()->audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; - eq_level_max = PLAYER_INI()->audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; + eq_level_min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; + eq_level_max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ]; for ( i = 0 ; i < size ; i++ ) { @@ -1034,7 +1081,7 @@ mm_player_audio_effect_custom_set_level_eq_from_list(MMHandleType hplayer, int * player->audio_effect_info.custom_eq_level[i] = level_list[i]; } } - debug_fleave(); + MMPLAYER_FLEAVE(); return result; }