From ca68cae76fa7d163336c06d703ff15934ed496c6 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 12 Jul 2019 21:49:19 +0200 Subject: [PATCH] PluginManager: remove unneeded buffering. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/kits/media/PluginManager.cpp | 38 ++++++++------------------------ 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/kits/media/PluginManager.cpp b/src/kits/media/PluginManager.cpp index a6828eefae..89f786e5c6 100644 --- a/src/kits/media/PluginManager.cpp +++ b/src/kits/media/PluginManager.cpp @@ -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(source); fMedia = dynamic_cast(source); - fBufferIO = dynamic_cast(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(fBufferIO); - fData = dynamic_cast(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(fDataIOAdapter); - fPosition = dynamic_cast(fDataIOAdapter); - fData = dynamic_cast(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(fDataIOAdapter); + fPosition = dynamic_cast(fDataIOAdapter); + fData = dynamic_cast(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;