From 7bfb7657f6442cd0ad9d08e2f7d0b7887e68f675 Mon Sep 17 00:00:00 2001 From: casey langen Date: Thu, 17 Nov 2016 23:32:37 -0800 Subject: [PATCH] Cleaned up SDK interface namespaces -- they're all in musik::core::sdk now. --- src/contrib/cddadecoder/CddaDataStream.h | 2 +- .../cddadecoder/CddaDataStreamFactory.h | 2 +- src/contrib/cddadecoder/CddaDecoder.h | 3 +- src/contrib/cddadecoder/CddaDecoderFactory.h | 2 +- .../cddadecoder/cddadecoder_plugin.cpp | 4 +- src/contrib/flacdecoder/FlacDecoder.cpp | 2 +- src/contrib/flacdecoder/FlacDecoder.h | 10 +- .../flacdecoder/FlacDecoderFactory.cpp | 4 +- src/contrib/flacdecoder/FlacDecoderFactory.h | 4 +- .../flacdecoder/flacdecoder_plugin.cpp | 6 +- src/contrib/m4adecoder/M4aDecoder.cpp | 6 +- src/contrib/m4adecoder/M4aDecoder.h | 6 +- src/contrib/m4adecoder/M4aDecoderFactory.cpp | 2 +- src/contrib/m4adecoder/M4aDecoderFactory.h | 4 +- src/contrib/m4adecoder/m4adecoder_plugin.cpp | 6 +- src/contrib/mpg123decoder/Mpg123Decoder.cpp | 3 +- src/contrib/mpg123decoder/Mpg123Decoder.h | 8 +- .../mpg123decoder/Mpg123DecoderFactory.cpp | 2 +- .../mpg123decoder/Mpg123DecoderFactory.h | 4 +- .../mpg123decoder/mpg123decoder_plugin.cpp | 6 +- src/contrib/oggdecoder/OggDecoder.cpp | 2 +- src/contrib/oggdecoder/OggDecoder.h | 12 +- src/contrib/oggdecoder/OggDecoderFactory.h | 10 +- src/contrib/oggdecoder/oggdecoder_plugin.cpp | 4 +- .../taglib_plugin/TaglibMetadataReader.cpp | 20 +-- .../taglib_plugin/TaglibMetadataReader.h | 22 +-- src/contrib/taglib_plugin/taglib_plugin.cpp | 6 +- src/contrib/waveout/WaveOut.h | 8 +- src/contrib/waveout/WaveOutBuffer.h | 2 +- src/contrib/waveout/waveout_plugin.cpp | 6 +- src/core/CMakeLists.txt | 1 - src/core/audio/Buffer.h | 2 +- src/core/audio/Player.cpp | 2 + src/core/audio/Player.h | 6 +- src/core/audio/Stream.cpp | 1 + src/core/audio/Stream.h | 4 + src/core/audio/Visualizer.cpp | 1 + src/core/audio/Visualizer.h | 10 +- src/core/core.vcxproj | 5 +- src/core/core.vcxproj.filters | 15 +- src/core/io/DataStreamFactory.cpp | 1 + src/core/io/DataStreamFactory.h | 4 +- src/core/io/LocalFileStream.cpp | 1 + src/core/io/LocalFileStream.h | 4 +- src/core/library/Indexer.cpp | 6 +- src/core/library/Indexer.h | 4 +- src/core/library/track/IndexerTrack.cpp | 11 +- src/core/library/track/IndexerTrack.h | 8 +- src/core/library/track/LibraryTrack.cpp | 11 +- src/core/library/track/LibraryTrack.h | 7 +- src/core/library/track/Track.h | 8 +- src/core/plugin/PluginFactory.h | 6 +- src/core/sdk/IAnalyzer.h | 8 +- src/core/sdk/IBuffer.h | 2 +- src/core/sdk/IBufferProvider.h | 2 +- src/core/sdk/IDSP.h | 2 +- src/core/sdk/IDataStream.h | 2 +- src/core/sdk/IDataStreamFactory.h | 2 +- src/core/sdk/IDecoder.h | 4 +- src/core/sdk/IDecoderFactory.h | 2 +- src/core/sdk/IMetadataReader.h | 4 +- src/core/sdk/IMetadataWriter.h | 4 +- src/core/sdk/IOutput.h | 2 +- src/core/sdk/IPcmVisualizer.h | 4 +- src/core/sdk/IPlaybackRemote.h | 51 +++++++ .../IPlaybackService.h} | 62 +++----- src/core/sdk/IPlugin.h | 4 +- src/core/sdk/ISpectrumVisualizer.h | 2 +- src/core/sdk/ITrack.h | 48 +++++++ src/core/sdk/IVisualizer.h | 2 +- src/core/sdk/config.h | 10 ++ src/core/support/NonLibraryTrackHelper.cpp | 133 ------------------ src/musikbox/app/layout/ConsoleLayout.cpp | 2 +- src/musikbox/app/service/PlaybackService.cpp | 14 +- src/musikbox/app/service/PlaybackService.h | 43 +++--- src/musikbox/app/util/GlobalHotkeys.cpp | 1 + src/musikbox/cursespp/Text.h | 2 +- 77 files changed, 357 insertions(+), 351 deletions(-) create mode 100644 src/core/sdk/IPlaybackRemote.h rename src/core/{support/NonLibraryTrackHelper.h => sdk/IPlaybackService.h} (57%) create mode 100644 src/core/sdk/ITrack.h delete mode 100644 src/core/support/NonLibraryTrackHelper.cpp diff --git a/src/contrib/cddadecoder/CddaDataStream.h b/src/contrib/cddadecoder/CddaDataStream.h index 75fad63da..4f9686962 100755 --- a/src/contrib/cddadecoder/CddaDataStream.h +++ b/src/contrib/cddadecoder/CddaDataStream.h @@ -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: diff --git a/src/contrib/cddadecoder/CddaDataStreamFactory.h b/src/contrib/cddadecoder/CddaDataStreamFactory.h index b62932cb0..2a5dea59f 100755 --- a/src/contrib/cddadecoder/CddaDataStreamFactory.h +++ b/src/contrib/cddadecoder/CddaDataStreamFactory.h @@ -34,7 +34,7 @@ #include -using namespace musik::core::io; +using namespace musik::core::sdk; class CddaDataStreamFactory : public IDataStreamFactory { public: diff --git a/src/contrib/cddadecoder/CddaDecoder.h b/src/contrib/cddadecoder/CddaDecoder.h index 027d4447f..fb78000b8 100644 --- a/src/contrib/cddadecoder/CddaDecoder.h +++ b/src/contrib/cddadecoder/CddaDecoder.h @@ -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 { diff --git a/src/contrib/cddadecoder/CddaDecoderFactory.h b/src/contrib/cddadecoder/CddaDecoderFactory.h index 0cf59b275..fa4de55d6 100644 --- a/src/contrib/cddadecoder/CddaDecoderFactory.h +++ b/src/contrib/cddadecoder/CddaDecoderFactory.h @@ -36,7 +36,7 @@ #include -using namespace musik::core::audio; +using namespace musik::core::sdk; class CddaDecoderFactory : public IDecoderFactory { public: diff --git a/src/contrib/cddadecoder/cddadecoder_plugin.cpp b/src/contrib/cddadecoder/cddadecoder_plugin.cpp index ab0f45f98..20db60a31 100644 --- a/src/contrib/cddadecoder/cddadecoder_plugin.cpp +++ b/src/contrib/cddadecoder/cddadecoder_plugin.cpp @@ -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(); } diff --git a/src/contrib/flacdecoder/FlacDecoder.cpp b/src/contrib/flacdecoder/FlacDecoder.cpp index be6cb93fc..4abe94c76 100644 --- a/src/contrib/flacdecoder/FlacDecoder.cpp +++ b/src/contrib/flacdecoder/FlacDecoder.cpp @@ -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 = diff --git a/src/contrib/flacdecoder/FlacDecoder.h b/src/contrib/flacdecoder/FlacDecoder.h index 2bac14ed3..da15712db 100644 --- a/src/contrib/flacdecoder/FlacDecoder.h +++ b/src/contrib/flacdecoder/FlacDecoder.h @@ -39,9 +39,9 @@ #include #include -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; diff --git a/src/contrib/flacdecoder/FlacDecoderFactory.cpp b/src/contrib/flacdecoder/FlacDecoderFactory.cpp index d8d2186cf..1bfe60c8f 100644 --- a/src/contrib/flacdecoder/FlacDecoderFactory.cpp +++ b/src/contrib/flacdecoder/FlacDecoderFactory.cpp @@ -35,12 +35,12 @@ #include "stdafx.h" #include #include -#include +#include #include "FlacDecoderFactory.h" #include "FlacDecoder.h" -using namespace musik::core::audio; +using namespace musik::core::sdk; FlacDecoderFactory::FlacDecoderFactory() { } diff --git a/src/contrib/flacdecoder/FlacDecoderFactory.h b/src/contrib/flacdecoder/FlacDecoderFactory.h index 6be81b2bd..9c3e8fd14 100644 --- a/src/contrib/flacdecoder/FlacDecoderFactory.h +++ b/src/contrib/flacdecoder/FlacDecoderFactory.h @@ -36,12 +36,12 @@ #include -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; }; diff --git a/src/contrib/flacdecoder/flacdecoder_plugin.cpp b/src/contrib/flacdecoder/flacdecoder_plugin.cpp index f8a9ae5b0..5fc460a28 100644 --- a/src/contrib/flacdecoder/flacdecoder_plugin.cpp +++ b/src/contrib/flacdecoder/flacdecoder_plugin.cpp @@ -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(); } diff --git a/src/contrib/m4adecoder/M4aDecoder.cpp b/src/contrib/m4adecoder/M4aDecoder.cpp index 9c1d3267c..6c62708a9 100644 --- a/src/contrib/m4adecoder/M4aDecoder.cpp +++ b/src/contrib/m4adecoder/M4aDecoder.cpp @@ -36,8 +36,8 @@ #include "M4aDecoder.h" #include -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(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) { diff --git a/src/contrib/m4adecoder/M4aDecoder.h b/src/contrib/m4adecoder/M4aDecoder.h index 7043e8c0e..f034d6371 100644 --- a/src/contrib/m4adecoder/M4aDecoder.h +++ b/src/contrib/m4adecoder/M4aDecoder.h @@ -38,15 +38,15 @@ #include #include -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; diff --git a/src/contrib/m4adecoder/M4aDecoderFactory.cpp b/src/contrib/m4adecoder/M4aDecoderFactory.cpp index 7b86ad1e8..f54c1fd1f 100644 --- a/src/contrib/m4adecoder/M4aDecoderFactory.cpp +++ b/src/contrib/m4adecoder/M4aDecoderFactory.cpp @@ -38,7 +38,7 @@ #include "M4aDecoder.h" #include -using musik::core::audio::IDecoder; +using musik::core::sdk::IDecoder; M4aDecoderFactory::M4aDecoderFactory() { } diff --git a/src/contrib/m4adecoder/M4aDecoderFactory.h b/src/contrib/m4adecoder/M4aDecoderFactory.h index f0c10852d..7339de5fe 100644 --- a/src/contrib/m4adecoder/M4aDecoderFactory.h +++ b/src/contrib/m4adecoder/M4aDecoderFactory.h @@ -36,12 +36,12 @@ #include -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; }; diff --git a/src/contrib/m4adecoder/m4adecoder_plugin.cpp b/src/contrib/m4adecoder/m4adecoder_plugin.cpp index 5a95c194a..04bef6708 100644 --- a/src/contrib/m4adecoder/m4adecoder_plugin.cpp +++ b/src/contrib/m4adecoder/m4adecoder_plugin.cpp @@ -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(); } diff --git a/src/contrib/mpg123decoder/Mpg123Decoder.cpp b/src/contrib/mpg123decoder/Mpg123Decoder.cpp index f93487f1b..e62b5789a 100644 --- a/src/contrib/mpg123decoder/Mpg123Decoder.cpp +++ b/src/contrib/mpg123decoder/Mpg123Decoder.cpp @@ -42,8 +42,7 @@ #include #endif -using namespace musik::core::audio; -using namespace musik::core::io; +using namespace musik::core::sdk; Mpg123Decoder::Mpg123Decoder() : cachedLength(0) diff --git a/src/contrib/mpg123decoder/Mpg123Decoder.h b/src/contrib/mpg123decoder/Mpg123Decoder.h index 0cd117a3b..bf451dfdb 100644 --- a/src/contrib/mpg123decoder/Mpg123Decoder.h +++ b/src/contrib/mpg123decoder/Mpg123Decoder.h @@ -43,21 +43,21 @@ typedef long ssize_t; #include -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; diff --git a/src/contrib/mpg123decoder/Mpg123DecoderFactory.cpp b/src/contrib/mpg123decoder/Mpg123DecoderFactory.cpp index 45bf351dd..a8055353e 100644 --- a/src/contrib/mpg123decoder/Mpg123DecoderFactory.cpp +++ b/src/contrib/mpg123decoder/Mpg123DecoderFactory.cpp @@ -40,7 +40,7 @@ #include "Mpg123Decoder.h" #include "mpg123.h" -using namespace musik::core::audio; +using namespace musik::core::sdk; Mpg123DecoderFactory::Mpg123DecoderFactory() { mpg123_init(); diff --git a/src/contrib/mpg123decoder/Mpg123DecoderFactory.h b/src/contrib/mpg123decoder/Mpg123DecoderFactory.h index 760a6cad6..4e1a60724 100644 --- a/src/contrib/mpg123decoder/Mpg123DecoderFactory.h +++ b/src/contrib/mpg123decoder/Mpg123DecoderFactory.h @@ -36,12 +36,12 @@ #include -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; }; diff --git a/src/contrib/mpg123decoder/mpg123decoder_plugin.cpp b/src/contrib/mpg123decoder/mpg123decoder_plugin.cpp index 17de3dd62..0e6ff1a18 100644 --- a/src/contrib/mpg123decoder/mpg123decoder_plugin.cpp +++ b/src/contrib/mpg123decoder/mpg123decoder_plugin.cpp @@ -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(); } diff --git a/src/contrib/oggdecoder/OggDecoder.cpp b/src/contrib/oggdecoder/OggDecoder.cpp index 8ed4030df..17b522d0f 100644 --- a/src/contrib/oggdecoder/OggDecoder.cpp +++ b/src/contrib/oggdecoder/OggDecoder.cpp @@ -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) { diff --git a/src/contrib/oggdecoder/OggDecoder.h b/src/contrib/oggdecoder/OggDecoder.h index 0f9ae37cd..ca9de5003 100644 --- a/src/contrib/oggdecoder/OggDecoder.h +++ b/src/contrib/oggdecoder/OggDecoder.h @@ -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; }; diff --git a/src/contrib/oggdecoder/OggDecoderFactory.h b/src/contrib/oggdecoder/OggDecoderFactory.h index fd6328523..849db933f 100644 --- a/src/contrib/oggdecoder/OggDecoderFactory.h +++ b/src/contrib/oggdecoder/OggDecoderFactory.h @@ -36,14 +36,14 @@ #include -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; }; diff --git a/src/contrib/oggdecoder/oggdecoder_plugin.cpp b/src/contrib/oggdecoder/oggdecoder_plugin.cpp index 4f58821d3..5a4aa9a5e 100644 --- a/src/contrib/oggdecoder/oggdecoder_plugin.cpp +++ b/src/contrib/oggdecoder/oggdecoder_plugin.cpp @@ -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(); } diff --git a/src/contrib/taglib_plugin/TaglibMetadataReader.cpp b/src/contrib/taglib_plugin/TaglibMetadataReader.cpp index 268176112..9ba306953 100644 --- a/src/contrib/taglib_plugin/TaglibMetadataReader.cpp +++ b/src/contrib/taglib_plugin/TaglibMetadataReader.cpp @@ -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 -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 */ diff --git a/src/contrib/taglib_plugin/TaglibMetadataReader.h b/src/contrib/taglib_plugin/TaglibMetadataReader.h index 2fd279484..de7d8b988 100644 --- a/src/contrib/taglib_plugin/TaglibMetadataReader.h +++ b/src/contrib/taglib_plugin/TaglibMetadataReader.h @@ -55,51 +55,51 @@ #include #include -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); }; diff --git a/src/contrib/taglib_plugin/taglib_plugin.cpp b/src/contrib/taglib_plugin/taglib_plugin.cpp index 3a454d5a8..88d887955 100644 --- a/src/contrib/taglib_plugin/taglib_plugin.cpp +++ b/src/contrib/taglib_plugin/taglib_plugin.cpp @@ -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(); } diff --git a/src/contrib/waveout/WaveOut.h b/src/contrib/waveout/WaveOut.h index cc696a3bf..2eaeefe9e 100644 --- a/src/contrib/waveout/WaveOut.h +++ b/src/contrib/waveout/WaveOut.h @@ -36,13 +36,13 @@ #include "pch.h" #include #include -#include +#include #include #include #include "WaveOutBuffer.h" #include -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 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 BufferList; diff --git a/src/contrib/waveout/WaveOutBuffer.h b/src/contrib/waveout/WaveOutBuffer.h index 693ae761e..e032180eb 100644 --- a/src/contrib/waveout/WaveOutBuffer.h +++ b/src/contrib/waveout/WaveOutBuffer.h @@ -46,7 +46,7 @@ class WaveOut; -using namespace musik::core::audio; +using namespace musik::core::sdk; class WaveOutBuffer { diff --git a/src/contrib/waveout/waveout_plugin.cpp b/src/contrib/waveout/waveout_plugin.cpp index 612fd4165..df93afa79 100644 --- a/src/contrib/waveout/waveout_plugin.cpp +++ b/src/contrib/waveout/waveout_plugin.cpp @@ -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(); } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d3e92b9c2..be7a30408 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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 diff --git a/src/core/audio/Buffer.h b/src/core/audio/Buffer.h index e0b15ec52..2fe2c158c 100644 --- a/src/core/audio/Buffer.h +++ b/src/core/audio/Buffer.h @@ -44,7 +44,7 @@ namespace musik { namespace core { namespace audio { class Stream; typedef std::shared_ptr BufferPtr; - class Buffer : public IBuffer { + class Buffer : public musik::core::sdk::IBuffer { private: Buffer(); diff --git a/src/core/audio/Player.cpp b/src/core/audio/Player.cpp index 2deaac166..37b5bad86 100644 --- a/src/core/audio/Player.cpp +++ b/src/core/audio/Player.cpp @@ -44,6 +44,8 @@ #define FFT_N 512 using namespace musik::core::audio; +using namespace musik::core::sdk; + using std::min; using std::max; diff --git a/src/core/audio/Player.h b/src/core/audio/Player.h index ed3234e09..fd7faf7ff 100644 --- a/src/core/audio/Player.h +++ b/src/core/audio/Player.h @@ -51,9 +51,9 @@ namespace musik { namespace core { namespace audio { typedef std::shared_ptr PlayerPtr; class Output; - typedef std::shared_ptr OutputPtr; + typedef std::shared_ptr 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(); diff --git a/src/core/audio/Stream.cpp b/src/core/audio/Stream.cpp index 81347c3a0..5642d9ce9 100644 --- a/src/core/audio/Stream.cpp +++ b/src/core/audio/Stream.cpp @@ -40,6 +40,7 @@ #include using namespace musik::core::audio; +using namespace musik::core::sdk; using musik::core::PluginFactory; static std::string TAG = "Stream"; diff --git a/src/core/audio/Stream.h b/src/core/audio/Stream.h index a2c608035..9c0ce686d 100644 --- a/src/core/audio/Stream.h +++ b/src/core/audio/Stream.h @@ -51,6 +51,10 @@ namespace musik { namespace core { namespace audio { typedef std::shared_ptr 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); diff --git a/src/core/audio/Visualizer.cpp b/src/core/audio/Visualizer.cpp index 815ea77b4..70d7db502 100644 --- a/src/core/audio/Visualizer.cpp +++ b/src/core/audio/Visualizer.cpp @@ -40,6 +40,7 @@ #include using namespace musik::core::audio; +using namespace musik::core::sdk; static std::vector > visualizers; static std::atomic initialized; diff --git a/src/core/audio/Visualizer.h b/src/core/audio/Visualizer.h index 221924ac7..00f703127 100644 --- a/src/core/audio/Visualizer.h +++ b/src/core/audio/Visualizer.h @@ -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 GetVisualizer(size_t index); + std::shared_ptr GetVisualizer(size_t index); size_t VisualizerCount(); - void SetSelectedVisualizer(std::shared_ptr visualizer); - std::shared_ptr SelectedVisualizer(); + void SetSelectedVisualizer(std::shared_ptr visualizer); + std::shared_ptr SelectedVisualizer(); void HideSelectedVisualizer(); } } } } diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index d6eb20009..fda5856a0 100755 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -109,7 +109,6 @@ - @@ -148,6 +147,8 @@ + + @@ -158,9 +159,9 @@ + - diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index 2a8311df6..3578c143d 100755 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -103,9 +103,6 @@ src\library - - src\support - src\audio @@ -240,9 +237,6 @@ src\library - - src\support - src\audio @@ -264,5 +258,14 @@ src\sdk + + src\sdk + + + src\sdk + + + src\sdk + \ No newline at end of file diff --git a/src/core/io/DataStreamFactory.cpp b/src/core/io/DataStreamFactory.cpp index 05c5c0680..dfc45addf 100644 --- a/src/core/io/DataStreamFactory.cpp +++ b/src/core/io/DataStreamFactory.cpp @@ -40,6 +40,7 @@ #include using namespace musik::core::io; +using namespace musik::core::sdk; DataStreamFactory::DataStreamFactory() { typedef IDataStreamFactory PluginType; diff --git a/src/core/io/DataStreamFactory.h b/src/core/io/DataStreamFactory.h index ee85e298a..bdedc4489 100644 --- a/src/core/io/DataStreamFactory.h +++ b/src/core/io/DataStreamFactory.h @@ -42,14 +42,14 @@ namespace musik { namespace core { namespace io { class DataStreamFactory { public: - typedef std::shared_ptr DataStreamPtr; + typedef std::shared_ptr DataStreamPtr; private: DataStreamFactory(); static DataStreamFactory* Instance(); private: - typedef std::vector > DataStreamFactoryVector; + typedef std::vector > DataStreamFactoryVector; DataStreamFactoryVector dataStreamFactories; public: diff --git a/src/core/io/LocalFileStream.cpp b/src/core/io/LocalFileStream.cpp index 45e1ae985..def179f5d 100644 --- a/src/core/io/LocalFileStream.cpp +++ b/src/core/io/LocalFileStream.cpp @@ -43,6 +43,7 @@ static const std::string TAG = "LocalFileStream"; using namespace musik::core::io; +using namespace musik::core::sdk; LocalFileStream::LocalFileStream() : file(NULL) diff --git a/src/core/io/LocalFileStream.h b/src/core/io/LocalFileStream.h index 608db62a4..1d8dea0f5 100644 --- a/src/core/io/LocalFileStream.h +++ b/src/core/io/LocalFileStream.h @@ -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(); diff --git a/src/core/library/Indexer.cpp b/src/core/library/Indexer.cpp index 8584fe251..fff4e47e0 100644 --- a/src/core/library/Indexer.cpp +++ b/src/core/library/Indexer.cpp @@ -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; @@ -592,7 +592,7 @@ void Indexer::ProcessAddRemoveQueue() { } void Indexer::RunAnalyzers() { - typedef audio::IAnalyzer PluginType; + typedef sdk::IAnalyzer PluginType; typedef PluginFactory::DestroyDeleter Deleter; typedef std::shared_ptr PluginPtr; typedef std::vector 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 */ diff --git a/src/core/library/Indexer.h b/src/core/library/Indexer.h index dc8d94d2c..bdde393a8 100644 --- a/src/core/library/Indexer.h +++ b/src/core/library/Indexer.h @@ -113,10 +113,10 @@ namespace musik { namespace core { }; typedef std::vector > MetadataReaderList; + musik::core::sdk::IMetadataReader> > MetadataReaderList; typedef std::vector > DecoderList; + musik::core::sdk::IDecoderFactory> > DecoderList; std::deque addRemoveQueue; diff --git a/src/core/library/track/IndexerTrack.cpp b/src/core/library/track/IndexerTrack.cpp index bdd43f8fd..aa127032b 100644 --- a/src/core/library/track/IndexerTrack.cpp +++ b/src/core/library/track/IndexerTrack.cpp @@ -36,6 +36,7 @@ #include +#include #include #include #include @@ -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); diff --git a/src/core/library/track/IndexerTrack.h b/src/core/library/track/IndexerTrack.h index 8d800acae..e331a3155 100644 --- a/src/core/library/track/IndexerTrack.h +++ b/src/core/library/track/IndexerTrack.h @@ -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(); diff --git a/src/core/library/track/LibraryTrack.cpp b/src/core/library/track/LibraryTrack.cpp index 799dd87f8..ac8caf99a 100644 --- a/src/core/library/track/LibraryTrack.cpp +++ b/src/core/library/track/LibraryTrack.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -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); diff --git a/src/core/library/track/LibraryTrack.h b/src/core/library/track/LibraryTrack.h index bf908233d..59935331b 100644 --- a/src/core/library/track/LibraryTrack.h +++ b/src/core/library/track/LibraryTrack.h @@ -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(); diff --git a/src/core/library/track/Track.h b/src/core/library/track/Track.h index c8a011716..9f1a1ed60 100644 --- a/src/core/library/track/Track.h +++ b/src/core/library/track/Track.h @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -46,7 +47,10 @@ namespace musik { namespace core { typedef std::shared_ptr TrackPtr; typedef std::vector TrackVector; - class Track : public IMetadataWriter { + class Track : + public musik::core::sdk::IMetadataWriter, + public musik::core::sdk::ITrack + { public: typedef std::multimap MetadataMap; typedef std::pair 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; diff --git a/src/core/plugin/PluginFactory.h b/src/core/plugin/PluginFactory.h index df6619d67..c05df2730 100644 --- a/src/core/plugin/PluginFactory.h +++ b/src/core/plugin/PluginFactory.h @@ -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 PluginList; + typedef std::vector PluginList; typedef std::vector HandleList; PluginList loadedPlugins; diff --git a/src/core/sdk/IAnalyzer.h b/src/core/sdk/IAnalyzer.h index d19956e08..ea39bb21a 100644 --- a/src/core/sdk/IAnalyzer.h +++ b/src/core/sdk/IAnalyzer.h @@ -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; }; } } } diff --git a/src/core/sdk/IBuffer.h b/src/core/sdk/IBuffer.h index 7bc7b61e0..78a25f1aa 100644 --- a/src/core/sdk/IBuffer.h +++ b/src/core/sdk/IBuffer.h @@ -36,7 +36,7 @@ #include "config.h" -namespace musik { namespace core { namespace audio { +namespace musik { namespace core { namespace sdk { class IBuffer { public: diff --git a/src/core/sdk/IBufferProvider.h b/src/core/sdk/IBufferProvider.h index d9aecc147..d844bf824 100644 --- a/src/core/sdk/IBufferProvider.h +++ b/src/core/sdk/IBufferProvider.h @@ -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: diff --git a/src/core/sdk/IDSP.h b/src/core/sdk/IDSP.h index 3c54b1cf5..f77906fd8 100644 --- a/src/core/sdk/IDSP.h +++ b/src/core/sdk/IDSP.h @@ -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: diff --git a/src/core/sdk/IDataStream.h b/src/core/sdk/IDataStream.h index 769ad3db6..1fb1d0cb8 100644 --- a/src/core/sdk/IDataStream.h +++ b/src/core/sdk/IDataStream.h @@ -36,7 +36,7 @@ #include "config.h" -namespace musik { namespace core { namespace io { +namespace musik { namespace core { namespace sdk { typedef long PositionType; diff --git a/src/core/sdk/IDataStreamFactory.h b/src/core/sdk/IDataStreamFactory.h index 7499e962d..4085bc652 100644 --- a/src/core/sdk/IDataStreamFactory.h +++ b/src/core/sdk/IDataStreamFactory.h @@ -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; diff --git a/src/core/sdk/IDecoder.h b/src/core/sdk/IDecoder.h index 3091751fa..78b7709c2 100644 --- a/src/core/sdk/IDecoder.h +++ b/src/core/sdk/IDecoder.h @@ -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; }; } } } diff --git a/src/core/sdk/IDecoderFactory.h b/src/core/sdk/IDecoderFactory.h index b16e5cddf..774617e1d 100644 --- a/src/core/sdk/IDecoderFactory.h +++ b/src/core/sdk/IDecoderFactory.h @@ -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: diff --git a/src/core/sdk/IMetadataReader.h b/src/core/sdk/IMetadataReader.h index 6a1292ba1..d405e6603 100644 --- a/src/core/sdk/IMetadataReader.h +++ b/src/core/sdk/IMetadataReader.h @@ -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; }; diff --git a/src/core/sdk/IMetadataWriter.h b/src/core/sdk/IMetadataWriter.h index 6a45c591d..006fb3f89 100644 --- a/src/core/sdk/IMetadataWriter.h +++ b/src/core/sdk/IMetadataWriter.h @@ -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 */ }; -} } +} } } diff --git a/src/core/sdk/IOutput.h b/src/core/sdk/IOutput.h index 6cbc2edf3..d51668a60 100644 --- a/src/core/sdk/IOutput.h +++ b/src/core/sdk/IOutput.h @@ -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: diff --git a/src/core/sdk/IPcmVisualizer.h b/src/core/sdk/IPcmVisualizer.h index d1be9b86f..314821423 100644 --- a/src/core/sdk/IPcmVisualizer.h +++ b/src/core/sdk/IPcmVisualizer.h @@ -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; }; } } } diff --git a/src/core/sdk/IPlaybackRemote.h b/src/core/sdk/IPlaybackRemote.h new file mode 100644 index 000000000..49aecec93 --- /dev/null +++ b/src/core/sdk/IPlaybackRemote.h @@ -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; + }; + +} } + diff --git a/src/core/support/NonLibraryTrackHelper.h b/src/core/sdk/IPlaybackService.h similarity index 57% rename from src/core/support/NonLibraryTrackHelper.h rename to src/core/sdk/IPlaybackService.h index b82d253c7..18091dca3 100644 --- a/src/core/support/NonLibraryTrackHelper.h +++ b/src/core/sdk/IPlaybackService.h @@ -34,52 +34,32 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include +#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 TrackMetadataUpdatedEvent; - TrackMetadataUpdatedEvent TrackMetadataUpdated; - - private: - static NonLibraryTrackHelper sInstance; - - NonLibraryTrackHelper(); - ~NonLibraryTrackHelper(); - - void ThreadLoop(); - - private: - boost::mutex mutex; - bool threadIsRunning; - - typedef std::weak_ptr TrackWeakPtr; - std::list tracksToRead; - - typedef boost::scoped_ptr ThreadPtr; - ThreadPtr helperThread; -}; - - -////////////////////////////////////////////////////////////////////////////// -} } // musik::core -////////////////////////////////////////////////////////////////////////////// + virtual size_t GetIndex() = 0; + virtual size_t Count() = 0; + }; +} } diff --git a/src/core/sdk/IPlugin.h b/src/core/sdk/IPlugin.h index 7526d7979..6542b2cd7 100644 --- a/src/core/sdk/IPlugin.h +++ b/src/core/sdk/IPlugin.h @@ -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; }; -} } +} } } diff --git a/src/core/sdk/ISpectrumVisualizer.h b/src/core/sdk/ISpectrumVisualizer.h index c94681650..2c9aa65df 100644 --- a/src/core/sdk/ISpectrumVisualizer.h +++ b/src/core/sdk/ISpectrumVisualizer.h @@ -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: diff --git a/src/core/sdk/ITrack.h b/src/core/sdk/ITrack.h new file mode 100644 index 000000000..db438df0f --- /dev/null +++ b/src/core/sdk/ITrack.h @@ -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; + }; + +} } } + diff --git a/src/core/sdk/IVisualizer.h b/src/core/sdk/IVisualizer.h index 29a8f1fa0..933031de6 100644 --- a/src/core/sdk/IVisualizer.h +++ b/src/core/sdk/IVisualizer.h @@ -36,7 +36,7 @@ #include "IPlugin.h" -namespace musik { namespace core { namespace audio { +namespace musik { namespace core { namespace sdk { class IVisualizer : public IPlugin { public: diff --git a/src/core/sdk/config.h b/src/core/sdk/config.h index eb6735063..412ad6172 100755 --- a/src/core/sdk/config.h +++ b/src/core/sdk/config.h @@ -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; + } } } diff --git a/src/core/support/NonLibraryTrackHelper.cpp b/src/core/support/NonLibraryTrackHelper.cpp deleted file mode 100644 index d5263f0f9..000000000 --- a/src/core/support/NonLibraryTrackHelper.cpp +++ /dev/null @@ -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 -#include -#include -#include - -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 Deleter; - typedef std::vector > MetadataReaderList; - - MetadataReaderList metadataReaders = - PluginFactory::Instance() .QueryInterface("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); - } - } - } -} diff --git a/src/musikbox/app/layout/ConsoleLayout.cpp b/src/musikbox/app/layout/ConsoleLayout.cpp index b5432ae2e..136a96b45 100755 --- a/src/musikbox/app/layout/ConsoleLayout.cpp +++ b/src/musikbox/app/layout/ConsoleLayout.cpp @@ -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 > PluginList; diff --git a/src/musikbox/app/service/PlaybackService.cpp b/src/musikbox/app/service/PlaybackService.cpp index afc450e95..0327cef76 100755 --- a/src/musikbox/app/service/PlaybackService.cpp +++ b/src/musikbox/app/service/PlaybackService.cpp @@ -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); diff --git a/src/musikbox/app/service/PlaybackService.h b/src/musikbox/app/service/PlaybackService.h index 767e7049d..109a0e462 100755 --- a/src/musikbox/app/service/PlaybackService.h +++ b/src/musikbox/app/service/PlaybackService.h @@ -40,6 +40,7 @@ #include +#include #include #include #include @@ -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 TrackChanged; sigslot::signal0<> ModeChanged; sigslot::signal1 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); diff --git a/src/musikbox/app/util/GlobalHotkeys.cpp b/src/musikbox/app/util/GlobalHotkeys.cpp index baf63cf82..8178fac93 100755 --- a/src/musikbox/app/util/GlobalHotkeys.cpp +++ b/src/musikbox/app/util/GlobalHotkeys.cpp @@ -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) diff --git a/src/musikbox/cursespp/Text.h b/src/musikbox/cursespp/Text.h index c66d1c917..ce1773345 100755 --- a/src/musikbox/cursespp/Text.h +++ b/src/musikbox/cursespp/Text.h @@ -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 BreakLines(const std::string& line, size_t width); + std::vector BreakLines(const std::string& line, size_t width); } namespace key {