From 672397ba1a3feb1fb9bd51d7017443b0f7a181bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 25 Aug 2010 22:27:12 +0000 Subject: [PATCH] The list of Reader plugins will also not remain sorted, the same mechanism needs to be applied as for Decoders, so that user add-ons are always found before system add-ons. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38360 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/media/AddOnManager.cpp | 42 +++++++++++++++++++++++++----- src/servers/media/AddOnManager.h | 3 +++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/servers/media/AddOnManager.cpp b/src/servers/media/AddOnManager.cpp index d9f10ec45c..7f293a2c72 100644 --- a/src/servers/media/AddOnManager.cpp +++ b/src/servers/media/AddOnManager.cpp @@ -146,13 +146,21 @@ AddOnManager::GetReaders(xfer_entry_ref* outRefs, int32* outCount, { BAutolock locker(fLock); - fReaderList.Rewind(); - reader_info* info; - for (*outCount = 0; fReaderList.GetNext(&info) && *outCount < maxCount; - (*outCount)++) { - outRefs[*outCount] = info->ref; - } + *outCount = 0; + // See GetDecoderForFormat() for why we need to scan the list by path. + + BPath path; + for (uint i = 0; i < sizeof(sDirectories) / sizeof(directory_which); i++) { + if (find_directory(sDirectories[i], &path) != B_OK + || path.Append("media/plugins") != B_OK) { + printf("AddOnManager::GetReaders: failed to construct " + "path for directory %u\n", i); + continue; + } + _GetReaders(path, outRefs, outCount, maxCount); + } + return B_OK; } @@ -602,3 +610,25 @@ AddOnManager::_FindDecoder(const media_format& format, const BPath& path, return false; } + +void +AddOnManager::_GetReaders(const BPath& path, xfer_entry_ref* outRefs, + int32* outCount, int32 maxCount) +{ + node_ref nref; + BDirectory directory; + if (directory.SetTo(path.Path()) != B_OK + || directory.GetNodeRef(&nref) != B_OK) { + return; + } + + reader_info* info; + for (fReaderList.Rewind(); fReaderList.GetNext(&info) + && *outCount < maxCount;) { + if (info->ref.directory != nref.node) + continue; + + outRefs[*outCount] = info->ref; + (*outCount)++; + } +} diff --git a/src/servers/media/AddOnManager.h b/src/servers/media/AddOnManager.h index 48c0409f7b..bc99f99639 100644 --- a/src/servers/media/AddOnManager.h +++ b/src/servers/media/AddOnManager.h @@ -72,6 +72,9 @@ private: bool _FindDecoder(const media_format& format, const BPath& path, xfer_entry_ref* _decoderRef); + void _GetReaders(const BPath& path, + xfer_entry_ref* outRefs, int32* outCount, + int32 maxCount); private: struct reader_info {