mirror of
https://github.com/clangen/musikcube.git
synced 2025-04-15 11:42:29 +00:00
Track abstract class now only directly implements ITrack. TagStore has
been extracted, and implements ITagStore and delegates to Track implementation.
This commit is contained in:
parent
2f119b7c06
commit
a864efb1bc
@ -364,6 +364,7 @@ void Indexer::ReadMetadataFromFile(
|
|||||||
bool saveToDb = false;
|
bool saveToDb = false;
|
||||||
|
|
||||||
/* read the tag from the plugin */
|
/* read the tag from the plugin */
|
||||||
|
TagStore store(track);
|
||||||
typedef TagReaderList::iterator Iterator;
|
typedef TagReaderList::iterator Iterator;
|
||||||
Iterator it = this->tagReaders.begin();
|
Iterator it = this->tagReaders.begin();
|
||||||
while (it != this->tagReaders.end()) {
|
while (it != this->tagReaders.end()) {
|
||||||
@ -373,7 +374,7 @@ void Indexer::ReadMetadataFromFile(
|
|||||||
fprintf(logFile, " - %s\n", file.string().c_str());
|
fprintf(logFile, " - %s\n", file.string().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*it)->Read(file.string().c_str(), &track)) {
|
if ((*it)->Read(file.string().c_str(), &store)) {
|
||||||
saveToDb = true;
|
saveToDb = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -795,9 +796,10 @@ void Indexer::RunAnalyzers() {
|
|||||||
if (LibraryTrack::Load(&track, this->dbConnection)) {
|
if (LibraryTrack::Load(&track, this->dbConnection)) {
|
||||||
PluginVector runningAnalyzers;
|
PluginVector runningAnalyzers;
|
||||||
|
|
||||||
|
TagStore store(track);
|
||||||
PluginVector::iterator plugin = analyzers.begin();
|
PluginVector::iterator plugin = analyzers.begin();
|
||||||
for ( ; plugin != analyzers.end(); ++plugin) {
|
for ( ; plugin != analyzers.end(); ++plugin) {
|
||||||
if ((*plugin)->Start(&track)) {
|
if ((*plugin)->Start(&store)) {
|
||||||
runningAnalyzers.push_back(*plugin);
|
runningAnalyzers.push_back(*plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -815,7 +817,7 @@ void Indexer::RunAnalyzers() {
|
|||||||
while ((buffer = stream->GetNextProcessedOutputBuffer()) && !runningAnalyzers.empty()) {
|
while ((buffer = stream->GetNextProcessedOutputBuffer()) && !runningAnalyzers.empty()) {
|
||||||
PluginVector::iterator plugin = runningAnalyzers.begin();
|
PluginVector::iterator plugin = runningAnalyzers.begin();
|
||||||
while(plugin != runningAnalyzers.end()) {
|
while(plugin != runningAnalyzers.end()) {
|
||||||
if ((*plugin)->Analyze(&track, buffer)) {
|
if ((*plugin)->Analyze(&store, buffer)) {
|
||||||
++plugin;
|
++plugin;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -830,7 +832,7 @@ void Indexer::RunAnalyzers() {
|
|||||||
PluginVector::iterator plugin = analyzers.begin();
|
PluginVector::iterator plugin = analyzers.begin();
|
||||||
|
|
||||||
for ( ; plugin != analyzers.end(); ++plugin) {
|
for ( ; plugin != analyzers.end(); ++plugin) {
|
||||||
if ((*plugin)->End(&track)) {
|
if ((*plugin)->End(&store)) {
|
||||||
successPlugins++;
|
successPlugins++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
using namespace musik::core;
|
using namespace musik::core;
|
||||||
|
|
||||||
|
/* * * * Track * * * */
|
||||||
|
|
||||||
Track::~Track() {
|
Track::~Track() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,3 +56,31 @@ ILibraryPtr Track::Library() {
|
|||||||
int Track::LibraryId() {
|
int Track::LibraryId() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* * * * TagStore * * * */
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct NoDeleter {
|
||||||
|
void operator()(T* t) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TagStore::TagStore(TrackPtr track) {
|
||||||
|
this->track = track;
|
||||||
|
}
|
||||||
|
|
||||||
|
TagStore::TagStore(Track& track) {
|
||||||
|
this->track = TrackPtr(&track, NoDeleter<Track>());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TagStore::SetValue(const char* key, const char* value) {
|
||||||
|
this->track->SetValue(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TagStore::ClearValue(const char* key) {
|
||||||
|
this->track->ClearValue(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TagStore::SetThumbnail(const char *data, long size) {
|
||||||
|
this->track->SetThumbnail(data, size);
|
||||||
|
}
|
@ -45,12 +45,8 @@ namespace musik { namespace core {
|
|||||||
|
|
||||||
class Track;
|
class Track;
|
||||||
typedef std::shared_ptr<Track> TrackPtr;
|
typedef std::shared_ptr<Track> TrackPtr;
|
||||||
typedef std::vector<TrackPtr> TrackVector;
|
|
||||||
|
|
||||||
class Track :
|
class Track : public musik::core::sdk::ITrack {
|
||||||
public musik::core::sdk::ITagStore,
|
|
||||||
public musik::core::sdk::ITrack
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
typedef std::multimap<std::string, std::string> MetadataMap;
|
typedef std::multimap<std::string, std::string> MetadataMap;
|
||||||
typedef std::pair<MetadataMap::iterator, MetadataMap::iterator> MetadataIteratorRange;
|
typedef std::pair<MetadataMap::iterator, MetadataMap::iterator> MetadataIteratorRange;
|
||||||
@ -66,9 +62,11 @@ namespace musik { namespace core {
|
|||||||
virtual std::string GetString(const char* metakey) = 0;
|
virtual std::string GetString(const char* metakey) = 0;
|
||||||
virtual std::string Uri() = 0;
|
virtual std::string Uri() = 0;
|
||||||
|
|
||||||
/* ITagStore */
|
/* ITrack is a ready only interface; we use the ITagStore interface
|
||||||
virtual void SetValue(const char* metakey, const char* value) = 0;
|
for writing. we replicate the interface here, and have TagStore pass
|
||||||
virtual void ClearValue(const char* metakey) = 0;
|
through to us */
|
||||||
|
virtual void SetValue(const char* key, const char* value) = 0;
|
||||||
|
virtual void ClearValue(const char* key) = 0;
|
||||||
virtual void SetThumbnail(const char *data, long size) = 0;
|
virtual void SetThumbnail(const char *data, long size) = 0;
|
||||||
|
|
||||||
/* ITrack */
|
/* ITrack */
|
||||||
@ -78,9 +76,23 @@ namespace musik { namespace core {
|
|||||||
virtual double GetDouble(const char* key, double defaultValue = 0.0f) = 0;
|
virtual double GetDouble(const char* key, double defaultValue = 0.0f) = 0;
|
||||||
virtual int Uri(char* dst, int size) = 0;
|
virtual int Uri(char* dst, int size) = 0;
|
||||||
|
|
||||||
|
/* implementation specific */
|
||||||
virtual MetadataIteratorRange GetValues(const char* metakey) = 0;
|
virtual MetadataIteratorRange GetValues(const char* metakey) = 0;
|
||||||
virtual MetadataIteratorRange GetAllValues() = 0;
|
virtual MetadataIteratorRange GetAllValues() = 0;
|
||||||
virtual TrackPtr Copy() = 0;
|
virtual TrackPtr Copy() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TagStore : public musik::core::sdk::ITagStore {
|
||||||
|
public:
|
||||||
|
TagStore(TrackPtr track);
|
||||||
|
TagStore(Track& track);
|
||||||
|
|
||||||
|
virtual void SetValue(const char* key, const char* value) override;
|
||||||
|
virtual void ClearValue(const char* key) override;
|
||||||
|
virtual void SetThumbnail(const char *data, long size) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TrackPtr track;
|
||||||
|
};
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
@ -38,8 +38,8 @@ namespace musik { namespace core { namespace sdk {
|
|||||||
|
|
||||||
class ITagStore {
|
class ITagStore {
|
||||||
public:
|
public:
|
||||||
virtual void SetValue(const char* metakey, const char* value) = 0;
|
virtual void SetValue(const char* key, const char* value) = 0;
|
||||||
virtual void ClearValue(const char* metakey) = 0;
|
virtual void ClearValue(const char* value) = 0;
|
||||||
virtual void SetThumbnail(const char *data, long size) = 0; /* should be SetBlob with a key */
|
virtual void SetThumbnail(const char *data, long size) = 0; /* should be SetBlob with a key */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user