- Made PluginFactory threadsafe.

- Fixed the splitting of the track number.
This commit is contained in:
Daniel Önnerby 2008-04-20 23:07:58 +00:00
parent eb2d941042
commit 095ac9a4a8
3 changed files with 12 additions and 4 deletions

View File

@ -199,10 +199,12 @@ bool TagReaderTaglib::GetID3v2Tag(musik::core::Track *track){
// Split TRCK to track and totaltracks // Split TRCK to track and totaltracks
std::vector<utfstring> splitTrack; std::vector<utfstring> splitTrack;
boost::algorithm::split(splitTrack,aAllTags["TRCK"].front()->toString().toWString(),boost::algorithm::is_any_of(_T("/"))); if(!aAllTags["TRCK"].isEmpty()){
this->SetTagValue("track",splitTrack[0].c_str(),track); boost::algorithm::split(splitTrack,aAllTags["TRCK"].front()->toString().toWString(),boost::algorithm::is_any_of(_T("/")));
if(splitTrack.size()>1){ this->SetTagValue("track",splitTrack[0].c_str(),track);
this->SetTagValue("totaltracks",splitTrack[1].c_str(),track); if(splitTrack.size()>1){
this->SetTagValue("totaltracks",splitTrack[1].c_str(),track);
}
} }
this->SetTagValues("bpm",aAllTags["TBPM"],track); this->SetTagValues("bpm",aAllTags["TBPM"],track);

View File

@ -66,6 +66,7 @@ PluginFactory::~PluginFactory(void){
} }
void PluginFactory::LoadPlugins(){ void PluginFactory::LoadPlugins(){
boost::mutex::scoped_lock lock(this->mutex);
utfstring sPluginDir(GetPluginDirectory()); utfstring sPluginDir(GetPluginDirectory());
// Open plugin directory // Open plugin directory

View File

@ -41,6 +41,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
namespace musik{ namespace core{ namespace musik{ namespace core{
@ -70,6 +71,8 @@ namespace musik{ namespace core{
static PluginFactory sInstance; static PluginFactory sInstance;
boost::mutex mutex;
public: public:
template <typename T> template <typename T>
@ -86,6 +89,8 @@ namespace musik{ namespace core{
}; };
template <class T, class D> std::vector<boost::shared_ptr<T>> QueryInterface(const char* functionName){ template <class T, class D> std::vector<boost::shared_ptr<T>> QueryInterface(const char* functionName){
boost::mutex::scoped_lock lock(this->mutex);
typedef T* (__stdcall* PluginInterfaceCall)(); typedef T* (__stdcall* PluginInterfaceCall)();
std::vector<boost::shared_ptr<T>> plugins; std::vector<boost::shared_ptr<T>> plugins;