Пример #1
0
SoundSource* DeviceAudioDX11::playQuick (SoundResource *sound)
{
	SoundSource* source = SoundSource::create();
    ScriptingSound* sound_loader = ScriptingSound::create();
    
    // Build the sound file loader
    sound_loader->setSoundProperty(sound);
    
    // Connect sound packet outputs
    PlugBase *s1 = source->getPlugByName("Sound_Packet");
    PlugBase *s2 = sound_loader->getPlugByName("Sound_Packet");
    s1->setIncomingConnection(s2);
    
    // Play the sound source
	if (play(source, sound_loader)) {
    
        if (source->countReferences() <= 1) {
            RELEASE(source);
        } else {
            source->release();	// Playing increments ref count so this pointer is still good
        }
        
        RELEASE(sound_loader);
		return source;
	} else {
        RELEASE(sound_loader);
		RELEASE(source);
		return NULL;
	}
}