Cleaned up SDK interface namespaces -- they're all in musik::core::sdk

now.
This commit is contained in:
casey langen 2016-11-17 23:32:37 -08:00
parent 2f72c01184
commit 7bfb7657f6
77 changed files with 357 additions and 351 deletions

View File

@ -37,7 +37,7 @@
#include "ntddcdrm.h"
#include "devioctl.h"
using namespace musik::core::io;
using namespace musik::core::sdk;
class CddaDataStream : public IDataStream {
public:

View File

@ -34,7 +34,7 @@
#include <core/sdk/IDataStreamFactory.h>
using namespace musik::core::io;
using namespace musik::core::sdk;
class CddaDataStreamFactory : public IDataStreamFactory {
public:

View File

@ -40,8 +40,7 @@
#include "ntddcdrm.h"
#include "devioctl.h"
using namespace musik::core::audio;
using namespace musik::core::io;
using namespace musik::core::sdk;
class CddaDecoder : public IDecoder
{

View File

@ -36,7 +36,7 @@
#include <core/sdk/IDecoderFactory.h>
using namespace musik::core::audio;
using namespace musik::core::sdk;
class CddaDecoderFactory : public IDecoderFactory {
public:

View File

@ -42,14 +42,14 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
return true;
}
class CddaDecoderPlugin : public musik::core::IPlugin {
class CddaDecoderPlugin : public musik::core::sdk::IPlugin {
void Destroy() { delete this; };
const char* Name() { return "CD Audio (CDDA) IDecoder"; };
const char* Version() { return "0.2"; };
const char* Author() { return "Björn Olievier, clangen"; };
};
extern "C" __declspec(dllexport) musik::core::IPlugin* GetPlugin() {
extern "C" __declspec(dllexport) musik::core::sdk::IPlugin* GetPlugin() {
return new CddaDecoderPlugin();
}

View File

@ -133,7 +133,7 @@ FLAC__StreamDecoderLengthStatus FlacDecoder::FlacFileSize(
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
}
bool FlacDecoder::Open(musik::core::io::IDataStream *stream){
bool FlacDecoder::Open(musik::core::sdk::IDataStream *stream){
this->stream = stream;
FLAC__StreamDecoderInitStatus init_status =

View File

@ -39,9 +39,9 @@
#include <FLAC/stream_decoder.h>
#include <stddef.h>
using namespace musik::core::audio;
using namespace musik::core::sdk;
class FlacDecoder : public musik::core::audio::IDecoder {
class FlacDecoder : public musik::core::sdk::IDecoder {
public:
FlacDecoder();
virtual ~FlacDecoder();
@ -50,7 +50,7 @@ class FlacDecoder : public musik::core::audio::IDecoder {
virtual void Destroy();
virtual double SetPosition(double seconds);
virtual bool GetBuffer(IBuffer *buffer);
virtual bool Open(musik::core::io::IDataStream *stream);
virtual bool Open(musik::core::sdk::IDataStream *stream);
private:
static FLAC__StreamDecoderReadStatus FlacRead(
@ -95,8 +95,8 @@ class FlacDecoder : public musik::core::audio::IDecoder {
void *clientData);
protected:
musik::core::io::IDataStream *stream;
FLAC__StreamDecoder *decoder;
musik::core::sdk::IDataStream *stream;
FLAC__StreamDecoder *decoder;
long channels;
long sampleRate;

View File

@ -35,12 +35,12 @@
#include "stdafx.h"
#include <cctype>
#include <algorithm>
#include <string>
#include <string>
#include "FlacDecoderFactory.h"
#include "FlacDecoder.h"
using namespace musik::core::audio;
using namespace musik::core::sdk;
FlacDecoderFactory::FlacDecoderFactory() {
}

View File

@ -36,12 +36,12 @@
#include <core/sdk/IDecoderFactory.h>
class FlacDecoderFactory : public musik::core::audio::IDecoderFactory {
class FlacDecoderFactory : public musik::core::sdk::IDecoderFactory {
public:
FlacDecoderFactory();
virtual ~FlacDecoderFactory();
musik::core::audio::IDecoder* CreateDecoder();
musik::core::sdk::IDecoder* CreateDecoder();
void Destroy();
bool CanHandle(const char* type) const;
};

View File

@ -49,17 +49,17 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
#endif
class FlacPlugin : public musik::core::IPlugin {
class FlacPlugin : public musik::core::sdk::IPlugin {
void Destroy() { delete this; };
const char* Name() { return "FLAC IDecoder"; }
const char* Version() { return "0.2"; }
const char* Author() { return "Daniel Önnerby, clangen"; }
};
extern "C" DLLEXPORT musik::core::IPlugin* GetPlugin() {
extern "C" DLLEXPORT musik::core::sdk::IPlugin* GetPlugin() {
return new FlacPlugin();
}
extern "C" DLLEXPORT musik::core::audio::IDecoderFactory* GetDecoderFactory() {
extern "C" DLLEXPORT musik::core::sdk::IDecoderFactory* GetDecoderFactory() {
return new FlacDecoderFactory();
}

View File

@ -36,8 +36,8 @@
#include "M4aDecoder.h"
#include <string.h>
using musik::core::io::IDataStream;
using musik::core::audio::IBuffer;
using musik::core::sdk::IDataStream;
using musik::core::sdk::IBuffer;
static uint32_t streamReadCallback(void *userData, void *buffer, uint32_t length) {
IDataStream *stream = static_cast<IDataStream*>(userData);
@ -85,7 +85,7 @@ M4aDecoder::M4aDecoder() {
M4aDecoder::~M4aDecoder() {
}
bool M4aDecoder::Open(musik::core::io::IDataStream *stream)
bool M4aDecoder::Open(musik::core::sdk::IDataStream *stream)
{
decoder = NeAACDecOpen();
if (!decoder) {

View File

@ -38,15 +38,15 @@
#include <neaacdec.h>
#include <mp4ff.h>
class M4aDecoder : public musik::core::audio::IDecoder {
class M4aDecoder : public musik::core::sdk::IDecoder {
public:
M4aDecoder();
~M4aDecoder();
virtual void Destroy();
virtual double SetPosition(double seconds);
virtual bool GetBuffer(musik::core::audio::IBuffer *buffer);
virtual bool Open(musik::core::io::IDataStream *stream);
virtual bool GetBuffer(musik::core::sdk::IBuffer *buffer);
virtual bool Open(musik::core::sdk::IDataStream *stream);
private:
NeAACDecHandle decoder;

View File

@ -38,7 +38,7 @@
#include "M4aDecoder.h"
#include <algorithm>
using musik::core::audio::IDecoder;
using musik::core::sdk::IDecoder;
M4aDecoderFactory::M4aDecoderFactory() {
}

View File

@ -36,12 +36,12 @@
#include <core/sdk/IDecoderFactory.h>
class M4aDecoderFactory : public musik::core::audio::IDecoderFactory {
class M4aDecoderFactory : public musik::core::sdk::IDecoderFactory {
public:
M4aDecoderFactory();
virtual ~M4aDecoderFactory();
musik::core::audio::IDecoder* CreateDecoder();
musik::core::sdk::IDecoder* CreateDecoder();
void Destroy();
bool CanHandle(const char* source) const;
};

View File

@ -49,7 +49,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
#endif
class AacDecoderPlugin : public musik::core::IPlugin {
class AacDecoderPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; };
virtual const char* Name() { return "M4A IDecoder"; };
@ -57,10 +57,10 @@ class AacDecoderPlugin : public musik::core::IPlugin {
virtual const char* Author() { return "Björn Olievier, clangen"; };
};
extern "C" DLLEXPORT musik::core::IPlugin* GetPlugin() {
extern "C" DLLEXPORT musik::core::sdk::IPlugin* GetPlugin() {
return new AacDecoderPlugin();
}
extern "C" DLLEXPORT musik::core::audio::IDecoderFactory* GetDecoderFactory() {
extern "C" DLLEXPORT musik::core::sdk::IDecoderFactory* GetDecoderFactory() {
return new M4aDecoderFactory();
}

View File

@ -42,8 +42,7 @@
#include <iostream>
#endif
using namespace musik::core::audio;
using namespace musik::core::io;
using namespace musik::core::sdk;
Mpg123Decoder::Mpg123Decoder()
: cachedLength(0)

View File

@ -43,21 +43,21 @@ typedef long ssize_t;
#include <mpg123.h>
class Mpg123Decoder : public musik::core::audio::IDecoder {
class Mpg123Decoder : public musik::core::sdk::IDecoder {
public:
Mpg123Decoder();
virtual ~Mpg123Decoder();
virtual bool Open(musik::core::io::IDataStream *dataStream);
virtual bool Open(musik::core::sdk::IDataStream *dataStream);
virtual double SetPosition(double seconds);
virtual bool GetBuffer(musik::core::audio::IBuffer *buffer);
virtual bool GetBuffer(musik::core::sdk::IBuffer *buffer);
virtual void Destroy();
private:
bool Feed();
private:
musik::core::io::IDataStream *fileStream;
musik::core::sdk::IDataStream *fileStream;
mpg123_handle *decoder;
unsigned long cachedLength;

View File

@ -40,7 +40,7 @@
#include "Mpg123Decoder.h"
#include "mpg123.h"
using namespace musik::core::audio;
using namespace musik::core::sdk;
Mpg123DecoderFactory::Mpg123DecoderFactory() {
mpg123_init();

View File

@ -36,12 +36,12 @@
#include <core/sdk/IDecoderFactory.h>
class Mpg123DecoderFactory : public musik::core::audio::IDecoderFactory {
class Mpg123DecoderFactory : public musik::core::sdk::IDecoderFactory {
public:
Mpg123DecoderFactory();
virtual ~Mpg123DecoderFactory();
musik::core::audio::IDecoder* CreateDecoder();
musik::core::sdk::IDecoder* CreateDecoder();
void Destroy();
bool CanHandle(const char* type) const;
};

View File

@ -48,17 +48,17 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
#endif
class Mpg123Plugin : public musik::core::IPlugin {
class Mpg123Plugin : public musik::core::sdk::IPlugin {
virtual void Destroy() { delete this; }
virtual const char* Name() { return "mpg123 IDecoder"; }
virtual const char* Version() { return "0.2"; }
virtual const char* Author() { return "Daniel Önnerby, clangen"; }
};
extern "C" DLLEXPORT musik::core::IPlugin* GetPlugin() {
extern "C" DLLEXPORT musik::core::sdk::IPlugin* GetPlugin() {
return new Mpg123Plugin();
}
extern "C" DLLEXPORT musik::core::audio::IDecoderFactory* GetDecoderFactory() {
extern "C" DLLEXPORT musik::core::sdk::IDecoderFactory* GetDecoderFactory() {
return new Mpg123DecoderFactory();
}

View File

@ -94,7 +94,7 @@ int OggDecoder::OggClose(void *datasource) {
OggDecoder::~OggDecoder() {
}
bool OggDecoder::Open(musik::core::io::IDataStream *fileStream) {
bool OggDecoder::Open(musik::core::sdk::IDataStream *fileStream) {
this->fileStream = fileStream;
if (ov_open_callbacks(this, &this->oggFile, NULL, 0, this->oggCallbacks) != 0) {

View File

@ -38,20 +38,20 @@
#include "vorbis/codec.h"
#include "vorbis/vorbisfile.h"
using namespace musik::core::audio;
using namespace musik::core::sdk;
class OggDecoder : public IDecoder
{
public:
public:
OggDecoder();
~OggDecoder();
public:
public:
virtual void Destroy();
virtual double SetPosition(double second);
virtual bool GetBuffer(IBuffer *buffer);
virtual bool Open(musik::core::io::IDataStream *fileStream);
virtual bool Open(musik::core::sdk::IDataStream *fileStream);
public:
/* libvorbis callbacks */
@ -60,8 +60,8 @@ public:
static long OggTell(void *datasource);
static int OggClose(void *datasource);
protected:
musik::core::io::IDataStream *fileStream;
protected:
musik::core::sdk::IDataStream *fileStream;
OggVorbis_File oggFile;
ov_callbacks oggCallbacks;
};

View File

@ -36,14 +36,14 @@
#include <core/sdk/IDecoderFactory.h>
using namespace musik::core::audio;
using namespace musik::core::sdk;
class OggDecoderFactory : public IDecoderFactory {
public:
OggDecoderFactory();
~OggDecoderFactory();
~OggDecoderFactory();
IDecoder* CreateDecoder();
void Destroy();
bool CanHandle(const char* type) const;
IDecoder* CreateDecoder();
void Destroy();
bool CanHandle(const char* type) const;
};

View File

@ -48,7 +48,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
#endif
class OggDecoderPlugin : public musik::core::IPlugin {
class OggDecoderPlugin : public musik::core::sdk::IPlugin {
public:
void Destroy() { delete this; };
const char* Name() { return "Ogg IDecoder"; };
@ -56,7 +56,7 @@ public:
const char* Author() { return "Björn Olievier, clangen"; };
};
extern "C" DLLEXPORT musik::core::IPlugin* GetPlugin() {
extern "C" DLLEXPORT musik::core::sdk::IPlugin* GetPlugin() {
return new OggDecoderPlugin();
}

View File

@ -115,7 +115,7 @@ bool TaglibMetadataReader::CanRead(const char *extension){
return false;
}
bool TaglibMetadataReader::Read(const char* uri, musik::core::IMetadataWriter *track) {
bool TaglibMetadataReader::Read(const char* uri, musik::core::sdk::IMetadataWriter *track) {
std::string path(uri);
std::string extension;
@ -137,7 +137,7 @@ bool TaglibMetadataReader::Read(const char* uri, musik::core::IMetadataWriter *t
#include <iostream>
bool TaglibMetadataReader::GetGenericTag(const char* uri, musik::core::IMetadataWriter *target) {
bool TaglibMetadataReader::GetGenericTag(const char* uri, musik::core::sdk::IMetadataWriter *target) {
#ifdef WIN32
TagLib::FileRef file(utf8to16(uri).c_str());
#else
@ -186,7 +186,7 @@ bool TaglibMetadataReader::GetGenericTag(const char* uri, musik::core::IMetadata
return false;
}
bool TaglibMetadataReader::GetID3v2Tag(const char* uri, musik::core::IMetadataWriter *track) {
bool TaglibMetadataReader::GetID3v2Tag(const char* uri, musik::core::sdk::IMetadataWriter *track) {
TagLib::ID3v2::FrameFactory::instance()->setDefaultTextEncoding(TagLib::String::UTF8);
#ifdef WIN32
@ -356,7 +356,7 @@ bool TaglibMetadataReader::GetID3v2Tag(const char* uri, musik::core::IMetadataWr
void TaglibMetadataReader::SetTagValue(
const char* key,
const TagLib::String tagString,
musik::core::IMetadataWriter *track)
musik::core::sdk::IMetadataWriter *track)
{
std::string value(tagString.to8Bit(true));
track->SetValue(key, value.c_str());
@ -365,7 +365,7 @@ void TaglibMetadataReader::SetTagValue(
void TaglibMetadataReader::SetTagValue(
const char* key,
const char* string,
musik::core::IMetadataWriter *track)
musik::core::sdk::IMetadataWriter *track)
{
std::string temp(string);
track->SetValue(key, temp.c_str());
@ -374,7 +374,7 @@ void TaglibMetadataReader::SetTagValue(
void TaglibMetadataReader::SetTagValue(
const char* key,
const int tagInt,
musik::core::IMetadataWriter *target)
musik::core::sdk::IMetadataWriter *target)
{
std::string temp = boost::str(boost::format("%1%") % tagInt);
target->SetValue(key, temp.c_str());
@ -383,7 +383,7 @@ void TaglibMetadataReader::SetTagValue(
void TaglibMetadataReader::SetTagValues(
const char* key,
const TagLib::ID3v2::FrameList &frame,
musik::core::IMetadataWriter *target)
musik::core::sdk::IMetadataWriter *target)
{
if (!frame.isEmpty()) {
TagLib::ID3v2::FrameList::ConstIterator value = frame.begin();
@ -401,7 +401,7 @@ void TaglibMetadataReader::SetTagValues(
void TaglibMetadataReader::SetSlashSeparatedValues(
const char* key,
TagLib::String tagString,
musik::core::IMetadataWriter *track)
musik::core::sdk::IMetadataWriter *track)
{
if(!tagString.isEmpty()) {
std::string value(tagString.to8Bit(true));
@ -419,7 +419,7 @@ void TaglibMetadataReader::SetSlashSeparatedValues(
void TaglibMetadataReader::SetSlashSeparatedValues(
const char* key,
const TagLib::ID3v2::FrameList &frame,
musik::core::IMetadataWriter *track)
musik::core::sdk::IMetadataWriter *track)
{
if(!frame.isEmpty()) {
TagLib::ID3v2::FrameList::ConstIterator value = frame.begin();
@ -432,7 +432,7 @@ void TaglibMetadataReader::SetSlashSeparatedValues(
void TaglibMetadataReader::SetAudioProperties(
TagLib::AudioProperties *audioProperties,
musik::core::IMetadataWriter *track)
musik::core::sdk::IMetadataWriter *track)
{
/* FIXME: it's overkill to bring boost in just to convert ints to strings */

View File

@ -55,51 +55,51 @@
#include <set>
#include <core/sdk/IMetadataReader.h>
class TaglibMetadataReader : public musik::core::metadata::IMetadataReader {
class TaglibMetadataReader : public musik::core::sdk::IMetadataReader {
public:
TaglibMetadataReader();
virtual ~TaglibMetadataReader();
virtual bool Read(const char *uri, musik::core::IMetadataWriter *target);
virtual bool Read(const char *uri, musik::core::sdk::IMetadataWriter *target);
virtual bool CanRead(const char *extension);
virtual void Destroy();
private:
void SetTagValue(
const char* key,
const char* string,musik::core::IMetadataWriter *target);
const char* string,musik::core::sdk::IMetadataWriter *target);
void SetTagValue(
const char* key,
const TagLib::String tagString,
musik::core::IMetadataWriter *target);
musik::core::sdk::IMetadataWriter *target);
void SetTagValue(
const char* key,
const int tagInt,musik::core::IMetadataWriter *target);
const int tagInt,musik::core::sdk::IMetadataWriter *target);
void SetTagValues(const char* key,
const TagLib::ID3v2::FrameList &frame,
musik::core::IMetadataWriter *target);
musik::core::sdk::IMetadataWriter *target);
void SetAudioProperties(
TagLib::AudioProperties *audioProperties,
musik::core::IMetadataWriter *target);
musik::core::sdk::IMetadataWriter *target);
void SetSlashSeparatedValues(
const char* key,
const TagLib::ID3v2::FrameList &frame,
musik::core::IMetadataWriter *target);
musik::core::sdk::IMetadataWriter *target);
void SetSlashSeparatedValues(
const char* key,
TagLib::String tagString,
musik::core::IMetadataWriter *target);
musik::core::sdk::IMetadataWriter *target);
bool GetID3v2Tag(
const char* uri,
musik::core::IMetadataWriter *target);
musik::core::sdk::IMetadataWriter *target);
bool GetGenericTag(
const char* uri,
musik::core::IMetadataWriter *target);
musik::core::sdk::IMetadataWriter *target);
};

View File

@ -48,7 +48,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
#endif
class TaglibPlugin : public musik::core::IPlugin {
class TaglibPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; }
virtual const char* Name() { return "Taglib 1.11 IMetadataReader"; }
@ -56,10 +56,10 @@ class TaglibPlugin : public musik::core::IPlugin {
virtual const char* Author() { return "Daniel Önnerby, clangen"; }
};
extern "C" DLLEXPORT musik::core::metadata::IMetadataReader* GetMetadataReader() {
extern "C" DLLEXPORT musik::core::sdk::IMetadataReader* GetMetadataReader() {
return new TaglibMetadataReader();
}
extern "C" DLLEXPORT musik::core::IPlugin* GetPlugin() {
extern "C" DLLEXPORT musik::core::sdk::IPlugin* GetPlugin() {
return new TaglibPlugin();
}

View File

@ -36,13 +36,13 @@
#include "pch.h"
#include <list>
#include <boost/thread/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/condition.hpp>
#include "WaveOutBuffer.h"
#include <core/sdk/IOutput.h>
using namespace musik::core::audio;
using namespace musik::core::sdk;
class WaveOut : public IOutput {
public:
@ -56,7 +56,7 @@ class WaveOut : public IOutput {
virtual void Stop();
virtual bool Play(IBuffer *buffer, IBufferProvider *provider);
public:
public:
typedef std::shared_ptr<WaveOutBuffer> WaveOutBufferPtr;
static DWORD WINAPI WaveCallbackThreadProc(LPVOID params);
@ -73,7 +73,7 @@ class WaveOut : public IOutput {
friend class WaveOutBuffer;
/* note we apparently use a std::list<> here, and not std::set<> because
when we need to do a lookup we have a WaveOutBuffer*, and not a shared_ptr.
when we need to do a lookup we have a WaveOutBuffer*, and not a shared_ptr.
we could fix this up by using boost::enable_shared_from_this */
typedef std::list<WaveOutBufferPtr> BufferList;

View File

@ -46,7 +46,7 @@
class WaveOut;
using namespace musik::core::audio;
using namespace musik::core::sdk;
class WaveOutBuffer
{

View File

@ -41,17 +41,17 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
return true;
}
class WaveOutPlugin : public musik::core::IPlugin {
class WaveOutPlugin : public musik::core::sdk::IPlugin {
void Destroy() { delete this; };
const char* Name() { return "WaveOut IOutput"; };
const char* Version() { return "0.2"; };
const char* Author() { return "Björn Olievier, clangen"; };
};
extern "C" __declspec(dllexport) musik::core::IPlugin* GetPlugin() {
extern "C" __declspec(dllexport) musik::core::sdk::IPlugin* GetPlugin() {
return new WaveOutPlugin();
}
extern "C" __declspec(dllexport) musik::core::audio::IOutput* GetAudioOutput() {
extern "C" __declspec(dllexport) musik::core::sdk::IOutput* GetAudioOutput() {
return new WaveOut();
}

View File

@ -21,7 +21,6 @@ set(CORE_SOURCES
./library/track/Track.cpp
./plugin/PluginFactory.cpp
./support/Common.cpp
./support/NonLibraryTrackHelper.cpp
./support/Preferences.cpp
./support/PreferenceKeys.cpp
./support/Version.cpp

View File

@ -44,7 +44,7 @@ namespace musik { namespace core { namespace audio {
class Stream;
typedef std::shared_ptr<Buffer> BufferPtr;
class Buffer : public IBuffer {
class Buffer : public musik::core::sdk::IBuffer {
private:
Buffer();

View File

@ -44,6 +44,8 @@
#define FFT_N 512
using namespace musik::core::audio;
using namespace musik::core::sdk;
using std::min;
using std::max;

View File

@ -51,9 +51,9 @@ namespace musik { namespace core { namespace audio {
typedef std::shared_ptr<Player> PlayerPtr;
class Output;
typedef std::shared_ptr<IOutput> OutputPtr;
typedef std::shared_ptr<musik::core::sdk::IOutput> OutputPtr;
class Player : public IBufferProvider {
class Player : public musik::core::sdk::IBufferProvider {
public:
static OutputPtr CreateDefaultOutput();
@ -67,7 +67,7 @@ namespace musik { namespace core { namespace audio {
~Player();
virtual void OnBufferProcessed(IBuffer *buffer);
virtual void OnBufferProcessed(musik::core::sdk::IBuffer *buffer);
void Play();
void Stop();

View File

@ -40,6 +40,7 @@
#include <core/plugin/PluginFactory.h>
using namespace musik::core::audio;
using namespace musik::core::sdk;
using musik::core::PluginFactory;
static std::string TAG = "Stream";

View File

@ -51,6 +51,10 @@ namespace musik { namespace core { namespace audio {
typedef std::shared_ptr<Stream> StreamPtr;
class Stream {
using IDSP = musik::core::sdk::IDSP;
using IDecoder = musik::core::sdk::IDecoder;
using IDecoderFactory = musik::core::sdk::IDecoderFactory;
public:
static StreamPtr Create(unsigned int options=0);

View File

@ -40,6 +40,7 @@
#include <algorithm>
using namespace musik::core::audio;
using namespace musik::core::sdk;
static std::vector<std::shared_ptr<IVisualizer > > visualizers;
static std::atomic<bool> initialized;

View File

@ -40,13 +40,13 @@
namespace musik { namespace core { namespace audio { namespace vis {
ISpectrumVisualizer* SpectrumVisualizer();
IPcmVisualizer* PcmVisualizer();
musik::core::sdk::ISpectrumVisualizer* SpectrumVisualizer();
musik::core::sdk::IPcmVisualizer* PcmVisualizer();
std::shared_ptr<IVisualizer> GetVisualizer(size_t index);
std::shared_ptr<musik::core::sdk::IVisualizer> GetVisualizer(size_t index);
size_t VisualizerCount();
void SetSelectedVisualizer(std::shared_ptr<IVisualizer> visualizer);
std::shared_ptr<IVisualizer> SelectedVisualizer();
void SetSelectedVisualizer(std::shared_ptr<musik::core::sdk::IVisualizer> visualizer);
std::shared_ptr<musik::core::sdk::IVisualizer> SelectedVisualizer();
void HideSelectedVisualizer();
} } } }

View File

@ -109,7 +109,6 @@
<ClCompile Include="audio\Stream.cpp" />
<ClCompile Include="plugin\PluginFactory.cpp" />
<ClCompile Include="support\Common.cpp" />
<ClCompile Include="support\NonLibraryTrackHelper.cpp" />
<ClCompile Include="support\PreferenceKeys.cpp" />
<ClCompile Include="support\Preferences.cpp" />
<ClCompile Include="support\Version.cpp" />
@ -148,6 +147,8 @@
<ClInclude Include="sdk\IOutput.h" />
<ClInclude Include="sdk\IBufferProvider.h" />
<ClInclude Include="sdk\IPcmVisualizer.h" />
<ClInclude Include="sdk\IPlaybackRemote.h" />
<ClInclude Include="sdk\IPlaybackService.h" />
<ClInclude Include="sdk\IPlugin.h" />
<ClInclude Include="sdk\IMetadataWriter.h" />
<ClInclude Include="db\Connection.h" />
@ -158,9 +159,9 @@
<ClInclude Include="audio\Player.h" />
<ClInclude Include="audio\Stream.h" />
<ClInclude Include="sdk\ISpectrumVisualizer.h" />
<ClInclude Include="sdk\ITrack.h" />
<ClInclude Include="sdk\IVisualizer.h" />
<ClInclude Include="support\Common.h" />
<ClInclude Include="support\NonLibraryTrackHelper.h" />
<ClInclude Include="support\PreferenceKeys.h" />
<ClInclude Include="support\Preferences.h" />
<ClInclude Include="support\Version.h" />

View File

@ -103,9 +103,6 @@
<ClCompile Include="library\LocalLibrary.cpp">
<Filter>src\library</Filter>
</ClCompile>
<ClCompile Include="support\NonLibraryTrackHelper.cpp">
<Filter>src\support</Filter>
</ClCompile>
<ClCompile Include="audio\GaplessTransport.cpp">
<Filter>src\audio</Filter>
</ClCompile>
@ -240,9 +237,6 @@
<ClInclude Include="library\LocalLibraryConstants.h">
<Filter>src\library</Filter>
</ClInclude>
<ClInclude Include="support\NonLibraryTrackHelper.h">
<Filter>src\support</Filter>
</ClInclude>
<ClInclude Include="audio\ITransport.h">
<Filter>src\audio</Filter>
</ClInclude>
@ -264,5 +258,14 @@
<ClInclude Include="sdk\IVisualizer.h">
<Filter>src\sdk</Filter>
</ClInclude>
<ClInclude Include="sdk\IPlaybackRemote.h">
<Filter>src\sdk</Filter>
</ClInclude>
<ClInclude Include="sdk\IPlaybackService.h">
<Filter>src\sdk</Filter>
</ClInclude>
<ClInclude Include="sdk\ITrack.h">
<Filter>src\sdk</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -40,6 +40,7 @@
#include <core/io/LocalFileStream.h>
using namespace musik::core::io;
using namespace musik::core::sdk;
DataStreamFactory::DataStreamFactory() {
typedef IDataStreamFactory PluginType;

View File

@ -42,14 +42,14 @@ namespace musik { namespace core { namespace io {
class DataStreamFactory {
public:
typedef std::shared_ptr<IDataStream> DataStreamPtr;
typedef std::shared_ptr<musik::core::sdk::IDataStream> DataStreamPtr;
private:
DataStreamFactory();
static DataStreamFactory* Instance();
private:
typedef std::vector<std::shared_ptr<IDataStreamFactory> > DataStreamFactoryVector;
typedef std::vector<std::shared_ptr<musik::core::sdk::IDataStreamFactory> > DataStreamFactoryVector;
DataStreamFactoryVector dataStreamFactories;
public:

View File

@ -43,6 +43,7 @@
static const std::string TAG = "LocalFileStream";
using namespace musik::core::io;
using namespace musik::core::sdk;
LocalFileStream::LocalFileStream()
: file(NULL)

View File

@ -46,8 +46,10 @@
namespace musik { namespace core { namespace io {
class LocalFileStream : public IDataStream {
class LocalFileStream : public musik::core::sdk::IDataStream{
public:
using PositionType = musik::core::sdk::PositionType;
LocalFileStream();
virtual ~LocalFileStream();

View File

@ -60,7 +60,7 @@ static const int MAX_THREADS = 10;
static const size_t NOTIFY_INTERVAL = 300;
using namespace musik::core;
using namespace musik::core::metadata;
using namespace musik::core::sdk;
using namespace musik::core::audio;
using Thread = std::unique_ptr<boost::thread>;
@ -592,7 +592,7 @@ void Indexer::ProcessAddRemoveQueue() {
}
void Indexer::RunAnalyzers() {
typedef audio::IAnalyzer PluginType;
typedef sdk::IAnalyzer PluginType;
typedef PluginFactory::DestroyDeleter<PluginType> Deleter;
typedef std::shared_ptr<PluginType> PluginPtr;
typedef std::vector<PluginPtr> PluginVector;
@ -638,7 +638,7 @@ void Indexer::RunAnalyzers() {
audio::StreamPtr stream = audio::Stream::Create(audio::Stream::NoDSP);
if (stream) {
if (stream->OpenStream(track.URI())) {
if (stream->OpenStream(track.Uri())) {
/* decode the stream quickly, passing to all analyzers */

View File

@ -113,10 +113,10 @@ namespace musik { namespace core {
};
typedef std::vector<std::shared_ptr<
metadata::IMetadataReader> > MetadataReaderList;
musik::core::sdk::IMetadataReader> > MetadataReaderList;
typedef std::vector<std::shared_ptr<
musik::core::audio::IDecoderFactory> > DecoderList;
musik::core::sdk::IDecoderFactory> > DecoderList;
std::deque<AddRemoveContext> addRemoveQueue;

View File

@ -36,6 +36,7 @@
#include <core/library/track/IndexerTrack.h>
#include <core/sdk/config.h>
#include <core/support/Common.h>
#include <core/db/Connection.h>
#include <core/db/Statement.h>
@ -105,10 +106,18 @@ void IndexerTrack::SetThumbnail(const char *data,long size) {
memcpy(this->internalMetadata->thumbnailData, data, size);
}
std::string IndexerTrack::URI() {
std::string IndexerTrack::Uri() {
return this->GetValue("filename");
}
int IndexerTrack::GetValue(const char* key, char* dst, int size) {
return musik::sdk::copyString(this->GetValue(key), dst, size);
}
int IndexerTrack::Uri(char* dst, int size) {
return musik::sdk::copyString(this->Uri(), dst, size);
}
Track::MetadataIteratorRange IndexerTrack::GetValues(const char* metakey) {
if (this->internalMetadata) {
return this->internalMetadata->metadata.equal_range(metakey);

View File

@ -45,11 +45,15 @@ namespace musik { namespace core {
IndexerTrack(DBID id);
virtual ~IndexerTrack(void);
virtual std::string GetValue(const char* metakey);
virtual void SetValue(const char* metakey, const char* value);
virtual void ClearValue(const char* metakey);
virtual void SetThumbnail(const char *data, long size);
virtual std::string URI();
virtual std::string GetValue(const char* metakey);
virtual int GetValue(const char* key, char* dst, int size);
virtual std::string Uri();
virtual int Uri(char* dst, int size);
virtual MetadataIteratorRange GetValues(const char* metakey);
virtual MetadataIteratorRange GetAllValues();

View File

@ -37,6 +37,7 @@
#include <core/library/track/LibraryTrack.h>
#include <core/library/LibraryFactory.h>
#include <core/sdk/config.h>
#include <core/support/Common.h>
#include <core/db/Connection.h>
#include <core/db/Statement.h>
@ -92,10 +93,18 @@ void LibraryTrack::SetThumbnail(const char *data, long size) {
memcpy(this->data.thumbnailData, data, size);
}
std::string LibraryTrack::URI() {
std::string LibraryTrack::Uri() {
return this->GetValue("filename");
}
int LibraryTrack::GetValue(const char* key, char* dst, int size) {
return musik::sdk::copyString(this->GetValue(key), dst, size);
}
int LibraryTrack::Uri(char* dst, int size) {
return musik::sdk::copyString(this->Uri(), dst, size);
}
Track::MetadataIteratorRange LibraryTrack::GetValues(const char* metakey) {
boost::mutex::scoped_lock lock(this->data.mutex);
return this->data.metadata.equal_range(metakey);

View File

@ -53,12 +53,15 @@ namespace musik { namespace core {
virtual DBID Id();
virtual void SetId(DBID id) { this->id = id; }
virtual std::string GetValue(const char* metakey);
virtual void SetValue(const char* metakey, const char* value);
virtual void ClearValue(const char* metakey);
virtual void SetThumbnail(const char *data, long size);
virtual std::string URI();
virtual std::string GetValue(const char* metakey);
virtual std::string Uri();
virtual int GetValue(const char* key, char* dst, int size);
virtual int Uri(char* dst, int size);
virtual MetadataIteratorRange GetValues(const char* metakey);
virtual MetadataIteratorRange GetAllValues();

View File

@ -36,6 +36,7 @@
#include <core/sdk/IMetadataWriter.h>
#include <core/library/ILibrary.h>
#include <core/sdk/ITrack.h>
#include <boost/shared_ptr.hpp>
#include <vector>
#include <map>
@ -46,7 +47,10 @@ namespace musik { namespace core {
typedef std::shared_ptr<Track> TrackPtr;
typedef std::vector<TrackPtr> TrackVector;
class Track : public IMetadataWriter {
class Track :
public musik::core::sdk::IMetadataWriter,
public musik::core::sdk::ITrack
{
public:
typedef std::multimap<std::string, std::string> MetadataMap;
typedef std::pair<MetadataMap::iterator, MetadataMap::iterator> MetadataIteratorRange;
@ -60,7 +64,7 @@ namespace musik { namespace core {
virtual int LibraryId();
virtual std::string GetValue(const char* metakey) = 0;
virtual std::string URI() = 0;
virtual std::string Uri() = 0;
virtual MetadataIteratorRange GetValues(const char* metakey) = 0;
virtual MetadataIteratorRange GetAllValues() = 0;

View File

@ -61,12 +61,12 @@ namespace musik { namespace core {
private:
#ifdef WIN32
typedef musik::core::IPlugin* STDCALL(CallGetPlugin);
typedef musik::core::sdk::IPlugin* STDCALL(CallGetPlugin);
#else
typedef musik::core::IPlugin* (*CallGetPlugin)();
typedef musik::core::sdk::IPlugin* (*CallGetPlugin)();
#endif
typedef std::vector<IPlugin*> PluginList;
typedef std::vector<musik::core::sdk::IPlugin*> PluginList;
typedef std::vector<void*> HandleList;
PluginList loadedPlugins;

View File

@ -38,14 +38,14 @@
#include "IMetadataWriter.h"
#include "IBuffer.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IAnalyzer {
public:
virtual void Destroy() = 0;
virtual bool Start(musik::core::IMetadataWriter *target) = 0;
virtual bool Analyze(musik::core::IMetadataWriter *target, IBuffer *buffer) = 0;
virtual bool End(musik::core::IMetadataWriter *target) = 0;
virtual bool Start(musik::core::sdk::IMetadataWriter *target) = 0;
virtual bool Analyze(musik::core::sdk::IMetadataWriter *target, IBuffer *buffer) = 0;
virtual bool End(musik::core::sdk::IMetadataWriter *target) = 0;
};
} } }

View File

@ -36,7 +36,7 @@
#include "config.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IBuffer {
public:

View File

@ -37,7 +37,7 @@
#include "config.h"
#include "IBuffer.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IBufferProvider {
public:

View File

@ -37,7 +37,7 @@
#include "config.h"
#include "IBuffer.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IDSP {
public:

View File

@ -36,7 +36,7 @@
#include "config.h"
namespace musik { namespace core { namespace io {
namespace musik { namespace core { namespace sdk {
typedef long PositionType;

View File

@ -37,7 +37,7 @@
#include "config.h"
#include "IDataStream.h"
namespace musik { namespace core { namespace io {
namespace musik { namespace core { namespace sdk {
class IDataStreamFactory{
public:
virtual bool CanRead(const char *uri) = 0;

View File

@ -38,14 +38,14 @@
#include "IDataStream.h"
#include "IBuffer.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IDecoder {
public:
virtual void Destroy() = 0;
virtual double SetPosition(double seconds) = 0;
virtual bool GetBuffer(IBuffer *buffer) = 0;
virtual bool Open(musik::core::io::IDataStream *stream) = 0;
virtual bool Open(musik::core::sdk::IDataStream *stream) = 0;
};
} } }

View File

@ -37,7 +37,7 @@
#include "config.h"
#include "IDecoder.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IDecoderFactory{
public:

View File

@ -37,11 +37,11 @@
#include "config.h"
#include "IMetadataWriter.h"
namespace musik { namespace core { namespace metadata {
namespace musik { namespace core { namespace sdk {
class IMetadataReader {
public:
virtual bool Read(const char *uri, musik::core::IMetadataWriter *target) = 0;
virtual bool Read(const char *uri, musik::core::sdk::IMetadataWriter *target) = 0;
virtual bool CanRead(const char *extension) = 0;
virtual void Destroy() = 0;
};

View File

@ -36,7 +36,7 @@
#include "config.h"
namespace musik { namespace core {
namespace musik { namespace core { namespace sdk {
class IMetadataWriter {
public:
@ -45,4 +45,4 @@ namespace musik { namespace core {
virtual void SetThumbnail(const char *data, long size) = 0; /* should be SetBlob with a key */
};
} }
} } }

View File

@ -39,7 +39,7 @@
#include "IBuffer.h"
#include "IBufferProvider.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IOutput {
public:

View File

@ -37,12 +37,12 @@
#include "IBuffer.h"
#include "IVisualizer.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IPcmVisualizer : public IVisualizer {
public:
virtual void Destroy() = 0;
virtual void Write(musik::core::audio::IBuffer *target) = 0;
virtual void Write(IBuffer *target) = 0;
};
} } }

View File

@ -0,0 +1,51 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "config.h"
#include "IPlaybackService.h"
#include "ITrack.h"
namespace musik { namespace core {
class IPlaybackRemote {
public:
virtual void Destroy() = 0;
virtual void SetPlaybackService(IPlaybackService* playback) = 0;
virtual void OnTrackChanged(ITrack* track) = 0;
};
} }

View File

@ -34,52 +34,32 @@
#pragma once
#include <core/config.h>
#include <core/library/track/Track.h>
#include <boost/scoped_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <sigslot/sigslot.h>
#include <list>
#include "config.h"
//////////////////////////////////////////////////////////////////////////////
namespace musik { namespace core {
namespace musik{ namespace core{
class IPlaybackService {
public:
enum RepeatMode {
RepeatNone,
RepeatTrack,
RepeatList
};
//////////////////////////////////////////////////////////////////////////////
virtual void Play(size_t index) = 0;
virtual bool Next() = 0;
virtual bool Previous() = 0;
virtual void Stop() = 0;
class NonLibraryTrackHelper{
public:
static NonLibraryTrackHelper& Instance();
virtual RepeatMode GetRepeatMode() = 0;
virtual void SetRepeatMode(RepeatMode mode) = 0;
void ReadTrack(musik::core::TrackPtr track);
virtual bool IsShuffled() = 0;
virtual void ToggleShuffle() = 0;
typedef sigslot::signal1<musik::core::TrackPtr> TrackMetadataUpdatedEvent;
TrackMetadataUpdatedEvent TrackMetadataUpdated;
private:
static NonLibraryTrackHelper sInstance;
NonLibraryTrackHelper();
~NonLibraryTrackHelper();
void ThreadLoop();
private:
boost::mutex mutex;
bool threadIsRunning;
typedef std::weak_ptr<musik::core::Track> TrackWeakPtr;
std::list<TrackWeakPtr> tracksToRead;
typedef boost::scoped_ptr<boost::thread> ThreadPtr;
ThreadPtr helperThread;
};
//////////////////////////////////////////////////////////////////////////////
} } // musik::core
//////////////////////////////////////////////////////////////////////////////
virtual size_t GetIndex() = 0;
virtual size_t Count() = 0;
};
} }

View File

@ -36,7 +36,7 @@
#include "config.h"
namespace musik { namespace core {
namespace musik { namespace core { namespace sdk {
class IPlugin {
public:
@ -46,5 +46,5 @@ namespace musik { namespace core {
virtual const char* Author() = 0;
};
} }
} } }

View File

@ -37,7 +37,7 @@
#include "IBuffer.h"
#include "IVisualizer.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class ISpectrumVisualizer : public IVisualizer {
public:

48
src/core/sdk/ITrack.h Normal file
View File

@ -0,0 +1,48 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "config.h"
namespace musik { namespace core { namespace sdk {
class ITrack {
public:
virtual int GetValue(const char* key, char* dst, int size) = 0;
virtual int Uri(char* dst, int size) = 0;
};
} } }

View File

@ -36,7 +36,7 @@
#include "IPlugin.h"
namespace musik { namespace core { namespace audio {
namespace musik { namespace core { namespace sdk {
class IVisualizer : public IPlugin {
public:

View File

@ -74,5 +74,15 @@ namespace musik {
s.size() >= suffix.size() &&
s.rfind(suffix) == (s.size() - suffix.size());
}
static inline size_t copyString(const std::string& src, char* dst, size_t size) {
size_t len = src.size() + 1; /* space for the null terminator */
if (dst) {
size_t copied = src.copy(dst, size - 1);
dst[copied] = '\0';
return copied + 1;
}
return len;
}
}
}

View File

@ -1,133 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include "NonLibraryTrackHelper.h"
#include <boost/bind.hpp>
#include <core/plugin/PluginFactory.h>
#include <core/sdk/IMetadataReader.h>
#include <core/io/DataStreamFactory.h>
using namespace musik::core;
NonLibraryTrackHelper NonLibraryTrackHelper::sInstance;
NonLibraryTrackHelper::NonLibraryTrackHelper(void)
: threadIsRunning(false) {
}
NonLibraryTrackHelper::~NonLibraryTrackHelper(void) {
}
NonLibraryTrackHelper& NonLibraryTrackHelper::Instance() {
return NonLibraryTrackHelper::sInstance;
}
void NonLibraryTrackHelper::ReadTrack(musik::core::TrackPtr track) {
bool threadRunning = false;
{
boost::mutex::scoped_lock lock(this->mutex);
this->tracksToRead.push_back(TrackWeakPtr(track));
threadRunning = this->threadIsRunning;
}
if (!threadRunning) {
if (this->helperThread) {
this->helperThread->join();
}
this->helperThread.reset(new boost::thread(
boost::bind(&NonLibraryTrackHelper::ThreadLoop,this)));
}
}
void NonLibraryTrackHelper::ThreadLoop() {
/* load all IMetadataReader plugins */
typedef metadata::IMetadataReader PluginType;
typedef PluginFactory::DestroyDeleter<PluginType> Deleter;
typedef std::vector<std::shared_ptr<metadata::IMetadataReader> > MetadataReaderList;
MetadataReaderList metadataReaders =
PluginFactory::Instance() .QueryInterface<PluginType, Deleter>("GetMetadataReader");
bool moreTracks = true;
while (moreTracks) {
musik::core::TrackPtr track;
/* pop the next track, if one exists. */
{
boost::mutex::scoped_lock lock(this->mutex);
if (!this->tracksToRead.empty()) {
track = this->tracksToRead.front().lock();
this->tracksToRead.pop_front();
}
moreTracks = !this->tracksToRead.empty();
if (!moreTracks) {
this->threadIsRunning = false;
}
}
if (track) {
/* we only support local files. other URIs are ignored */
if (musik::core::io::DataStreamFactory::IsLocalFileStream(track->URI().c_str())) {
std::string url = track->URI();
std::string::size_type lastDot = url.find_last_of(".");
if (lastDot != std::string::npos) {
track->SetValue("extension", url.substr(lastDot + 1).c_str());
}
/* see if we can find a MetadataReader plugin that supports this file */
typedef MetadataReaderList::iterator Iterator;
Iterator it = metadataReaders.begin();
while (it != metadataReaders.end()) {
if ((*it)->CanRead(track->GetValue("extension").c_str())) {
(*it)->Read(url.c_str(), track.get());
break;
}
it++;
}
this->TrackMetadataUpdated(track);
}
}
}
}

View File

@ -285,7 +285,7 @@ void ConsoleLayout::Stop() {
}
void ConsoleLayout::ListPlugins() const {
using musik::core::IPlugin;
using musik::core::sdk::IPlugin;
using musik::core::PluginFactory;
typedef std::vector<std::shared_ptr<IPlugin> > PluginList;

View File

@ -52,7 +52,7 @@ using namespace musik::core::library::constants;
using namespace musik::box;
#define NO_POSITION (size_t) -1
#define URI_AT_INDEX(x) this->playlist.Get(x)->URI()
#define URI_AT_INDEX(x) this->playlist.Get(x)->Uri()
#define PREVIOUS_GRACE_PERIOD 2.0f
#define MESSAGE_STREAM_EVENT 1000
#define MESSAGE_PLAYBACK_EVENT 1001
@ -182,7 +182,7 @@ void PlaybackService::ProcessMessage(IMessage &message) {
things are asynchronous, this may not always be the case, especially if
the tracks are very short, or the user is advancing through songs very
quickly. make compare the track URIs before we update internal state. */
if (this->GetTrackAtIndex(this->nextIndex)->URI() == streamMessage->GetUri()) {
if (this->GetTrackAtIndex(this->nextIndex)->Uri() == streamMessage->GetUri()) {
this->index = this->nextIndex;
this->nextIndex = NO_POSITION;
}
@ -257,6 +257,16 @@ bool PlaybackService::Previous() {
return false;
}
bool PlaybackService::IsShuffled() {
boost::recursive_mutex::scoped_lock lock(this->playlistMutex);
return this->unshuffled.Count() > 0;
}
size_t PlaybackService::Count() {
boost::recursive_mutex::scoped_lock lock(this->playlistMutex);
return this->playlist.Count();
}
void PlaybackService::Play(TrackList& tracks, size_t index) {
/* do the copy outside of the critical section, then swap. */
TrackList temp(this->library);

View File

@ -40,6 +40,7 @@
#include <cursespp/IMessageTarget.h>
#include <core/sdk/IPlaybackService.h>
#include <core/library/track/Track.h>
#include <core/library/ILibrary.h>
#include <core/audio/ITransport.h>
@ -48,46 +49,42 @@
namespace musik {
namespace box {
class PlaybackService : public cursespp::IMessageTarget, public sigslot::has_slots<> {
class PlaybackService :
public musik::core::IPlaybackService,
public cursespp::IMessageTarget,
public sigslot::has_slots<>
{
public:
sigslot::signal2<size_t, musik::core::TrackPtr> TrackChanged;
sigslot::signal0<> ModeChanged;
sigslot::signal1<bool> Shuffled;
enum RepeatMode {
RepeatNone,
RepeatTrack,
RepeatList
};
PlaybackService(
musik::core::LibraryPtr library,
musik::core::audio::ITransport& transport);
~PlaybackService();
/* IMessageTarget */
virtual void ProcessMessage(cursespp::IMessage &message);
/* IPlaybackService */
virtual void Play(size_t index);
virtual bool Next();
virtual bool Previous();
virtual void Stop() { transport.Stop(); }
virtual RepeatMode GetRepeatMode() { return this->repeatMode; }
virtual void SetRepeatMode(RepeatMode mode);
virtual bool IsShuffled();
virtual void ToggleShuffle();
virtual size_t GetIndex();
virtual size_t Count();
/* app-specific implementation */
musik::core::audio::ITransport& GetTransport() { return this->transport; }
void Play(TrackList& tracks, size_t index);
void Play(size_t index);
bool Next();
bool Previous();
void Stop() { transport.Stop(); }
void CopyTo(TrackList& target);
RepeatMode GetRepeatMode() { return this->repeatMode; }
void SetRepeatMode(RepeatMode mode);
bool IsShuffled() { return this->unshuffled.Count() > 0; }
void ToggleShuffle();
musik::core::TrackPtr GetTrackAtIndex(size_t index);
size_t GetIndex();
size_t Count() { return this->playlist.Count(); }
private:
void OnStreamEvent(int eventType, std::string uri);

View File

@ -44,6 +44,7 @@
using musik::core::LibraryPtr;
using musik::core::audio::ITransport;
using namespace musik::core::audio;
using namespace musik::core::sdk;
using namespace musik::box;
GlobalHotkeys::GlobalHotkeys(PlaybackService& playback, LibraryPtr library)

View File

@ -46,7 +46,7 @@ namespace cursespp {
std::string Ellipsize(const std::string& str, size_t len);
std::string Align(const std::string& str, TextAlign align, size_t len);
std::vector<std::string> BreakLines(const std::string& line, size_t width);
std::vector<std::string> BreakLines(const std::string& line, size_t width);
}
namespace key {