Ejemplo n.º 1
0
/*! Used to play a 3d sound
 *
 *  Note, if you call this on a file that has not been Loaded
 *  (see icSoundDeviceAL::LoadSource), it will keep this audio
 *  loaded in memory until you call UnloadSource or the device
 *  is destroyed.
 *
 *  @param          szFile          Audio file to play
 *  @param          soundParam      How to play that audio
 *  @param[out]     ppStream        Handle to the sound object
 *  @returns        ICRESULT        Success/failure of playing audio
**/
ICRESULT icSoundDeviceAL::Play3D(const char* szName,
                                 const icSoundParam& soundParams,
                                 icSoundI** ppSound)
{
    icSoundI* sound = GetFreeSound();
    if (!sound)
        return IC_FAIL_GEN;

    icSoundBuffer pBuf;

    if (ICEFAIL(FindSource(szName,pBuf)))
        LoadSource(szName);

    if (ICEFAIL(FindSource(szName,pBuf)))
        return IC_FAIL_GEN;


    icSoundAL* alSound = (icSoundAL*)sound;

    alSound->m_buf = pBuf;

    alSound->m_Params = soundParams;

    // assign the buffer to this source
    alSourcei(alSound->m_ALsource, AL_BUFFER, pBuf.buffID);

    alSound->Play3d();

    *ppSound = sound;

    return IC_OK;
}// END FUNCTION Play3D(const char* szName,
Ejemplo n.º 2
0
void AddSoundToList(const res::path & path, bool isSpeech) {
	
	CinematicSound * cs = GetFreeSound();
	if(!cs) {
		LogError << "AddSoundToList failed for " << path;
		return;
	}
	
	cs->file = path;
	cs->isSpeech = isSpeech;
	cs->exists = true;
}
Ejemplo n.º 3
0
/*! Gets a handle to a sound for playing
 *
 *  @param          szFile          Audio file to play
 *  @param[out]     ppStream        Handle to the sound object
 *  @returns        ICRESULT        Success/failure of playing audio
**/
ICRESULT icSoundDeviceAL::GetSound(const char* szName, icSoundI** ppSound)
{
    icSoundI* sound = GetFreeSound();
    if (!sound)
        return IC_FAIL_GEN;

    icSoundBuffer pBuf;
    
    if (ICEFAIL(FindSource(szName,pBuf)))
	{
		if (ICEFAIL(LoadSource(szName)))
		{
			return IC_FAIL_GEN;
		}

		if (ICEFAIL(FindSource(szName,pBuf)))
		{
			return IC_FAIL_GEN;
		}
	}


    icSoundAL* alSound = (icSoundAL*)sound;

    alSound->m_buf = pBuf;

    // assign the buffer to this source
    alSourcei(alSound->m_ALsource, AL_BUFFER, pBuf.buffID);

    ALenum err = alGetError();
    if (err != AL_NO_ERROR)
        return IC_FAIL_GEN;

	*ppSound = sound;

    return IC_OK;
}// END FUNCTION GetSound(const char* szName, icSoundI** ppSound)