SfxInstanceId QtAdvancedAudioPlayer::play(SfxId soundId) { PlayableAudioSource *inst; checkFinishedEffects(); QObject *source = m_effects.value(soundId); if (!source) { CCLOGERROR("Tried to play non-existing sfx %u", soundId); return 0; } if (qobject_cast<VorbisSource *>(source)) { inst = qobject_cast<PlayableAudioSource *>(source); inst->seek(0); inst->play(); } else { AudioBuffer *buffer = qobject_cast<AudioBuffer *>(source); inst = buffer->playWithMixer(*m_mixer); if (!inst) { CCLOG("playWithMixer for %s failed", pszFilePath); return 0; } } QObject::connect(inst, SIGNAL(finished(unsigned int)), this, SLOT(sfxFinished(unsigned int))); m_effectInstances.insertMulti(++m_sfxInstanceId, QPointer<PlayableAudioSource>(inst)); inst->setTag(m_sfxInstanceId); inst->setId(soundId); return m_sfxInstanceId; }