bool FNetworkPlatformFile::IsInLocalDirectory(const FString& Filename) { if (!bHasLoadedDDCDirectories) { // need to be careful here to avoid initializing the DDC from the wrong thread or using LocalDirectories while it is being initialized FScopeLock ScopeLock(&LocalDirectoriesCriticalSection); if (IsInGameThread() && GConfig && GConfig->IsReadyForUse()) { // one time DDC directory initialization // add any DDC directories to our list of local directories (local = inner platform file, it may // actually live on a server, but it will use the platform's file system) if (GetDerivedDataCache()) { TArray<FString> DdcDirectories; GetDerivedDataCacheRef().GetDirectories(DdcDirectories); LocalDirectories.Append(DdcDirectories); } FPlatformMisc::MemoryBarrier(); bHasLoadedDDCDirectories = true; } return IsInLocalDirectoryUnGuarded(Filename); } // once the DDC is initialized, we don't need to lock a critical section anymore return IsInLocalDirectoryUnGuarded(Filename); }
FByteBulkData* USoundWave::GetCompressedData(FName Format) { if (IsTemplate() || IsRunningDedicatedServer()) { return NULL; } bool bContainedData = CompressedFormatData.Contains(Format); FByteBulkData* Result = &CompressedFormatData.GetFormat(Format); if (!bContainedData) { if (!FPlatformProperties::RequiresCookedData() && GetDerivedDataCache()) { TArray<uint8> OutData; FDerivedAudioDataCompressor* DeriveAudioData = new FDerivedAudioDataCompressor(this, Format); GetDerivedDataCacheRef().GetSynchronous(DeriveAudioData, OutData); if (OutData.Num()) { Result->Lock(LOCK_READ_WRITE); FMemory::Memcpy(Result->Realloc(OutData.Num()), OutData.GetData(), OutData.Num()); Result->Unlock(); } } else { UE_LOG(LogAudio, Error, TEXT("Attempt to access the DDC when there is none available on sound '%s', format = %s. Should have been cooked."), *GetFullName(), *Format.ToString()); } } check(Result); return Result->GetBulkDataSize() > 0 ? Result : NULL; // we don't return empty bulk data...but we save it to avoid thrashing the DDC }
class FDerivedDataCacheInterface& GetDerivedDataCacheRef() { class FDerivedDataCacheInterface* SingletonInterface = GetDerivedDataCache(); if (!SingletonInterface) { UE_LOG(LogInit, Fatal, TEXT("Derived Data Cache was requested, but not available.")); CA_ASSUME( SingletonInterface != NULL ); // Suppress static analysis warning in unreachable code (fatal error) } return *SingletonInterface; }