static ASM_sound_events_t __mmplayer_asm_get_event_type(gint type);
-gint mmplayer_asm_register(MMPlayerASM* sm, ASM_sound_cb_t callback, void* param)
+gint
+_mmplayer_asm_register(MMPlayerASM* sm, ASM_sound_cb_t callback, void* param)
{
/* read mm-session type */
gint sessionType = MM_SESSION_TYPE_SHARE;
return MM_ERROR_NONE;
}
-gint mmplayer_asm_deregister(MMPlayerASM* sm)
+gint
+_mmplayer_asm_deregister(MMPlayerASM* sm)
{
gint event_type = ASM_EVENT_NONE;
gint errorcode = 0;
{
debug_log("no pid has assigned. using default(current) context\n");
}
-#if 0
- /* read session type */
- errorcode = _mm_session_util_read_type(pid, &sessionType);
- if ( errorcode )
- {
- debug_error("MMSessionReadType Fail %s\n",__func__);
- return MM_ERROR_POLICY_INTERNAL;
- }
-
- /* check if it's CALL */
- if ( sessionType == MM_SESSION_TYPE_CALL || sessionType == MM_SESSION_TYPE_VIDEOCALL )
- {
- debug_log("session type is VOICE or VIDEO CALL (%d)\n", sessionType);
- return MM_ERROR_NONE;
- }
- /* interpret session type */
- event_type = __mmplayer_asm_get_event_type(sessionType);
-#else
/* check if it's CALL */
if(sm->event == ASM_EVENT_CALL || sm->event == ASM_EVENT_VIDEOCALL)
{
return MM_ERROR_NONE;
}
event_type = sm->event;
-#endif
+
if( ! ASM_unregister_sound( sm->handle, event_type, &errorcode) )
{
debug_error("Unregister sound failed 0x%X\n", errorcode);
return MM_ERROR_NONE;
}
-gint mmplayer_asm_set_state(MMHandleType hplayer, ASM_sound_states_t state)
+gint _mmplayer_asm_set_state(MMHandleType hplayer, ASM_sound_states_t state)
{
gint event_type = ASM_EVENT_NONE;
gint pid = -1;
{
debug_log("no pid has assigned. using default(current) context\n");
}
-#if 0
- /* read session type */
- errorcode = _mm_session_util_read_type(pid, &sessionType);
- if ( errorcode )
- {
- debug_error("MMSessionReadType Fail\n");
- return MM_ERROR_POLICY_INTERNAL;
- }
/* check if it's CALL */
- if ( sessionType == MM_SESSION_TYPE_CALL || sessionType == MM_SESSION_TYPE_VIDEOCALL)
- {
- debug_log("session type is VOICE or VIDEO CALL (%d)\n", sessionType);
- return MM_ERROR_NONE;
- }
-#else
- /* check if it's CALL */
if(sm->event == ASM_EVENT_CALL || sm->event == ASM_EVENT_VIDEOCALL)
{
debug_log("session type is VOICE or VIDEO CALL (%d)\n", sm->event);
return MM_ERROR_NONE;
}
-#endif
if ( ! sm->by_asm_cb )//|| sm->state == ASM_STATE_PLAYING )
{
int ret = 0;
-
-#if 0
- event_type = __mmplayer_asm_get_event_type(sessionType);
-#else
event_type = sm->event;
-#endif
+
/* check if there is video */
/* NOTE: resource can be set as NONE when it's not occupied or unknown resource is used. */
if(ASM_STATE_PLAYING == state || ASM_STATE_PAUSE == state)
{
if(player->pipeline && player->pipeline->videobin)
- //resource = ASM_RESOURCE_VIDEO_OVERLAY | ASM_RESOURCE_HW_DECODER;
- resource = ASM_RESOURCE_VIDEO_OVERLAY | ASM_RESOURCE_HW_DECODER;
+ resource = ASM_RESOURCE_VIDEO_OVERLAY | ASM_RESOURCE_HW_DECODER;
}
if( ! ASM_set_sound_state( sm->handle, event_type, state, resource, &ret) )
return MM_ERROR_NONE;
}
-
-ASM_sound_events_t __mmplayer_asm_get_event_type(gint type)
+static ASM_sound_events_t
+__mmplayer_asm_get_event_type(gint type)
{
gint event_type = ASM_EVENT_NONE;
{
if (player->cmd == MMPLAYER_COMMAND_STOP)
{
- asm_result = mmplayer_asm_set_state((MMHandleType)player, ASM_STATE_STOP);
+ asm_result = _mmplayer_asm_set_state((MMHandleType)player, ASM_STATE_STOP);
if ( asm_result != MM_ERROR_NONE )
{
debug_error("failed to set asm state to stop\n");
if ( ! player->audio_cb_probe_id && player->is_sound_extraction )
__mmplayer_configure_audio_callback(player);
- asm_result = mmplayer_asm_set_state((MMHandleType)player, ASM_STATE_PAUSE);
+ asm_result = _mmplayer_asm_set_state((MMHandleType)player, ASM_STATE_PAUSE);
if ( asm_result )
{
debug_error("failed to set asm state to PAUSE\n");
/* update video resource status */
if ( ( player->can_support_codec & 0x02) == FOUND_PLUGIN_VIDEO )
{
- asm_result = mmplayer_asm_set_state((MMHandleType)player, ASM_STATE_PLAYING);
+ asm_result = _mmplayer_asm_set_state((MMHandleType)player, ASM_STATE_PLAYING);
if ( asm_result )
{
MMMessageParamType msg = {0, };
return FALSE;
}
ASM_cb_result_t
-player_asm_callback(int handle, ASM_event_sources_t event_src, ASM_sound_commands_t command, unsigned int sound_status, void* cb_data)
+__mmplayer_asm_callback(int handle, ASM_event_sources_t event_src, ASM_sound_commands_t command, unsigned int sound_status, void* cb_data)
{
mm_player_t* player = (mm_player_t*) cb_data;
- ASM_cb_result_t cb_res = ASM_CB_RES_IGNORE;
+ ASM_cb_result_t cb_res = ASM_CB_RES_IGNORE;
MMHandleType attrs = 0;
int result = MM_ERROR_NONE;
- int flag = 0;
debug_fenter();
- return_val_if_fail ( player, ASM_CB_RES_IGNORE );
+ return_val_if_fail ( player && player->pipeline, ASM_CB_RES_IGNORE );
+ return_val_if_fail ( player->attrs, MM_ERROR_PLAYER_INTERNAL );
if (player->is_sound_extraction)
{
return result;
}
- attrs = MMPLAYER_GET_ATTRS(player);
- if ( !attrs )
- {
- debug_error("cannot get content attribute\n");
- return MM_ERROR_PLAYER_INTERNAL;
- }
-
- mm_attrs_get_int_by_name(attrs, "sound_stop_when_unplugged", &flag);
+ player->sm.by_asm_cb = 1; // it should be enabled for player state transition with called application command
+ player->sm.event_src = event_src;
- player->sm.by_asm_cb = 1;
if(event_src == ASM_EVENT_SOURCE_OTHER_PLAYER_APP)
+ {
player->sm.event_src = ASM_EVENT_SOURCE_OTHER_APP;
- else
- player->sm.event_src = event_src;
-
- if(event_src == ASM_EVENT_SOURCE_EARJACK_UNPLUG)
+ }
+ else if(event_src == ASM_EVENT_SOURCE_EARJACK_UNPLUG )
{
- if ( !flag )
+ int stop_by_asm = 0;
+
+ mm_attrs_get_int_by_name(player->attrs, "sound_stop_when_unplugged", &stop_by_asm);
+ if (!stop_by_asm)
return cb_res;
}
else if (event_src == ASM_EVENT_SOURCE_RESOURCE_CONFLICT)
{
- if(player->pipeline)
+ /* can use video overlay simultaneously */
+ /* video resource conflict */
+ if(player->pipeline->videobin)
{
- /* can use video overlay simultaneously */
- /* video resource conflict */
- if(player->pipeline->videobin) {
- if (PLAYER_INI()->multiple_codec_supported)
- {
- debug_log("video conflict but, can support to use video overlay simultaneously\n");
- result = _mmplayer_pause((MMHandleType)player);
- cb_res = ASM_CB_RES_PAUSE;
- }
- else
- {
- debug_log("video conflict, can't support for multiple codec instance\n");
- result = _mmplayer_unrealize((MMHandleType)player);
- cb_res = ASM_CB_RES_STOP;
- }
+ if (PLAYER_INI()->multiple_codec_supported)
+ {
+ debug_log("video conflict but, can support to use video overlay simultaneously");
+ result = _mmplayer_pause((MMHandleType)player);
+ cb_res = ASM_CB_RES_PAUSE;
+ }
+ else
+ {
+ debug_log("video conflict, can't support for multiple codec instance");
+ result = _mmplayer_unrealize((MMHandleType)player);
+ cb_res = ASM_CB_RES_STOP;
}
}
- else
- debug_log("No pipeline!!!!\n");
-
return cb_res;
}
switch(command)
{
+ case ASM_COMMAND_PLAY:
case ASM_COMMAND_STOP:
- debug_log("Got msg from asm to Stop\n");
- result = _mmplayer_stop((MMHandleType) player);
-
- player->sm.by_asm_cb = 1;
- result = _mmplayer_unrealize((MMHandleType)player);
-
- cb_res = ASM_CB_RES_STOP;
- break;
-
+ debug_warning ("Got unexpected asm command (%d)", command);
+ break;
+
case ASM_COMMAND_PAUSE:
{
- debug_log("Got msg from asm to Pause\n");
- if(event_src == ASM_EVENT_SOURCE_CALL_START || event_src == ASM_EVENT_SOURCE_ALARM_START
- || event_src == ASM_EVENT_SOURCE_OTHER_APP)
+ debug_log("Got msg from asm to Pause");
+
+ if(event_src == ASM_EVENT_SOURCE_CALL_START
+ || event_src == ASM_EVENT_SOURCE_ALARM_START
+ || event_src == ASM_EVENT_SOURCE_OTHER_APP)
{
//hold 0.7 second to excute "fadedown mute" effect
- debug_log ("do fade down->pause->undo fade down\n");
+ debug_log ("do fade down->pause->undo fade down");
__mmplayer_do_sound_fadedown(player, MM_PLAYER_FADEOUT_TIME_DEFAULT);
result = _mmplayer_pause((MMHandleType)player);
- if (result != MM_ERROR_NONE) {
- debug_warning("fail to set Pause state.\n");
+ if (result != MM_ERROR_NONE)
+ {
+ debug_warning("fail to set Pause state by asm");
cb_res = ASM_CB_RES_IGNORE;
break;
- }
-
+ }
__mmplayer_undo_sound_fadedown(player);
}
- else if(event_src == ASM_EVENT_SOURCE_OTHER_PLAYER_APP) {
+ else if(event_src == ASM_EVENT_SOURCE_OTHER_PLAYER_APP)
+ {
if ( player->pipeline->audiobin && player->pipeline->audiobin[MMPLAYER_A_SINK].gst )
g_object_set( player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "mute", 2, NULL);
+
player->lazy_pause_event_id = g_timeout_add(LAZY_PAUSE_TIMEOUT_MSEC, (GSourceFunc)_asm_lazy_pause, (gpointer)player);
- debug_log ("set lazy pause timer (id=[%d], timeout=[%d ms])\n", player->lazy_pause_event_id, LAZY_PAUSE_TIMEOUT_MSEC);
- }
- else {
+ debug_log ("set lazy pause timer (id=[%d], timeout=[%d ms])", player->lazy_pause_event_id, LAZY_PAUSE_TIMEOUT_MSEC);
+ }
+ else
+ {
//immediate pause
- debug_log ("immediate pause\n");
+ debug_log ("immediate pause");
result = _mmplayer_pause((MMHandleType)player);
}
cb_res = ASM_CB_RES_PAUSE;
- break;
}
-
- case ASM_COMMAND_PLAY:
- debug_log("Got msg from asm to Play\n");
- result = _mmplayer_start((MMHandleType)player);
- cb_res = ASM_CB_RES_PLAYING;
- break;
+ break;
case ASM_COMMAND_RESUME:
{
//ASM server is single thread daemon. So use g_idle_add() to post resume msg
g_idle_add((GSourceFunc)_asm_postmsg, (gpointer)player);
cb_res = ASM_CB_RES_IGNORE;
- break;
- }
-
+ }
+ break;
+
default:
- break;
+ break;
}
+ player->sm.by_asm_cb = 0;
debug_fleave();
return cb_res;
}
/* register to asm */
- if ( MM_ERROR_NONE != mmplayer_asm_register(&player->sm, (ASM_sound_cb_t)player_asm_callback, (void*)player) )
+ if ( MM_ERROR_NONE != _mmplayer_asm_register(&player->sm, (ASM_sound_cb_t)__mmplayer_asm_callback, (void*)player) )
{
/* NOTE : we are dealing it as an error since we cannot expect it's behavior */
debug_error("failed to register asm server\n");
}
/* withdraw asm */
- if ( MM_ERROR_NONE != mmplayer_asm_deregister(&player->sm) )
+ if ( MM_ERROR_NONE != _mmplayer_asm_deregister(&player->sm) )
{
debug_error("failed to deregister asm server\n");
return MM_ERROR_PLAYER_INTERNAL;
/* set player state if success */
if ( MM_ERROR_NONE == ret )
{
- ret = mmplayer_asm_set_state(hplayer, ASM_STATE_STOP);
+ ret = _mmplayer_asm_set_state(hplayer, ASM_STATE_STOP);
if ( ret )
{
debug_error("failed to set asm state to STOP\n");
/* check current state */
MMPLAYER_CHECK_STATE_RETURN_IF_FAIL( player, MMPLAYER_COMMAND_START );
- ret = mmplayer_asm_set_state(hplayer, ASM_STATE_PLAYING);
+ ret = _mmplayer_asm_set_state(hplayer, ASM_STATE_PLAYING);
if ( ret != MM_ERROR_NONE )
{
debug_error("failed to set asm state to PLAYING\n");
return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
- ret = mmplayer_asm_set_state(hplayer, ASM_STATE_PLAYING);
+ ret = _mmplayer_asm_set_state(hplayer, ASM_STATE_PLAYING);
if ( ret )
{
debug_error("failed to set asm state to PLAYING\n");
_mmplayer_deactivate_section_repeat(MMHandleType hplayer)
{
mm_player_t* player = (mm_player_t*)hplayer;
- gint64 cur_pos = 0L;
+ gint64 cur_pos = 0;
GstFormat fmt = GST_FORMAT_TIME;
gint onetime = 1;