- 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:
casey 2016-06-04 18:07:10 -07:00
parent 4effb493e9
commit ae82180470
4 changed files with 37 additions and 7 deletions

Binary file not shown.

View File

@ -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());

View File

@ -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;

View File

@ -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";
}
}
}