📄 backgroundplaying.c
字号:
//========================================================================
// 文件名称: BackGroundPlaying.c
// 功能描述: S480后台播放的功能接口函数
// 维护记录: 2006-07-11 V1.0
//========================================================================
#include "bsrSD.h"
#include "s480.h"
#include "BackGroundPlaying.h"
#include "SPCE061A.h"
#include "InterruptStatus.h"
unsigned int g_PlayStatus;
//========================================================================
// 语法格式: void SetPlayService()
// 实现功能: 打开4096Hz时基中断,并设置R_InterruptStatus变量
// 参数: 无
// 返回值: 无
//========================================================================
void SetPlayService()
{
*P_INT_Clear = 0x0040;
*P_INT_Ctrl = *P_INT_Ctrl_New | 0x0040; // 打开4096时基中断
SetInterruptStatus(0x0040);
}
//========================================================================
// 语法格式: void ClearPlayService()
// 实现功能: 关闭4096Hz时基中断,并设置R_InterruptStatus变量
// 参数: 无
// 返回值: 无
//========================================================================
void ClearPlayService()
{
*P_INT_Clear = 0x0040;
*P_INT_Ctrl = *P_INT_Ctrl_New & (~0x0040); // 关闭4096时基中断
ClearInterruptStatus(0x0040);
}
//========================================================================
// 语法格式: void PlaySnd(unsigned int SndIndex, unsigned int Wait)
// 实现功能: 初始化并开始S480播放
// 参数: SndIndex - 语音资源序号
// Wait - 是否需要等待语音播放结束之后才退出函数
// 返回值: 无
//========================================================================
void PlaySnd(unsigned int SndIndex, unsigned int Wait)
{
#ifdef __BSRSD_H__
BSR_StopRecognizer();
#endif
ClearPlayService();
SACM_S480_Stop();
SACM_S480_Initial(1);
SACM_S480_Play(SndIndex, 3, 3);
g_PlayStatus = plPlaying;
SetPlayService();
if(Wait != 0)
{
while(g_PlayStatus != plNULL);
ClearPlayService();
}
}
//========================================================================
// 语法格式: void SetPlayStatus(unsigned int Status)
// 实现功能: 设置当前播放状态
// 参数: Status - 播放状态
// 可选值有:
// 播放结束(空闲状态):plNULL = 0
// 正在播放:plPlaying = 1
// 返回值: 无
//========================================================================
void SetPlayStatus(unsigned int Status)
{
g_PlayStatus = Status;
}
//========================================================================
// 语法格式: unsigned int GetPlayStatus()
// 实现功能: 得到当前播放状态
// 参数: 无
// 返回值: plNULL(0) - 当前处于空闲状态
// plPlaying(1)- 当前处于播放状态
//========================================================================
unsigned int GetPlayStatus()
{
return(g_PlayStatus);
}
//========================================================================
// 语法格式: void IRQ_PlayService()
// 实现功能: 后台解码播放函数(需要安置在4096Hz时基中断中)
// 参数: 无
// 返回值: 无
//========================================================================
void IRQ_PlayService()
{
if(g_PlayStatus == plPlaying)
{
if((SACM_S480_Status()&0x0001) != 0)
{
SACM_S480_ServiceLoop();
}
else
{
g_PlayStatus = plNULL;
SACM_S480_Stop();
#ifdef __BSRSD_H__
BSR_InitRecognizer(BSR_MIC);
// BSR_EnableCPUIndicator();
#endif
ClearPlayService();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -