📄 msoundplayer.cpp
字号:
}
if ( nPlayingIndex_ == nIndex || (nQueueCount_ == 1 && Queue_[0] == nIndex) )
{
// DBGPRINTF("PUSH ERROR");
return;
}
Queue_[0] = nIndex;
QueueRepeat_[0] = bRepeat;
nQueueCount_ = 1;
if ( nPlayingIndex_ >= 0 )
{
stopSound();
nRepeatIndex_ = -1;
}
}
void CMSoundPlayer::pop() {
if ( nQueueCount_ != 1 || nPlayingIndex_ != MYSOUND_PLAY_NOTHING )
{
// DBGPRINTF("POP ERROR");
return;
}
playSound(Queue_[0], QueueRepeat_[0]);
nQueueCount_ = 0;
}
/*
// Game 狼 皋牢 风橇俊辑 亲惑 荐青登绢具 窍绰 皋辑靛
// Queue 俊 阶牢 牢郸胶甫 曼炼窍咯 荤款靛甫 荐青矫挪促.
*/
void CMSoundPlayer::checkSound() {
if ( nPlayingIndex_ == MYSOUND_PLAY_NOTHING )
{
if ( nRepeatIndex_ != -1 )
{
playSound(nRepeatIndex_, true);
}
else {
pop();
}
}
else if ( nPlayingIndex_ == MYSOUND_WAIT_DELAY )
{
if ( nWaitCount_ > 0 )
{
uint32 nCurrentTime;
DBGPRINTF("柳涝 nWiatCount_ : %d", nWaitCount_);
nCurrentTime = GET_UPTIMEMS();
nWaitCount_ = nWaitCount_ - (GET_UPTIMEMS() - nWaitStartTime_);
nWaitStartTime_ = nCurrentTime;
}
else {
nPlayingIndex_ = MYSOUND_PLAY_NOTHING;
}
}
#ifndef USE_CALLBACK
virtualSoundCB();
#endif
}
boolean CMSoundPlayer::playSound(int nIndex, boolean bRepeat) {
// DBGPRINTF("PlaySound 柳涝");
#ifdef DEBUG_CODE_ENABLED
if ( (nIndex < 0) || (nIndex >= nSoundCount_) ) {
DBGPRINTF("[MSoundPlayer class]-[playSound func] : Out of index.");
return false;
}
#endif
if ( bRepeat )
{
nRepeatIndex_ = nIndex;
} else {
nRepeatIndex_ = -1;
}
#ifdef LOAD_FROM_FILE
if ( !bSound_ || (pSoundBuf_[nIndex] == NULL) )
{
return false;
}
#else
if ( !bSound_ || (pSoundRes_[nIndex]->getData() == NULL) )
{
// DBGPRINTF("Error 1");
return false;
}
#endif // LOAD_FROM_FILE
#ifdef _6160_EXCEPTION
byte *buf=NULL;
#ifdef LOAD_FROM_FILE
buf = (byte*)MALLOC(pSoundRealSize_[nIndex]);
MEMCPY(buf, pSoundBuf_[nIndex], pSoundRealSize_[nIndex]);
#else
buf = (byte*)MALLOC(pSoundRes_[nIndex]->getSize() );
MEMCPY(buf, pSoundRes_[nIndex]->getData(), pSoundRes_[nIndex]->getSize() );
#endif // LOAD_FROM_FILE
// Play sound
if(bIs6160_) {
if (pSoundBuffArr_->pData !=NULL) {
FREE(pSoundBuffArr_->pData);
pSoundBuffArr_->pData=NULL;
}
pSoundBuffArr_->pData = buf;
#ifdef LOAD_FROM_FILE
pSoundBuffArr_->dwSize = pSoundRealSize_[nIndex];
#else
pSoundBuffArr_->dwSize = pSoundRes_[nIndex]->getSize();
#endif // LOAD_FROM_FILE
pSoundBuffArr_->eInput = SDT_BUFFER;
ISOUNDPLAYER_SetInfo(pISoundPlayer_,pSoundBuffArr_);
} else {
/*
byte *buf=NULL;
#ifdef LOAD_FROM_FILE
buf = (byte*)MALLOC(pSoundRealSize_[nIndex]);
MEMCPY(buf, pSoundBuf_[nIndex], pSoundRealSize_[nIndex]);
#else
buf = (byte*)MALLOC(pSoundRes_[nIndex]->getSize() );
MEMCPY(buf, pSoundRes_[nIndex]->getData(), pSoundRes_[nIndex]->getSize() );
#endif // LOAD_FROM_FILE
*/
#ifdef BREW_11_OVER
if (pSoundBuffArr_->pData !=NULL) {
FREE(pSoundBuffArr_->pData);
pSoundBuffArr_->pData=NULL;
}
pSoundBuffArr_->pData = buf;
#ifdef LOAD_FROM_FILE
pSoundBuffArr_->dwSize = pSoundRealSize_[nIndex];
#else
pSoundBuffArr_->dwSize = pSoundRes_[nIndex]->getSize();
#endif // LOAD_FROM_FILE
pSoundBuffArr_->eInput = SDT_BUFFER;
ISOUNDPLAYER_SetInfo(pISoundPlayer_,pSoundBuffArr_);
#else
ISOUNDPLAYER_Set(pISoundPlayer_, SDT_BUFFER, buf);
#endif // BREW_11_OVER
}
#else
byte *buf=NULL;
#ifdef LOAD_FROM_FILE
buf = (byte*)MALLOC(pSoundRealSize_[nIndex]);
MEMCPY(buf, pSoundBuf_[nIndex], pSoundRealSize_[nIndex]);
#else
buf = (byte*)MALLOC(pSoundRes_[nIndex]->getSize() );
MEMCPY(buf, pSoundRes_[nIndex]->getData(), pSoundRes_[nIndex]->getSize() );
#endif // LOAD_FROM_FILE
#ifdef BREW_11_OVER
if (pSoundBuffArr_->pData !=NULL) {
FREE(pSoundBuffArr_->pData);
pSoundBuffArr_->pData=NULL;
}
pSoundBuffArr_->pData = buf;
#ifdef LOAD_FROM_FILE
pSoundBuffArr_->dwSize = pSoundRealSize_[nIndex];
#else
pSoundBuffArr_->dwSize = pSoundRes_[nIndex]->getSize();
#endif // LOAD_FROM_FILE
pSoundBuffArr_->eInput = SDT_BUFFER;
ISOUNDPLAYER_SetInfo(pISoundPlayer_,pSoundBuffArr_);
#else
ISOUNDPLAYER_Set(pISoundPlayer_, SDT_BUFFER, buf);
#endif // BREW_11_OVER
#endif // _6160_EXCEPTION
#ifdef USE_CALLBACK
ISOUNDPLAYER_RegisterNotify(pISoundPlayer_, SoundCB, this);
#else
startPlayTime_ = GET_UPTIMEMS();
#endif
ISOUNDPLAYER_Play(pISoundPlayer_);
nPlayingIndex_ = nIndex;
// DBGPRINTF("PlaySound %d", nPlayingIndex_);
return true;
}
void CMSoundPlayer::stopSound() {
if ( pISoundPlayer_ == NULL ) {
return;
}
if ( nPlayingIndex_ >= 0 )
{
ISOUNDPLAYER_Stop(pISoundPlayer_);
#ifdef USE_CALLBACK
ISOUNDPLAYER_RegisterNotify(pISoundPlayer_, NULL, NULL);
#endif
nPlayingIndex_ = MYSOUND_WAIT_DELAY;
nWaitCount_ = nGapDelay_ + VIRTUAL_CB_HAZARD;
nWaitStartTime_ = GET_UPTIMEMS();
}
else {
nPlayingIndex_ = MYSOUND_PLAY_NOTHING;
}
nRepeatIndex_ = -1;
}
void CMSoundPlayer::pauseSound() {
if ( pISoundPlayer_ == NULL ) {
return;
}
if ( nPlayingIndex_ >= 0 )
{
ISOUNDPLAYER_Stop(pISoundPlayer_);
#ifdef USE_CALLBACK
ISOUNDPLAYER_RegisterNotify(pISoundPlayer_, NULL, NULL);
#endif
nPlayingIndex_ = MYSOUND_WAIT_DELAY;
nWaitCount_ = nGapDelay_ + VIRTUAL_CB_HAZARD;
nWaitStartTime_ = GET_UPTIMEMS();
}
else {
nPlayingIndex_ = MYSOUND_PLAY_NOTHING;
}
}
void CMSoundPlayer::resumeSound() {
if ( nRepeatIndex_ != -1 )
{
push(nRepeatIndex_, true);
}
}
void CMSoundPlayer::toggleSound() {
bSound_ = !bSound_;
if ( bSound_ )
{
resumeSound();
} else {
pauseSound();
}
}
boolean CMSoundPlayer::getSoundCount() {
return nSoundCount_;
}
boolean CMSoundPlayer::getSoundStatus() {
return bSound_;
}
void CMSoundPlayer::setSoundStatus(boolean bSound) {
bSound_ = bSound;
}
#ifdef USE_CALLBACK
void CMSoundPlayer::SoundCB(void *pUser, AEESoundPlayerCmd eCBType, AEESoundPlayerStatus eSPStatus, uint32 dwParam) {
CMSoundPlayer *pi = (CMSoundPlayer *)pUser;
// DBGPRINTF(" CB : %d %d vs %d %d", eCBType, eSPStatus, AEE_SOUNDPLAYER_PLAY_CB, AEE_SOUNDPLAYER_DONE);
if ( eCBType == AEE_SOUNDPLAYER_PLAY_CB )
{
if ( eSPStatus == AEE_SOUNDPLAYER_DONE || eSPStatus == AEE_SOUNDPLAYER_ABORTED )
{
pi->nPlayingIndex_ = MYSOUND_WAIT_DELAY;
pi->nWaitCount_ = pi->nGapDelay_;
pi->nWaitStartTime_ = GET_UPTIMEMS();
}
}
}
#else
void CMSoundPlayer::virtualSoundCB() {
#ifdef DEBUG_CODE_ENABLED
if ( totalPlayTimeMs_[nPlayingIndex_] < 0 ) {
DBGPRINTF("[MSoundPlayer class]-[virtualSoundCB func] : Invalid totalplaytime.");
return;
}
#endif // DEBUG_CODE_ENABLED
if(nPlayingIndex_ >= 0) {
checkPlayTime_ = GET_UPTIMEMS();
if( (int)(checkPlayTime_ - startPlayTime_) > totalPlayTimeMs_[nPlayingIndex_] + VIRTUAL_CB_HAZARD ) {
// stopSound();
pauseSound();
}
}
}
void CMSoundPlayer::setPlayTimeMs(int nIndex, int ms) {
#ifdef DEBUG_CODE_ENABLED
if ( (nIndex < 0) || (nIndex >= nSoundCount_) ) {
DBGPRINTF("[MSoundPlayer class]-[setPlayTimeMs func] : Out of index.");
return;
}
#endif // DEBUG_CODE_ENABLED
#ifdef DEBUG_CODE_ENABLED
if ( ms < 0 ) {
DBGPRINTF("[MSoundPlayer class]-[setPlayTimeMs func] : Out of playtime.");
return;
}
#endif // DEBUG_CODE_ENABLED
totalPlayTimeMs_[nIndex] = ms;
}
int CMSoundPlayer::getPlayTimeMs(int nIndex) {
#ifdef DEBUG_CODE_ENABLED
if ( (nIndex < 0) || (nIndex >= nSoundCount_) ) {
DBGPRINTF("[MSoundPlayer class]-[loadSoundFile func] : Out of index.");
return -1;
}
#endif // DEBUG_CODE_ENABLED
return -1;
}
#endif // USE_CALLBACK
/*
// nIndex : 楷林 快急鉴困甫 沥且 荤款靛 滚欺狼 牢郸胶
// priorityLevel : 快急鉴困 饭骇(0 - 255)
// 快急 鉴困俊 狼秦辑 Play 吝埃俊 Play啊 荐青登搁 公矫 肚绰 碍力荐青 且 荐 乐促.
// 悼老茄 快急鉴困老 版快俊绰 唱吝俊 Play 等 巴捞 快急鉴困啊 臭促绊 魄窜茄促.
*/
void CMSoundPlayer::setPriority(int nIndex, uint8 priorityLevel) {
#ifdef LOAD_FROM_FILE
if (pSoundBuf_[nIndex] == NULL)
{
return;
}
#else
if (pSoundRes_[nIndex]->getData() == NULL)
{
return;
}
#endif // LOAD_FROM_FILE
playPriority_[nIndex] = priorityLevel;
}
void CMSoundPlayer::setGapDelay(int delay) {
// 楷林吝俊绰 掉饭捞 汲沥 阂啊
if(nPlayingIndex_ == MYSOUND_PLAY_NOTHING) {
(delay < 0)?(nGapDelay_ = 0):(nGapDelay_ = delay);
}
}
#ifdef _6160_EXCEPTION
boolean CMSoundPlayer::Is6160() {
SYSINFO SysInfo;
IEB_KTF_System *pDUser = NULL;
ISHELL_CreateInstance(pIShell_, AEECLSID_DM, (void**)&pDUser);
MEMSET(&SysInfo, 0, sizeof(SysInfo));
if (pDUser){
IEB_KTF_SYSTEM_GetSysInfo(pDUser, &SysInfo);
IEB_KTF_SYSTEM_Release(pDUser);
if(STRCMP(SysInfo.HandsetModelName, "LG-KP6160")==0)
return true;
}
return false;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -