Improve IO performance for all media files

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34793 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
David McPaul 2009-12-29 00:41:08 +00:00
parent d4e7d2de5c
commit 6768fe0d89
1 changed files with 19 additions and 2 deletions

View File

@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
#include <BufferIO.h>
#include <File.h>
#include <MediaTrack.h>
@ -432,9 +433,25 @@ BMediaFile::_InitReader(BDataIO* source, int32 flags)
return;
}
fSource = source;
if (dynamic_cast<BBufferIO *>(source)) {
// Already buffered
fSource = source;
} else {
// Source needs to be at least a BPositionIO to wrap with a BBufferIO
if (dynamic_cast<BPositionIO *>(source)) {
fSource = new(std::nothrow) BBufferIO(dynamic_cast<BPositionIO *>(source), 65536, fDeleteSource);
if (fSource == NULL) {
fErr = B_NO_MEMORY;
return;
}
fDeleteSource = true;
} else {
TRACE("Unable to improve performance with a BufferIO\n");
fSource = source;
}
}
fExtractor = new(std::nothrow) MediaExtractor(source, flags);
fExtractor = new(std::nothrow) MediaExtractor(fSource, flags);
if (fExtractor == NULL)
fErr = B_NO_MEMORY;
else