示例#1
0
void Sound::Play3D(const AudioEmitter& audioEmitter, float volume)
{
	auto& audioManager = AudioManager::GetInstance();
	auto& voice = GetVoiceForPlayback();
	
	voice.sourceVoice->SetVolume(volume);
	audioManager.Calculate3DAudioForVoice(audioEmitter.GetEmitter(), voice.sourceVoice, m_WaveFormat.Format.nChannels, m_SubmixVoice);
	PlayImpl(voice);
}
    // called for background thread; changes state (since that can involve 
    // slow blocking calls) and updates the state (since the state is read 
    // frequently and querying the device is a bit slow)  
    bool ThreadIteration()
    {
        // fetch the current requested state and copy it to the current state
        int nRequestedTrack;
        int nOldTrack;
        {
            CriticalSectionLock lock(m_csTrack);

            nOldTrack = m_nCurrentTrack;
            nRequestedTrack = m_nQueuedTrack;
            
            if (nRequestedTrack != trackEmpty)
                m_nCurrentTrack = nRequestedTrack;
            m_nQueuedTrack = trackEmpty;
        }

        // if there is a new state requested, make that change
        if (nRequestedTrack != trackEmpty)
        {
            if (nRequestedTrack == trackStop)
                StopImpl();
            else 
                PlayImpl(nRequestedTrack);
        }
        // otherwise, just update the current state
        else 
        {
            if ((nOldTrack != trackStop) && (IsPlayingImpl() != S_OK))
            {
                CriticalSectionLock lock(m_csTrack);
                m_nCurrentTrack = trackStop;
            }
        }

        return true;
    }
示例#3
0
void Sound::Play()
{
	PlayImpl(GetVoiceForPlayback());
}