Cleaned up a couple of the SDK interfaces and removed comments until the

definitions have stabilized. Also fixed CD playback in windows.
This commit is contained in:
casey 2016-06-04 14:18:33 -07:00
parent ed0e23088d
commit fdd3a030c3
15 changed files with 24 additions and 137 deletions

View File

@ -44,12 +44,12 @@ CddaDataStreamFactory::~CddaDataStreamFactory() {
}
bool CddaDataStreamFactory::CanReadFile(const char *uri) {
bool CddaDataStreamFactory::CanRead(const char *uri) {
std::string extension = PathFindExtension(uri);
return (extension == ".cda");
}
IDataStream* CddaDataStreamFactory::OpenFile(const char *uri, unsigned int options) {
IDataStream* CddaDataStreamFactory::Open(const char *uri, unsigned int options) {
CddaDataStream* stream = new CddaDataStream();
if (stream->Open(uri, options)) {

View File

@ -40,7 +40,7 @@ public:
CddaDataStreamFactory();
~CddaDataStreamFactory();
virtual bool CanReadFile(const char *uri);
virtual IDataStream* OpenFile(const char *uri, unsigned int options = 0);
virtual bool CanRead(const char *uri);
virtual IDataStream* Open(const char *uri, unsigned int options = 0);
virtual void Destroy();
};

View File

@ -97,7 +97,7 @@ void TaglibMetadataReader::Destroy() {
delete this;
}
bool TaglibMetadataReader::CanReadTag(const char *extension){
bool TaglibMetadataReader::CanRead(const char *extension){
if (extension) {
std::string ext(extension);
boost::algorithm::to_lower(ext);
@ -113,7 +113,7 @@ bool TaglibMetadataReader::CanReadTag(const char *extension){
return false;
}
bool TaglibMetadataReader::ReadTag(const char* uri, musik::core::IMetadataWriter *track) {
bool TaglibMetadataReader::Read(const char* uri, musik::core::IMetadataWriter *track) {
std::string path(uri);
std::string extension;

View File

@ -61,8 +61,8 @@ class TaglibMetadataReader : public musik::core::metadata::IMetadataReader {
public:
TaglibMetadataReader();
virtual ~TaglibMetadataReader();
bool ReadTag(const char *uri, musik::core::IMetadataWriter *target);
virtual bool CanReadTag(const char *extension);
virtual bool Read(const char *uri, musik::core::IMetadataWriter *target);
virtual bool CanRead(const char *extension);
virtual void Destroy();
private:

View File

@ -70,8 +70,8 @@ DataStreamFactory::DataStreamPtr DataStreamFactory::OpenUri(const char *uri) {
/* plugins get the first crack at the uri */
for( ; it != DataStreamFactory::Instance()->dataStreamFactories.end(); it++) {
if ((*it)->CanReadFile(uri)) {
IDataStream* dataStream = (*it)->OpenFile(uri);
if ((*it)->CanRead(uri)) {
IDataStream* dataStream = (*it)->Open(uri);
if (dataStream) {
return DataStreamPtr(dataStream, StreamDeleter());
@ -100,7 +100,7 @@ bool DataStreamFactory::IsLocalFileStream(const char *uri) {
DataStreamFactory::Instance()->dataStreamFactories.begin();
for( ; it != DataStreamFactory::Instance()->dataStreamFactories.end(); ++it) {
if ((*it)->CanReadFile(uri)) {
if ((*it)->CanRead(uri)) {
return false;
}
}

View File

@ -315,8 +315,8 @@ void Indexer::SyncDirectory(
typedef MetadataReaderList::iterator Iterator;
Iterator it = this->metadataReaders.begin();
while (it != this->metadataReaders.end()) {
if ((*it)->CanReadTag(track.GetValue("extension").c_str())) {
if ((*it)->ReadTag(file->path().string().c_str(), &track)) {
if ((*it)->CanRead(track.GetValue("extension").c_str())) {
if ((*it)->Read(file->path().string().c_str(), &track)) {
saveToDb = true;
}
}

View File

@ -120,8 +120,8 @@ void NonLibraryTrackHelper::ThreadLoop() {
typedef MetadataReaderList::iterator Iterator;
Iterator it = metadataReaders.begin();
while (it != metadataReaders.end()) {
if ((*it)->CanReadTag(track->GetValue("extension").c_str())) {
(*it)->ReadTag(url.c_str(), track.get());
if ((*it)->CanRead(track->GetValue("extension").c_str())) {
(*it)->Read(url.c_str(), track.get());
break;
}

View File

@ -39,48 +39,13 @@
namespace musik { namespace core { namespace audio {
//////////////////////////////////////////
///\brief
///The main interface for a analyzer plugin
///
///A analyzer plugin will be executed from the Indexer
///after all tags has been read. The plugin will first be
///called with the Start method, and if that method returns true
///a audio::Stream will be opened and the whole track will be
///decoded and passed on to the Analyze method (or until the Analyze method
///returns false). Finally the End method will be called where the
///the plugin can make changes to the tracks metadata.
//////////////////////////////////////////
class IAnalyzer {
public:
//////////////////////////////////////////
///\brief
///Destroy the object
//////////////////////////////////////////
virtual void Destroy() = 0;
//////////////////////////////////////////
///\brief
///Start analyzing the track. Returns true if
///the analyzing should continue.
//////////////////////////////////////////
virtual bool Start(musik::core::IMetadataWriter *target) = 0;
//////////////////////////////////////////
///\brief
///Analyze a buffer
//////////////////////////////////////////
virtual bool Analyze(musik::core::IMetadataWriter *target, IBuffer *buffer) = 0;
//////////////////////////////////////////
///\brief
///Called when the whole track has been analyzed.
///If this call makes changes to the track it should
///return true.
//////////////////////////////////////////
virtual bool End(musik::core::IMetadataWriter *target) = 0;
};
} } }

View File

@ -38,32 +38,10 @@
namespace musik { namespace core { namespace audio {
//////////////////////////////////////////
///\brief
///Main interface for dsp plugins.
///Each instance equals a track.
//////////////////////////////////////////
class IDSP {
public:
//////////////////////////////////////////
///\brief
///Destroy this object
//////////////////////////////////////////
virtual void Destroy() = 0;
//////////////////////////////////////////
///\brief
///Process the buffer through the dsp plugin
///
///\param inputBuffer
///Buffer to process
///
///\param outputBuffer
///Empty buffer that you can write the processed inputBuffer to
///
///\return true if the buffer has been processed to the new outputBuffer.
//////////////////////////////////////////
virtual bool Process(const IBuffer *inputBuffer, IBuffer *outputBuffer) = 0;
virtual bool Process(const IBuffer *input, IBuffer *ouput) = 0;
};
} } }

View File

@ -42,8 +42,8 @@
namespace musik { namespace core { namespace io {
class IDataStreamFactory{
public:
virtual bool CanReadFile(const char *uri) = 0;
virtual IDataStream* OpenFile(const char *uri, unsigned int options = 0) = 0;
virtual bool CanRead(const char *uri) = 0;
virtual IDataStream* Open(const char *uri, unsigned int options = 0) = 0;
virtual void Destroy() = 0;
};

View File

@ -41,44 +41,10 @@ namespace musik { namespace core { namespace audio {
class IDecoder {
public:
//////////////////////////////////////////
///\brief
///Destroy the object
///
///The Destroy method is used so that it's guaranteed that the object is
///destroyed inside the right DLL/exe
//////////////////////////////////////////
virtual void Destroy() = 0;
//////////////////////////////////////////
///\brief
///Set the position in the source (in seconds)
///
///\returns
///The actual position set
//////////////////////////////////////////
virtual double SetPosition(double seconds) = 0;
//////////////////////////////////////////
///\brief
///Fill the next buffer
///
///\returns
///false is there is nothing left
//////////////////////////////////////////
virtual bool GetBuffer(IBuffer *buffer) = 0;
//////////////////////////////////////////
///\brief
///Open the stream
///
///\param fileStream
///pointer to the filestream object.
///
///\returns
///True if successfully opened
//////////////////////////////////////////
virtual bool Open(musik::core::io::IDataStream *fileStream) = 0;
virtual bool Open(musik::core::io::IDataStream *stream) = 0;
};
} } }

View File

@ -38,30 +38,10 @@
namespace musik { namespace core { namespace audio {
//////////////////////////////////////////
///\brief
///Interface for decoder plugins to be able to create
///instances of IDecoder
//////////////////////////////////////////
class IDecoderFactory{
public:
//////////////////////////////////////////
///\brief
///Create a instance of the decoder
//////////////////////////////////////////
virtual IDecoder* CreateDecoder() = 0;
//////////////////////////////////////////
///\brief
///Destroy the object
//////////////////////////////////////////
virtual void Destroy() = 0;
//////////////////////////////////////////
///\brief
///Can this plugin handle this kind of filetype?
///The "type" can either be a file extension or a mimetype
//////////////////////////////////////////
virtual bool CanHandle(const char* type) const = 0;
};

View File

@ -43,8 +43,8 @@ namespace musik { namespace core { namespace metadata {
class IMetadataReader {
public:
virtual bool ReadTag(const char *uri, musik::core::IMetadataWriter *target) = 0;
virtual bool CanReadTag(const char *extension) = 0;
virtual bool Read(const char *uri, musik::core::IMetadataWriter *target) = 0;
virtual bool CanRead(const char *extension) = 0;
virtual void Destroy() = 0;
};

View File

@ -40,10 +40,6 @@
namespace musik { namespace core {
//////////////////////////////////////////
///\brief
///The virtual base for all tracks
//////////////////////////////////////////
class IMetadataWriter {
public:
virtual void SetValue(const char* metakey, const char* value) = 0;

View File

@ -48,7 +48,9 @@ void PlaybackService::ProcessMessage(IMessage &message) {
this->nextIndex = NO_POSITION;
}
this->TrackChanged(this->index, this->playlist.at(this->index));
if (this->index != NO_POSITION) {
this->TrackChanged(this->index, this->playlist.at(this->index));
}
}
}
else if (message.Type() == MESSAGE_PLAYBACK_EVENT) {