📄 voice.c
字号:
/* INPUTS: voiceHandle - Voice 句柄 */
/* OUTPUTS: NONE */
/* RETURN: 设置成功则返回TRUE,否则返回FALSE */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* HuangXM 2003-06-19 创建 */
/****************************************************************************/
BOOL VoicePlay(VoiceHandle voiceHandle)
{
if(g_VoiceStatus != VOICE_STATUS_STOP)
return FALSE;
__VoiceTaskReset();
__VoiceSendCommand(voiceHandle, VOICE_COMMAND_PLAY, 0, 0);
if(g_VoiceStatus == VOICE_STATUS_PLAY)
return TRUE;
else
return FALSE;
}
BOOL VoicePause(VoiceHandle voiceHandle)
{
if(g_VoiceStatus != VOICE_STATUS_PLAY)
return FALSE;
__VoiceSendCommand(voiceHandle, VOICE_COMMAND_PAUSE, 0, 0);
if(g_VoiceStatus == VOICE_STATUS_PLAYPAUSE)
return TRUE;
else
return FALSE;
}
/****************************************************************************/
/* FUNCTION: VoiceResume */
/* DESCRIPTION:继续播放 */
/* INPUTS: voiceHandle - Voice 句柄 */
/* OUTPUTS: NONE */
/* RETURN: 设置成功则返回TRUE,否则返回FALSE */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* HuangXM 2003-06-19 创建 */
/****************************************************************************/
BOOL VoiceResume(VoiceHandle voiceHandle)
{
if(g_VoiceStatus != VOICE_STATUS_PLAYPAUSE)
return FALSE;
__VoiceSendCommand(voiceHandle, VOICE_COMMAND_RESUME, 0, 0);
if(g_VoiceStatus == VOICE_STATUS_PLAY)
return TRUE;
else
return FALSE;
}
BOOL VoicePlayStop(VoiceHandle voiceHandle)
{
return VoiceClose(voiceHandle);
}
BOOL VoiceStop(VoiceHandle voiceHandle)
{
__VoiceSendCommand(voiceHandle, VOICE_COMMAND_STOP, VOICE_NOTIFY_NONE, 0);
if(g_VoiceStatus == VOICE_STATUS_STOP)
return TRUE;
else
return FALSE;
}
/****************************************************************************/
/* FUNCTION: VoiceClose */
/* DESCRIPTION:停止播放 */
/* INPUTS: voiceHandle - Voice 句柄 */
/* OUTPUTS: NONE */
/* RETURN: 设置成功则返回TRUE,否则返回FALSE */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* HuangXM 2003-06-19 创建 */
/****************************************************************************/
BOOL VoiceClose(VoiceHandle voiceHandle)
{
//参数NULL表示针对当前声音句柄
if(voiceHandle == NULL)
{
/* VoiceListPlayParam mpPlayParam;
//关闭后台播放
if(VoiceListPlayParamGet(&mpPlayParam) == TRUE)
VoiceListClose();
//关闭普通声音
else
__VoiceSendCommand(g_VoiceHandle, VOICE_COMMAND_CLOSE, 0, 0);
*/
return TRUE;
}
if(voiceHandle != g_VoiceHandle)
return FALSE;
__VoiceSendCommand(voiceHandle, VOICE_COMMAND_CLOSE, 0, 0);
//继续后台播放
if(g_VoicePlayParam.bListSuspend == TRUE)
VoiceListContinue();
if(g_VoiceStatus == VOICE_STATUS_STOP)
return TRUE;
else
return FALSE;
}
VoiceHandle VoicePlayStart(MVoicePlayParam *pVoicePlayParam)
{
VoiceHandle hVoice;
pVoicePlayParam->playMode |= VOICE_MODE_AUTOCLOSE;
hVoice = VoiceOpen(pVoicePlayParam);
if(hVoice == (VoiceHandle) -1)
return hVoice;
if(VoicePlay(hVoice) == TRUE)
return hVoice;
VoiceClose(hVoice);
return (VoiceHandle) -1;
}
BOOL VoiceCloseAll()
{
VoiceListClose();
return VoiceClose(g_VoiceHandle);
}
BOOL VoiceIsRun()
{
if((g_VoiceStatus == VOICE_STATUS_STOP) || (g_VoiceStatus == VOICE_STATUS_PLAYPAUSE))
return FALSE;
else
return TRUE;
}
/****************************************************************************/
/****************************************************************************/
//the following added by ju
//闹铃时,若果当前有播放声音,则闹铃响闹后原来的声音不会继续,
//故提供此借口。当闹铃时AP接收EVENT_ALARM消息,分别调用BackupCurrentVoice
//RestoreCurrentVoice来备份和恢复当前的声音
#ifdef BACKVOICE_FUNC
/****************************************************************************/
/* FUNCTION: BOOL BackupCurrentVoice(VOID ) */
/* DESCRIPTION:备份当前声音播放的资源 */
/* INPUTS: NONE */
/* OUTPUTS: NONE */
/* RETURN: 返回备份成功与否的标志,TURE为真 */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* Ju 2006-07-06 First Issue */
/****************************************************************************/
BOOL BackupCurrentVoice(VOID )
{
//备份播放
g_hVoiceHandleBk =(VoiceHandle) -1;
g_pVoiceListPlayParamBk = MemAlloc(sizeof( VoiceListPlayParam));
if(g_pVoiceListPlayParamBk == NULL)
{
g_nVoiceBkFlag = VOICE_BKFLAG_UNBACKUP;
return FALSE;
}
g_hVoiceHandleBk = g_VoiceHandle;
if(VoiceListPlayParamGet(g_pVoiceListPlayParamBk) == TRUE)
{
VoiceListSuspend();
g_nVoiceBkFlag = VOICE_BKFLAG_BK_PLAYLIST;
}
else if(g_VoiceStatus != VOICE_STATUS_STOP)
{
__VoiceSendCommand(g_hVoiceHandleBk, VOICE_COMMAND_PAUSE, 0, 0);
//VoiceGetParam(g_hVoiceHandleBk,(MVoicePlayParam*)g_pVoiceListPlayParamBk );
g_nVoiceBkFlag = VOICE_BKFLAG_BK_PLAY;
}
else
{
g_nVoiceBkFlag = VOICE_BKFLAG_UNBACKUP;
g_hVoiceHandleBk =(VoiceHandle) -1;
MemFree(g_pVoiceListPlayParamBk);
return FALSE;
}
return TRUE;
//关闭当前声音操作
__VoiceSendCommand(g_hVoiceHandleBk, VOICE_COMMAND_CLOSE, 0, 0);
if(g_VoiceStatus == VOICE_STATUS_STOP)
{
return TRUE;
}
else
{
g_nVoiceBkFlag = VOICE_BKFLAG_UNBACKUP;
g_hVoiceHandleBk =(VoiceHandle) -1;
MemFree(g_pVoiceListPlayParamBk);
return FALSE;
}
}
/****************************************************************************/
/* FUNCTION: BOOL RestoreCurrentVoice(VOID ) */
/* DESCRIPTION:恢复当前声音播放的资源,从上次中断的地方继续播放 */
/* INPUTS: NONE */
/* OUTPUTS: NONE */
/* RETURN: 返回恢复成功与否的标志,TURE为真 */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* Ju 2006-07-06 First Issue */
/****************************************************************************/
BOOL RestoreCurrentVoice(VOID )
{
//恢复播放
BOOL bRetFlag;
VoiceHandle hVoiceHandle;
bRetFlag = FALSE;
if( g_nVoiceBkFlag == VOICE_BKFLAG_UNBACKUP)
return TRUE;
//恢复播放列表
if( g_nVoiceBkFlag == VOICE_BKFLAG_BK_PLAYLIST)
{
VoiceListPlayParamSet(g_pVoiceListPlayParamBk,VOICE_LIST_SET_PLAYMOD|VOICE_LIST_SET_PLAYORDER
|VOICE_LIST_SET_PLAYOFFSET|VOICE_LIST_SET_CALLBACK);
VoiceListContinue();
bRetFlag = TRUE;
}
//恢复播放
else
{
__VoiceSendCommand(g_hVoiceHandleBk, VOICE_COMMAND_RESUME, 0, 0);
bRetFlag = TRUE;
/*
hVoiceHandle = VoiceOpen((MVoicePlayParam*)g_pVoiceListPlayParamBk);
if( hVoiceHandle == (VoiceHandle) -1)
{
bRetFlag =FALSE;
}
//恢复以前的句柄
g_VoiceHandle = g_hVoiceHandleBk;
memcpy((VOID*)&g_VoicePlayParam,(void*)g_pVoiceListPlayParamBk,sizeof(MVoicePlayParam) );
VoiceSetParam(g_hVoiceHandleBk,(MVoicePlayParam*)g_pVoiceListPlayParamBk );
__VoiceTaskReset();
__VoiceSendCommand(g_hVoiceHandleBk, VOICE_COMMAND_PLAY, 0, 0);
if(g_VoiceStatus == VOICE_STATUS_PLAY)
bRetFlag = TRUE;
else
bRetFlag = FALSE;
*/
}
MemFree(g_pVoiceListPlayParamBk);
g_pVoiceListPlayParamBk = NULL;
g_nVoiceBkFlag = VOICE_BKFLAG_UNBACKUP;
return bRetFlag;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -