mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
- Added a proper debug version of pdcurses for Windows.
- Tweaked the Indexer to allow files in the DB that do not have metadata, but have decoders. - Bug fix to Text::Duration
This commit is contained in:
parent
4effb493e9
commit
ae82180470
BIN
src/3rdparty/lib/pdcursesd.lib
vendored
BIN
src/3rdparty/lib/pdcursesd.lib
vendored
Binary file not shown.
@ -56,6 +56,8 @@
|
||||
static const std::string TAG = "Indexer";
|
||||
|
||||
using namespace musik::core;
|
||||
using namespace musik::core::metadata;
|
||||
using namespace musik::core::audio;
|
||||
|
||||
static std::string normalizeDir(std::string path) {
|
||||
path = boost::filesystem::path(path).make_preferred().string();
|
||||
@ -169,11 +171,14 @@ void Indexer::RemovePath(const std::string& path) {
|
||||
//////////////////////////////////////////
|
||||
void Indexer::SynchronizeInternal() {
|
||||
/* load all of the metadata (tag) reader plugins */
|
||||
typedef metadata::IMetadataReader PluginType;
|
||||
typedef PluginFactory::DestroyDeleter<PluginType> Deleter;
|
||||
typedef PluginFactory::DestroyDeleter<IMetadataReader> MetadataDeleter;
|
||||
typedef PluginFactory::DestroyDeleter<IDecoderFactory> DecoderDeleter;
|
||||
|
||||
this->metadataReaders = PluginFactory::Instance()
|
||||
.QueryInterface<PluginType, Deleter>("GetMetadataReader");
|
||||
.QueryInterface<IMetadataReader, MetadataDeleter>("GetMetadataReader");
|
||||
|
||||
this->audioDecoders = PluginFactory::Instance()
|
||||
.QueryInterface<IDecoderFactory, DecoderDeleter>("GetDecoderFactory");
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->progressMutex);
|
||||
@ -318,12 +323,27 @@ void Indexer::SyncDirectory(
|
||||
if ((*it)->CanRead(track.GetValue("extension").c_str())) {
|
||||
if ((*it)->Read(file->path().string().c_str(), &track)) {
|
||||
saveToDb = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
/* no tag? well... if a decoder can play it, add it to the database
|
||||
with the file as the name. */
|
||||
if (!saveToDb) {
|
||||
std::string fullPath = file->path().string();
|
||||
auto it = this->audioDecoders.begin();
|
||||
while (it != this->audioDecoders.end()) {
|
||||
if ((*it)->CanHandle(fullPath.c_str())) {
|
||||
saveToDb = true;
|
||||
track.SetValue("title", file->path().leaf().string().c_str());
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
/* write it to the db, if read successfully */
|
||||
if (saveToDb) {
|
||||
track.SetValue("path_id", pathIdStr.c_str());
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <core/support/ThreadHelper.h>
|
||||
#include <core/db/Connection.h>
|
||||
#include <core/sdk/IMetadataReader.h>
|
||||
#include <core/sdk/IDecoderFactory.h>
|
||||
#include <core/library/IIndexer.h>
|
||||
|
||||
#include <sigslot/sigslot.h>
|
||||
@ -110,11 +111,16 @@ namespace musik { namespace core {
|
||||
std::string path;
|
||||
};
|
||||
|
||||
typedef std::vector<std::shared_ptr<metadata::IMetadataReader> > MetadataReaderList;
|
||||
typedef std::vector<std::shared_ptr<
|
||||
metadata::IMetadataReader> > MetadataReaderList;
|
||||
|
||||
typedef std::vector<std::shared_ptr<
|
||||
musik::core::audio::IDecoderFactory> > DecoderList;
|
||||
|
||||
std::deque<AddRemoveContext> addRemoveQueue;
|
||||
|
||||
MetadataReaderList metadataReaders;
|
||||
DecoderList audioDecoders;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Indexer> IndexerPtr;
|
||||
|
@ -48,8 +48,12 @@ namespace musik {
|
||||
}
|
||||
|
||||
std::string Duration(std::string& str) {
|
||||
int seconds = boost::lexical_cast<int>(str);
|
||||
return Duration(seconds);
|
||||
if (str.size()) {
|
||||
int seconds = boost::lexical_cast<int>(str);
|
||||
return Duration(seconds);
|
||||
}
|
||||
|
||||
return "0:00";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user