* Always assign fSource in _InitReader(), even if we will
wrap it in a BBufferIO. Makes the code cleaner. * Check if source is a BFile and propagate InitCheck() of the BFile. When trying to open a BMediaFile on a non-existant file, it will correctly say the file does not exist instead that there is no handler for it. (IIRC there is a ticket for this.) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38760 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -446,22 +446,28 @@ BMediaFile::_InitReader(BDataIO* source, int32 flags)
|
||||
return;
|
||||
}
|
||||
|
||||
fSource = source;
|
||||
|
||||
if (BFile* file = dynamic_cast<BFile*>(source)) {
|
||||
fErr = file->InitCheck();
|
||||
if (fErr != B_OK)
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
fSource = new(std::nothrow) BBufferIO(dynamic_cast<BPositionIO *>(
|
||||
source), 65536, fDeleteSource);
|
||||
if (fSource == NULL) {
|
||||
fErr = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
fDeleteSource = true;
|
||||
} else {
|
||||
} else
|
||||
TRACE("Unable to improve performance with a BufferIO\n");
|
||||
fSource = source;
|
||||
}
|
||||
}
|
||||
|
||||
fExtractor = new(std::nothrow) MediaExtractor(fSource, flags);
|
||||
|
||||
Reference in New Issue
Block a user