ParticleSourceWrapper ParticleManager::createSource(ParticleEffectIndex index) { ParticleEffectPtr eff = this->getEffect(index); ParticleSourceWrapper wrapper; if (eff->getType() == EffectType::Composite) { SCP_vector<ParticleSource*> sources; auto composite = static_cast<effects::CompositeEffect*>(eff); auto& childEffects = composite->getEffects(); // UGH, HACK! To implement the source wrapper we need constant pointers to all sources. // To ensure this we reserve the number of sources we will need (current sources + sources being created) m_sources.reserve(m_sources.size() + childEffects.size()); for (auto& effect : childEffects) { ParticleSource* source = createSource(); source->setEffect(effect); effect->initializeSource(*source); sources.push_back(source); } wrapper = ParticleSourceWrapper(std::move(sources)); } else { ParticleSource* source = createSource(); source->setEffect(eff); eff->initializeSource(*source); wrapper = ParticleSourceWrapper(source); } wrapper.setCreationTimestamp(timestamp()); return wrapper; }
// ----------------------------------------- // ServerMediaSubsession for Multicast // ----------------------------------------- MulticastServerMediaSubsession* MulticastServerMediaSubsession::createNew(UsageEnvironment& env , struct in_addr destinationAddress , Port rtpPortNum, Port rtcpPortNum , int ttl , StreamReplicator* replicator , const std::string& format) { // Create a source FramedSource* source = replicator->createStreamReplica(); FramedSource* videoSource = createSource(env, source, format); // Create RTP/RTCP groupsock Groupsock* rtpGroupsock = new Groupsock(env, destinationAddress, rtpPortNum, ttl); Groupsock* rtcpGroupsock = new Groupsock(env, destinationAddress, rtcpPortNum, ttl); // Create a RTP sink RTPSink* videoSink = createSink(env, rtpGroupsock, 96, format, dynamic_cast<V4L2DeviceSource*>(replicator->inputSource())); // Create 'RTCP instance' const unsigned maxCNAMElen = 100; unsigned char CNAME[maxCNAMElen+1]; gethostname((char*)CNAME, maxCNAMElen); CNAME[maxCNAMElen] = '\0'; RTCPInstance* rtcpInstance = RTCPInstance::createNew(env, rtcpGroupsock, 500, CNAME, videoSink, NULL); // Start Playing the Sink videoSink->startPlaying(*videoSource, NULL, NULL); return new MulticastServerMediaSubsession(replicator, videoSink, rtcpInstance); }
void VFS::addNewSource(const std::string& path) { VFSSource* source = createSource(path); if (source) { addSource(source); } else { FL_WARN(_log, LMsg("Failed to add new VFS source: ") << path); } }
AudioSource* AudioManager::createSource(const std::string& filePath){ AudioBuffer* buf= find(filePath); if(!buf){ DebugLog("%s should be load first",filePath.c_str()); return 0; } return createSource(buf); }
/*! Creates and returns a source with the specified \a parent that reads from the system's default source of satellite update information, or the highest priority available plugin. Returns 0 if the system has no default source and no valid plugins could be found. Note: Symbian applications will need to have the Location capability otherwise this will return 0. \since 1.0 */ QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *parent) { QSettings pluginSettings(QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSat")); QVariant value = pluginSettings.value("position.plugin.operator.whitelist"); if (value.isValid()) { QStringList parts = value.toString().split(","); if (parts.size() == 4) { QGeoSatelliteInfoSource *source = createSource(parts.at(0), parent); if (source) return source; } } #if defined(Q_OS_SYMBIAN) CQGeoSatelliteInfoSourceS60 *ret = NULL; TRAPD(error, QT_TRYCATCH_LEAVING(ret = CQGeoSatelliteInfoSourceS60::NewL(parent))); if (error == KErrNone) return ret; #elif defined(Q_OS_WINCE) return new QGeoSatelliteInfoSourceWinCE(parent); #elif (defined(Q_WS_MAEMO_6)) || (defined(Q_WS_MAEMO_5)) QGeoSatelliteInfoSourceMaemo *source = new QGeoSatelliteInfoSourceMaemo(parent); int status = source->init(); if (status != -1) return source; else delete source; #elif defined(QT_SIMULATOR) return new QGeoSatelliteInfoSourceSimulator(parent); #elif defined(Q_WS_MEEGO) // Use Maemo6 backend if available, otherwise use Gypsy backend QSettings maemo6Settings(QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSatMaemo6")); if (!maemo6Settings.value("maemo6satelliteavailable").isValid()) { QGeoSatelliteInfoSourceMaemo *maemoSource = new QGeoSatelliteInfoSourceMaemo(parent); int status = maemoSource->init(); if (status == -1) { delete maemoSource; maemoSource = 0; maemo6Settings.setValue("maemo6satelliteavailable", false); } else { return maemoSource; } } #ifdef GYPSY_AVAILABLE QGeoSatelliteInfoSourceGypsy* gypsySource = new QGeoSatelliteInfoSourceGypsy(parent); int status = gypsySource->init(); if (status >= 0) return gypsySource; delete gypsySource; #endif // GYPSY_AVAILABLE #endif foreach (QGeoPositionInfoSourceFactory *f, QGeoSatelliteInfoSourcePrivate::pluginsSorted()) { QGeoSatelliteInfoSource *src = f->satelliteInfoSource(parent); if (src) return src; }
virtual AbstractSource *create(QString URL) const { // scheme checking if (QUrl(URL).scheme().toLower() != QLatin1String(scheme)) return 0; // decode if (URL.contains(QLatin1Char('&'))) URL.truncate(URL.indexOf(QLatin1Char('&'))); QString decodedURL = QLatin1String(QByteArray::fromBase64(URL.mid((QLatin1String(scheme) + QLatin1String("://")).size()).toLatin1()).constData()); // head & tail checking if (!decodedURL.startsWith(QLatin1String(head), Qt::CaseInsensitive)) return 0; if (!decodedURL.endsWith(QLatin1String(tail), Qt::CaseInsensitive)) return 0; decodedURL.remove(0, QString::fromLatin1(head).size()); decodedURL.chop(QString::fromLatin1(tail).size()); return createSource(decodedURL); }
virtual int sync( const int *activeSources, SyncMode syncMode, const CheckSyncReport &checkReport, long maxMsgSize, long maxObjSize, bool loSupport, const char *encoding = 0) { SyncSource **syncSources = new SyncSource *[sources.size() + 1]; int index, numsources = 0; memset(syncSources, 0, sizeof(syncSources[0]) * (sources.size() + 1)); for (index = 0; activeSources[index] >= 0 && index < (int)sources.size(); index++) { // rewrite configuration as needed for test SyncSourceConfig *sourceConfig = config->getSyncSourceConfig(sources[activeSources[index]].c_str()); CPPUNIT_ASSERT(sourceConfig); sourceConfig->setSync(syncModeKeyword(syncMode)); sourceConfig->setEncoding(encoding); config->getAccessConfig().setMaxMsgSize(maxMsgSize); config->getDeviceConfig().setMaxObjSize(maxObjSize); config->getDeviceConfig().setLoSupport(loSupport); // create sync source using the third change tracking for syncs syncSources[numsources++] = createSource(activeSources[index], "S"); } SyncClient client; int res = client.sync(*config, syncSources); CPPUNIT_ASSERT(client.getSyncReport()); for (int source = 0; syncSources[source]; source++) { delete syncSources[source]; } checkReport.check(res, *client.getSyncReport()); return res; }
AudioSystem::SourceID AudioSystem::createSource(BufferID buffer) { SourceID source = createSource(); alSourcei(source, AL_BUFFER, buffer); return source; }