Example #1
0
/**
* @brief 开始播放一个声音
* @param pSndBuffer - 声音缓冲
* @param uBufferSize - 声音缓冲大小
* @param format - 声音数据格式
* @param nLoopCount - 0表示循环播放,其他表示播放次数
* @return 播放ID
*/
SFSND_ID SFSnd_Play(void*pSndBuffer,unsigned int uBufferSize,SFSND_FORMAT format,int nLoopCount)
{
	if(!g_bBgMusicOn
		|| (MMI_PROFILE_SILENT == gactivatedprofile)
		|| (MMI_PROFILE_MEETING == gactivatedprofile))
	{
		return 0;
	}
	

//Output audio only through the earphone when earphone plugged
	if(isEarphonePlugged)
	{
		if(format==SNDFORMAT_MIDI)
		{
			if(g_kernal.bMidiPlaying)
				mdi_audio_stop_string();
			//PlayAudioMidiStream((U8*)pSndBuffer,(U16)uBufferSize,0);
			mdi_audio_play_string_with_vol_path(pSndBuffer,uBufferSize,MDI_FORMAT_SMF,nLoopCount==1?DEVICE_AUDIO_PLAY_ONCE:DEVICE_AUDIO_PLAY_INFINITE,SFNull,SFNull,255,MDI_DEVICE_SPEAKER2);
			g_kernal.bMidiPlaying=SFTrue;
			return 1;
		}
		else if(format==SNDFORMAT_WAVE)
		{
			if(g_kernal.bWavPlaying)
				mdi_audio_stop_string();
			//PlayAudioWavStream((U8*)pSndBuffer,(U16)uBufferSize,0);
			mdi_audio_play_string_with_vol_path(pSndBuffer,uBufferSize,MDI_FORMAT_WAV,nLoopCount==1?DEVICE_AUDIO_PLAY_ONCE:DEVICE_AUDIO_PLAY_INFINITE,SFNull,SFNull,255,MDI_DEVICE_SPEAKER2);
			g_kernal.bWavPlaying=SFTrue;
			return 2;
		}
	}
	else
     {
	if(format==SNDFORMAT_MIDI)
	{
		if(g_kernal.bMidiPlaying)
			mdi_audio_stop_string();
		mdi_audio_play_string_with_vol_path(pSndBuffer,uBufferSize,MDI_FORMAT_SMF,nLoopCount==1?DEVICE_AUDIO_PLAY_ONCE:DEVICE_AUDIO_PLAY_INFINITE,SFNull,SFNull,255,MDI_DEVICE_SPEAKER_BOTH);
		g_kernal.bMidiPlaying=SFTrue;
		return 1;
	}
	else if(format==SNDFORMAT_WAVE)
	{
		if(g_kernal.bWavPlaying)
			mdi_audio_stop_string();
		mdi_audio_play_string_with_vol_path(pSndBuffer,uBufferSize,MDI_FORMAT_WAV,nLoopCount==1?DEVICE_AUDIO_PLAY_ONCE:DEVICE_AUDIO_PLAY_INFINITE,SFNull,SFNull,255,MDI_DEVICE_SPEAKER_BOTH);
		g_kernal.bWavPlaying=SFTrue;
		return 2;
	}
     }
     return 0;
}
Example #2
0
void AudioPlayReq(U16 soundId, U8 style)
{
#ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
        S8 buf[MAX_EXT_MELODY_FULLNAME_WIDTH];
#else
        S8 buf[(FMGR_MAX_PATH_LEN+1)*ENCODING_LENGTH];
#endif

#ifdef __MMI_PROFILE_EXTMELODY_SUPPORT__
	if(soundId>=PMG_EXT_MELODY_BEGIN && soundId<=PMG_EXT_MELODY_END)
	{
		if( PmgGetFilePathNameByAudioId(buf, sizeof(buf), soundId) == MMI_TRUE )
			mdi_audio_play_file(buf, style, NULL, NULL);
	}
	else
#endif
#if defined( __MMI_HUMAN_VOICE_KEYPAD_TONE__ )
	if( soundId >= MIN_HUMAN_VOICE_ID && soundId <= MAX_HUMAN_VOICE_ID )
	{
		audio_resource_struct* audio_resource_p = &resource_human_voice_tones[soundId - MIN_HUMAN_VOICE_ID];
          #if defined(__PROJECT_GALLITE_C01__)		
                audio_resource_p->len = audio_resource_p->len/4;
          #endif
		if( mdi_audio_play_string_with_vol_path((void*)audio_resource_p->data,
			audio_resource_p->len, 
#if defined(__PROJECT_GALLITE_C01__)
			MDI_FORMAT_WAV,
#else
            (U8)audio_resource_p->format,
#endif
			style,
			NULL,
			HumanVoiceKeyTonePlayHandler,
			GetKeypadVolumeLevel(),
			MDI_DEVICE_SPEAKER2 ) == MDI_AUDIO_SUCCESS )
			IsHumanVoiceKeyTonePlaying = 1;
		else
			IsHumanVoiceKeyTonePlaying = 0;
	}
	else
#endif
#if defined( __MMI_CUST_KEYPAD_TONE__ )
	if( soundId >= MIN_KEYPAD_TONE_ID && soundId <= MAX_KEYPAD_TONE_ID )
	{
		audio_resource_struct* audio_resource_p = &resource_keypad_tones[soundId - MIN_KEYPAD_TONE_ID];
		if( mdi_audio_play_string_with_vol_path((void*)audio_resource_p->data,
			audio_resource_p->len, 
			(U8)audio_resource_p->format,
			style,
			NULL,
			CustKeyTonePlayHandler,
			GetKeypadVolumeLevel(),
			MDI_DEVICE_SPEAKER2 ) == MDI_AUDIO_SUCCESS )
			IsCustKeyTonePlaying = 1;
		else
			IsCustKeyTonePlaying = 0;
	}
	else
#endif
#ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
	if( GetAudioNameWithPathInFileSystem( soundId, buf ) != NULL )
		mdi_audio_play_file( buf,  style, NULL, NULL );
	else
#endif
	{
#ifdef MMI_ON_HARDWARE_P
		mdi_audio_play_id(soundId, style, NULL, NULL);
#else
	MYQUEUE Message;
	mmi_eq_play_audio_req_struct *audioPlayReq;
 
	audioPlayReq = OslConstructDataPtr(sizeof (mmi_eq_play_audio_req_struct));
	audioPlayReq->sound_id = (U8)soundId;
		audioPlayReq->style = 2;//style;
	audioPlayReq->identifier= (U16)soundId;  
		
	Message.oslMsgId = PRT_EQ_PLAY_AUDIO_REQ;	
    Message.oslDataPtr = (oslParaType *)audioPlayReq;
    Message.oslPeerBuffPtr= NULL;
	Message.oslSrcId=MOD_MMI;
	Message.oslDestId=MOD_L4C;
	OslMsgSendExtQueue(&Message);
#endif
	}
}