void AssetDownloadTask::textureDownloaded(Transfer::URI uri, ResourceDownloadTaskPtr taskptr, Transfer::TransferRequestPtr request, Transfer::DenseDataPtr response) { // This could be triggered by any CDN thread, protect access // (mActiveDownloads, mDependencies) boost::mutex::scoped_lock lok(mDependentDownloadMutex); if (!taskptr) { SILOG(ogre, warn, "failed request dependent callback"); failDownload(); return; } if (!request) { SILOG(ogre, warn, "failed request dependent callback " << taskptr->getIdentifier()); failDownload(); return; } // Clear the download task mActiveDownloads.erase(taskptr->getIdentifier()); mFinishedDownloads.push_back(taskptr->getIdentifier()); // Lack of response data means failure of some sort if (!response) { SILOG(ogre, warn, "failed response dependent callback " << taskptr->getIdentifier()); failDownload(); return; } // Store data for later use mDependencies[uri].request = request; mDependencies[uri].response = response; if (mActiveDownloads.size() == 0) mCB(); }
void AssetDownloadTask::assetFileDownloaded(ResourceDownloadTaskPtr taskptr, Transfer::ChunkRequestPtr request, Transfer::DenseDataPtr response) { boost::mutex::scoped_lock lok(mDependentDownloadMutex); // Clear from the active download list assert(mActiveDownloads.size() == 1); mActiveDownloads.erase(taskptr->getIdentifier()); mFinishedDownloads.push_back(taskptr->getIdentifier()); // Lack of response data means failure of some sort if (!response) { SILOG(ogre, warn, "Failed to download resource for " << taskptr->getIdentifier()); failDownload(); return; } // FIXME here we could have another callback which lets them get // at the hash to try to use an existing copy. Even with the // eventual centralized loading we want, this may still be // beneficial since Ogre may have a copy even if we don't have a // copy of the raw data any more. mParseMeshHandle = mScene->parseMesh( request->getMetadata(), request->getMetadata().getFingerprint(), response, mIsAggregate, std::tr1::bind(&AssetDownloadTask::weakHandleAssetParsed, getWeakPtr(), _1) ); }
void AssetDownloadTask::addDependentDownload(ResourceDownloadTaskPtr resPtr) { boost::mutex::scoped_lock lok(mDependentDownloadMutex); // Sometimes we get duplicate references, so make sure we're not already // working on this one. if (mActiveDownloads.find(resPtr->getIdentifier()) != mActiveDownloads.end()) { return; } mActiveDownloads[resPtr->getIdentifier()] = resPtr; }
void AssetDownloadTask::downloadAssetFile() { assert( !mAssetURI.empty() ); boost::mutex::scoped_lock lok(mDependentDownloadMutex); ResourceDownloadTaskPtr dl = ResourceDownloadTask::construct( mAssetURI, mScene->transferPool(), mPriority, std::tr1::bind(&AssetDownloadTask::weakAssetFileDownloaded, getWeakPtr(), _1, _2, _3) ); mActiveDownloads[dl->getIdentifier()] = dl; dl->start(); }