PluginManager: remove unneeded buffering.

The plugin manager was attempting to buffer the IOs. However, the ffmpeg
plugin already handles this (it reads in 64K chunks, the same size as
the buffer here, so this buffering was effectively useless), and the
media extractor already runs the decoding in a separate thread thanks to
the chunk cache. So, we do not need an extra level of buffering here.

We should leave any extra buffering to the upper layers (BMediaTrack or
Media Extractor), if it's needed, as they would have much more control
on the creation of the data io object.

Change-Id: I65b67919da107c8b910dd08f8cdb8e3745af92c7
Reviewed-on: https://review.haiku-os.org/c/1588
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
This commit is contained in:
Adrien Destugues 2019-07-12 21:49:19 +02:00 committed by waddlesplash
parent 727e49c611
commit ca68cae76f
1 changed files with 9 additions and 29 deletions

View File

@ -86,7 +86,6 @@ public:
fData(NULL),
fPosition(NULL),
fMedia(NULL),
fBufferIO(NULL),
fDataIOAdapter(NULL),
fErr(B_NO_ERROR)
{
@ -94,32 +93,17 @@ public:
fPosition = dynamic_cast<BPositionIO*>(source);
fMedia = dynamic_cast<BMediaIO*>(source);
fBufferIO = dynamic_cast<BBufferIO *>(source);
fData = source;
// No need to do additional buffering if we have
// a BBufferIO or a BMediaIO.
if (!IsMedia() && fBufferIO == NULL) {
// Source needs to be at least a BPositionIO to wrap with a BBufferIO
if (IsPosition()) {
fBufferIO = new(std::nothrow) BBufferIO(fPosition, 65536, false);
if (fBufferIO == NULL) {
fErr = B_NO_MEMORY;
return;
}
// We have to reset our parents reference too
fPosition = dynamic_cast<BPositionIO*>(fBufferIO);
fData = dynamic_cast<BDataIO*>(fPosition);
} else {
// In this case we have to supply our own form
// of pseudo-seekable object from a non-seekable
// BDataIO.
fDataIOAdapter = new DataIOAdapter(source);
fMedia = dynamic_cast<BMediaIO*>(fDataIOAdapter);
fPosition = dynamic_cast<BPositionIO*>(fDataIOAdapter);
fData = dynamic_cast<BDataIO*>(fDataIOAdapter);
TRACE("Unable to improve performance with a BufferIO\n");
}
if (!IsPosition()) {
// In this case we have to supply our own form
// of pseudo-seekable object from a non-seekable
// BDataIO.
fDataIOAdapter = new DataIOAdapter(source);
fMedia = dynamic_cast<BMediaIO*>(fDataIOAdapter);
fPosition = dynamic_cast<BPositionIO*>(fDataIOAdapter);
fData = dynamic_cast<BDataIO*>(fDataIOAdapter);
TRACE("Unable to improve performance with a BufferIO\n");
}
if (IsMedia())
@ -130,9 +114,6 @@ public:
virtual ~BMediaIOWrapper()
{
if (fBufferIO != NULL)
delete fBufferIO;
if (fDataIOAdapter != NULL)
delete fDataIOAdapter;
}
@ -212,7 +193,6 @@ private:
BDataIO* fData;
BPositionIO* fPosition;
BMediaIO* fMedia;
BBufferIO* fBufferIO;
DataIOAdapter* fDataIOAdapter;
int32 fFlags;