From 695aab2eba856bc1fe31389ab593402a92409954 Mon Sep 17 00:00:00 2001 From: KeeBum Kim Date: Fri, 24 Aug 2012 20:23:14 +0900 Subject: [PATCH] Fix Sound alert and repetition. --- framework/main.cpp | 3 ++- include/utils/MsgSoundPlayer.h | 1 + msg_helper/MsgSoundPlayer.cpp | 25 ++++++++++++++++---- utils/MsgSoundPlayer.cpp | 52 ++++++++++++++++++++++++++++++++++++++---- 4 files changed, 71 insertions(+), 10 deletions(-) diff --git a/framework/main.cpp b/framework/main.cpp index 943a7e6..0fd8b76 100755 --- a/framework/main.cpp +++ b/framework/main.cpp @@ -356,7 +356,8 @@ void* InitMsgServer(void*) // Register Callback to get the change of contact MsgInitContactSvc(&MsgContactChangedCallback); - MsgSoundPlayStart(); + MsgSoundInitRepeatAlarm(); + return (void*)0; } diff --git a/include/utils/MsgSoundPlayer.h b/include/utils/MsgSoundPlayer.h index 37eea6d..ce690e8 100755 --- a/include/utils/MsgSoundPlayer.h +++ b/include/utils/MsgSoundPlayer.h @@ -37,5 +37,6 @@ bool MsgSoundSetRepeatAlarm(); bool MsgSoundCreateRepeatAlarm(int RepeatTime); int MsgSoundRepeatAlarmCB(int TimerId, void *pUserParam); int MsgSoundGetUnreadMsgCnt(); +void MsgSoundInitRepeatAlarm(); #endif // MSG_SOUND_PLAYER_H diff --git a/msg_helper/MsgSoundPlayer.cpp b/msg_helper/MsgSoundPlayer.cpp index d0a3ce6..10da84f 100755 --- a/msg_helper/MsgSoundPlayer.cpp +++ b/msg_helper/MsgSoundPlayer.cpp @@ -47,6 +47,25 @@ pthread_cond_t cvMmPlay = PTHREAD_COND_INITIALIZER; /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ + +static gboolean MsgStopAndExit(void* data) +{ + MsgSoundPlayStop(); + if(!bPlaying && !bVibrating) + worker_done(); + + return FALSE; +} + +static gboolean MsgUninitAndExit(void* data) +{ + MsgSoundPlayUninit(); + if(!bPlaying && !bVibrating) + worker_done(); + + return FALSE; +} + static gboolean MsgSoundMelodyTimeout(gpointer data) { MSG_BEGIN(); @@ -98,7 +117,7 @@ static int MsgSoundPlayCallback(int message, void *param, void *user_param) { case MM_MESSAGE_ERROR: MSG_DEBUG("ERROR is happened."); - MsgSoundPlayUninit(); + g_idle_add (MsgUninitAndExit, NULL); break; case MM_MESSAGE_BEGIN_OF_STREAM: MSG_DEBUG("Play is started."); @@ -106,9 +125,7 @@ static int MsgSoundPlayCallback(int message, void *param, void *user_param) case MM_MESSAGE_END_OF_STREAM: case MM_MESSAGE_STATE_INTERRUPTED: MSG_DEBUG("EOS or Interrupted."); - MsgSoundPlayStop(); - if(!bPlaying && !bVibrating) - worker_done(); + g_idle_add (MsgStopAndExit, NULL); break; default: MSG_DEBUG("message = %d", message); diff --git a/utils/MsgSoundPlayer.cpp b/utils/MsgSoundPlayer.cpp index 2225961..15fd2f0 100755 --- a/utils/MsgSoundPlayer.cpp +++ b/utils/MsgSoundPlayer.cpp @@ -52,12 +52,8 @@ void MsgSoundPlayStart() if (childpid == 0) { MSG_DEBUG("Child Process - Run helper app for Sound"); - int nRepeatValue = 0; - nRepeatValue = MsgSettingGetInt(MSG_ALERT_TONE); - - if(nRepeatValue != MSG_ALERT_TONE_ONCE) - execl("/usr/bin/msg-helper", MSG_SOUND_START, NULL); + execl("/usr/bin/msg-helper", MSG_SOUND_START, NULL); MSG_DEBUG("Faild to run helper app for Sound"); @@ -259,3 +255,49 @@ int MsgSoundGetUnreadMsgCnt() return unreadCnt; } +void MsgSoundInitRepeatAlarm() +{ + MSG_BEGIN(); + + int nRepeatValue = 0; + long nRepeatTime = 0; + + g_bRepeat = false; + + if (MsgSoundGetUnreadMsgCnt() <= 0) { + MSG_DEBUG("no unread msg"); + return; + } + + nRepeatValue = MsgSettingGetInt(MSG_ALERT_TONE); + + switch (nRepeatValue) + { + case MSG_ALERT_TONE_ONCE: + nRepeatTime = 0; + break; + + case MSG_ALERT_TONE_2MINS: + nRepeatTime = 2; + break; + + case MSG_ALERT_TONE_5MINS: + nRepeatTime = 5; + break; + + case MSG_ALERT_TONE_10MINS: + nRepeatTime = 10; + break; + + default: + MSG_DEBUG("Invalid Repetition time"); + break; + } + + MSG_DEBUG("nRepeatTime = %d", nRepeatTime); + + if (nRepeatTime > 0) + MsgSoundPlayStart(); + + MSG_END(); +} -- 2.7.4