From c8284bd808b5f452fbabd40382d63c1cff4e3a7e Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Tue, 26 Apr 2011 23:52:00 -0700 Subject: [PATCH] Cache the file when it is played for the first time. --- Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp b/Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp index b3141e84..59aedcc1 100644 --- a/Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp +++ b/Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp @@ -75,6 +75,12 @@ plAudioFileReader* plAudioFileReader::CreateReader(const char* path, plAudioCore char cachedPath[256]; IGetCachedPath(path, cachedPath, whichChan); plAudioFileReader *r = TRACKED_NEW plCachedFileReader(cachedPath, plAudioCore::kAll); + if (!r->IsValid()) { + // So we tried to play a cached file and it didn't exist + // Oops... we should cache it now + ICacheFile(path, true, whichChan); + r = TRACKED_NEW plCachedFileReader(cachedPath, plAudioCore::kAll); + } return r; }