cleanup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21299 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b2d0e81723
commit
9e448b6224
@ -7,6 +7,8 @@
|
|||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate { namespace media {
|
||||||
|
|
||||||
class PluginManager
|
class PluginManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -26,7 +28,7 @@ public:
|
|||||||
void DestroyDecoder(Decoder *decoder);
|
void DestroyDecoder(Decoder *decoder);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool LoadPlugin(const entry_ref &ref, MediaPlugin **plugin, image_id *image);
|
status_t LoadPlugin(const entry_ref &ref, MediaPlugin **plugin, image_id *image);
|
||||||
|
|
||||||
struct plugin_info
|
struct plugin_info
|
||||||
{
|
{
|
||||||
@ -40,6 +42,10 @@ private:
|
|||||||
BLocker *fLocker;
|
BLocker *fLocker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} } // namespace BPrivate::media
|
||||||
|
|
||||||
|
using namespace BPrivate::media;
|
||||||
|
|
||||||
extern PluginManager _plugin_manager;
|
extern PluginManager _plugin_manager;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -108,14 +108,14 @@ PluginManager::CreateDecoder(Decoder **_decoder, const media_format &format)
|
|||||||
DecoderPlugin *decoderPlugin = dynamic_cast<DecoderPlugin *>(plugin);
|
DecoderPlugin *decoderPlugin = dynamic_cast<DecoderPlugin *>(plugin);
|
||||||
if (!decoderPlugin) {
|
if (!decoderPlugin) {
|
||||||
printf("PluginManager::CreateDecoder: dynamic_cast failed\n");
|
printf("PluginManager::CreateDecoder: dynamic_cast failed\n");
|
||||||
_plugin_manager.PutPlugin(plugin);
|
PutPlugin(plugin);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
*_decoder = decoderPlugin->NewDecoder(0);
|
*_decoder = decoderPlugin->NewDecoder(0);
|
||||||
if (*_decoder == NULL) {
|
if (*_decoder == NULL) {
|
||||||
printf("PluginManager::CreateDecoder: NewDecoder() failed\n");
|
printf("PluginManager::CreateDecoder: NewDecoder() failed\n");
|
||||||
_plugin_manager.PutPlugin(plugin);
|
PutPlugin(plugin);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,10 +200,10 @@ PluginManager::GetPlugin(const entry_ref &ref)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LoadPlugin(ref, &info.plugin, &info.image)) {
|
if (LoadPlugin(ref, &info.plugin, &info.image) < B_OK) {
|
||||||
printf("PluginManager: Error, loading PlugIn %s failed\n", ref.name);
|
printf("PluginManager: Error, loading PlugIn %s failed\n", ref.name);
|
||||||
fLocker->Unlock();
|
fLocker->Unlock();
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(info.name, ref.name);
|
strcpy(info.name, ref.name);
|
||||||
@ -245,7 +245,7 @@ PluginManager::PutPlugin(MediaPlugin *plugin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
status_t
|
||||||
PluginManager::LoadPlugin(const entry_ref &ref, MediaPlugin **plugin, image_id *image)
|
PluginManager::LoadPlugin(const entry_ref &ref, MediaPlugin **plugin, image_id *image)
|
||||||
{
|
{
|
||||||
BPath p(&ref);
|
BPath p(&ref);
|
||||||
@ -255,14 +255,14 @@ PluginManager::LoadPlugin(const entry_ref &ref, MediaPlugin **plugin, image_id *
|
|||||||
image_id id;
|
image_id id;
|
||||||
id = load_add_on(p.Path());
|
id = load_add_on(p.Path());
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
return false;
|
return B_ERROR;
|
||||||
|
|
||||||
MediaPlugin *(*instantiate_plugin_func)();
|
MediaPlugin *(*instantiate_plugin_func)();
|
||||||
|
|
||||||
if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT, (void**)&instantiate_plugin_func) < B_OK) {
|
if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT, (void**)&instantiate_plugin_func) < B_OK) {
|
||||||
printf("PluginManager: Error, LoadPlugin can't find instantiate_plugin in %s\n", p.Path());
|
printf("PluginManager: Error, LoadPlugin can't find instantiate_plugin in %s\n", p.Path());
|
||||||
unload_add_on(id);
|
unload_add_on(id);
|
||||||
return false;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaPlugin *pl;
|
MediaPlugin *pl;
|
||||||
@ -271,10 +271,10 @@ PluginManager::LoadPlugin(const entry_ref &ref, MediaPlugin **plugin, image_id *
|
|||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("PluginManager: Error, LoadPlugin instantiate_plugin in %s returned NULL\n", p.Path());
|
printf("PluginManager: Error, LoadPlugin instantiate_plugin in %s returned NULL\n", p.Path());
|
||||||
unload_add_on(id);
|
unload_add_on(id);
|
||||||
return false;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
*plugin = pl;
|
*plugin = pl;
|
||||||
*image = id;
|
*image = id;
|
||||||
return true;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user