Migrated all Destroy() methods to be Release() instead. Freeing SDK

resources is now consistent.
This commit is contained in:
casey langen 2017-10-08 13:56:24 -07:00
parent 1e2159d434
commit 8c1627c4e3
96 changed files with 149 additions and 157 deletions

View File

@ -64,7 +64,7 @@ namespace musik { namespace core { namespace audio {
virtual long Samples() const override;
virtual void SetSamples(long samples) override;
virtual long Bytes() const override;
virtual void Destroy() override { delete this; }
virtual void Release() override { delete this; }
double Position() const;
void SetPosition(double position);

View File

@ -77,7 +77,7 @@ namespace musik {
}
OutputList GetAllOutputs() {
using OutputDeleter = PluginFactory::DestroyDeleter<IOutput>;
using OutputDeleter = PluginFactory::ReleaseDeleter<IOutput>;
OutputList result = PluginFactory::Instance()
.QueryInterface<IOutput, OutputDeleter>("GetAudioOutput");

View File

@ -157,7 +157,7 @@ PlaybackService::~PlaybackService() {
}
void PlaybackService::InitRemotes() {
typedef PluginFactory::DestroyDeleter<IPlaybackRemote> Deleter;
typedef PluginFactory::ReleaseDeleter<IPlaybackRemote> Deleter;
this->remotes = PluginFactory::Instance()
.QueryInterface<IPlaybackRemote, Deleter>("GetPlaybackRemote");

View File

@ -49,7 +49,7 @@ using musik::core::PluginFactory;
using DataStreamPtr = musik::core::io::DataStreamFactory::DataStreamPtr;
using DecoderFactoryList = std::vector<std::shared_ptr<IDecoderFactory > >;
using DspList = std::vector<std::shared_ptr<IDSP > >;
using Deleter = PluginFactory::DestroyDeleter<IDecoder>;
using Deleter = PluginFactory::ReleaseDeleter<IDecoder>;
using DecoderPtr = std::shared_ptr<IDecoder>;
static std::mutex initLock;
@ -58,7 +58,7 @@ static DecoderFactoryList decoders;
static void init() {
std::unique_lock<std::mutex> lock(initLock);
if (!decoders.size()) {
typedef PluginFactory::DestroyDeleter<IDecoderFactory> Deleter;
typedef PluginFactory::ReleaseDeleter<IDecoderFactory> Deleter;
decoders = PluginFactory::Instance()
.QueryInterface<IDecoderFactory, Deleter>("GetDecoderFactory");
@ -103,7 +103,7 @@ namespace musik { namespace core { namespace audio {
good to start pulling data out of it! */
if (!decoder->Open(dataStream)) {
musik::debug::err(TAG, "open ok, but decode failed " + uri);
decoder->Destroy();
decoder->Release();
return nullptr;
}
@ -118,7 +118,7 @@ namespace musik { namespace core { namespace audio {
}
DspList GetDspPlugins() {
typedef PluginFactory::DestroyDeleter<IDSP> Deleter;
typedef PluginFactory::ReleaseDeleter<IDSP> Deleter;
return PluginFactory::Instance().QueryInterface<IDSP, Deleter>("GetDSP");
}
};

View File

@ -57,7 +57,7 @@ namespace musik {
namespace vis {
static void init() {
/* spectrum visualizers */
typedef PluginFactory::DestroyDeleter<ISpectrumVisualizer> SpectrumDeleter;
typedef PluginFactory::ReleaseDeleter<ISpectrumVisualizer> SpectrumDeleter;
std::vector<std::shared_ptr<ISpectrumVisualizer> > spectrum;
spectrum = PluginFactory::Instance()
@ -68,7 +68,7 @@ namespace musik {
}
/* pcm visualizers */
typedef PluginFactory::DestroyDeleter<IPcmVisualizer> PcmDeleter;
typedef PluginFactory::ReleaseDeleter<IPcmVisualizer> PcmDeleter;
std::vector<std::shared_ptr<IPcmVisualizer> > pcm;
pcm = PluginFactory::Instance()

View File

@ -53,12 +53,12 @@
<Filter Include="src\sdk\io">
<UniqueIdentifier>{578b0af6-0dc3-4a69-a784-5e0293a5708a}</UniqueIdentifier>
</Filter>
<Filter Include="src\sdk\library">
<UniqueIdentifier>{a39a447a-65ad-465c-839d-b96cc4a8e2e9}</UniqueIdentifier>
</Filter>
<Filter Include="src\sdk\indexer">
<UniqueIdentifier>{d35af273-0f2b-4669-aa83-d7eee8c2c5c5}</UniqueIdentifier>
</Filter>
<Filter Include="src\sdk\metadata">
<UniqueIdentifier>{a39a447a-65ad-465c-839d-b96cc4a8e2e9}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
@ -412,7 +412,7 @@
<Filter>src\sdk\vis</Filter>
</ClInclude>
<ClInclude Include="sdk\ISimpleDataProvider.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\IPlaybackRemote.h">
<Filter>src\sdk\audio</Filter>
@ -433,37 +433,37 @@
<Filter>src\sdk\indexer</Filter>
</ClInclude>
<ClInclude Include="sdk\ITrackListEditor.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\ITrackList.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\ITrack.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\IDevice.h">
<Filter>src\sdk\audio</Filter>
</ClInclude>
<ClInclude Include="sdk\IValue.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\IValueList.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\IResource.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\IMap.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\IMapList.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\ITagReader.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
<ClInclude Include="sdk\ITagStore.h">
<Filter>src\sdk\library</Filter>
<Filter>src\sdk\metadata</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -43,11 +43,11 @@ using namespace musik::core::io;
using namespace musik::core::sdk;
using DataStreamPtr = DataStreamFactory::DataStreamPtr;
using StreamDeleter = musik::core::PluginFactory::DestroyDeleter<IDataStream>;
using StreamDeleter = musik::core::PluginFactory::ReleaseDeleter<IDataStream>;
DataStreamFactory::DataStreamFactory() {
typedef IDataStreamFactory PluginType;
typedef musik::core::PluginFactory::DestroyDeleter<PluginType> Deleter;
typedef musik::core::PluginFactory::ReleaseDeleter<PluginType> Deleter;
this->dataStreamFactories = musik::core::PluginFactory::Instance()
.QueryInterface<PluginType, Deleter>("GetDataStreamFactory");
@ -64,7 +64,7 @@ DataStreamFactory* DataStreamFactory::Instance() {
}
IDataStream* DataStreamFactory::OpenDataStream(const char* uri) {
typedef musik::core::PluginFactory::DestroyDeleter<IDataStream> StreamDeleter;
typedef musik::core::PluginFactory::ReleaseDeleter<IDataStream> StreamDeleter;
if (uri) {
DataStreamFactoryVector::iterator it =
@ -87,7 +87,7 @@ IDataStream* DataStreamFactory::OpenDataStream(const char* uri) {
return regularFile;
}
else {
regularFile->Destroy();
regularFile->Release();
}
}

View File

@ -118,7 +118,7 @@ bool LocalFileStream::Close() {
return false;
}
void LocalFileStream::Destroy() {
void LocalFileStream::Release() {
delete this;
}

View File

@ -50,7 +50,7 @@ namespace musik { namespace core { namespace io {
virtual bool Open(const char *filename, unsigned int options = 0);
virtual bool Close();
virtual void Interrupt();
virtual void Destroy();
virtual void Release();
virtual PositionType Read(void* buffer, PositionType readBytes);
virtual bool SetPosition(PositionType position);
virtual PositionType Position();

View File

@ -79,9 +79,9 @@ using namespace musik::core::library;
using Thread = std::unique_ptr<boost::thread>;
using TagReaderDestroyer = PluginFactory::DestroyDeleter<ITagReader>;
using DecoderDeleter = PluginFactory::DestroyDeleter<IDecoderFactory>;
using SourceDeleter = PluginFactory::DestroyDeleter<IIndexerSource>;
using TagReaderDestroyer = PluginFactory::ReleaseDeleter<ITagReader>;
using DecoderDeleter = PluginFactory::ReleaseDeleter<IDecoderFactory>;
using SourceDeleter = PluginFactory::ReleaseDeleter<IIndexerSource>;
static std::string normalizeDir(std::string path) {
path = boost::filesystem::path(path).make_preferred().string();
@ -768,7 +768,7 @@ void Indexer::ProcessAddRemoveQueue() {
void Indexer::RunAnalyzers() {
typedef sdk::IAnalyzer PluginType;
typedef PluginFactory::DestroyDeleter<PluginType> Deleter;
typedef PluginFactory::ReleaseDeleter<PluginType> Deleter;
typedef std::shared_ptr<PluginType> PluginPtr;
typedef std::vector<PluginPtr> PluginVector;

View File

@ -76,7 +76,7 @@ PluginFactory::PluginFactory() {
PluginFactory::~PluginFactory() {
for (std::shared_ptr<Descriptor> plugin : this->plugins) {
plugin->plugin->Destroy();
plugin->plugin->Release();
closeNativeHandle(plugin->nativeHandle);
}
plugins.clear();

View File

@ -58,9 +58,9 @@ namespace musik { namespace core {
static PluginFactory& Instance();
template <typename T>
struct DestroyDeleter {
struct ReleaseDeleter {
void operator()(T* t) {
t->Destroy();
t->Release();
}
};

View File

@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk {
class IAnalyzer {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual bool Start(musik::core::sdk::ITagStore *target) = 0;
virtual bool Analyze(musik::core::sdk::ITagStore *target, IBuffer *buffer) = 0;
virtual bool End(musik::core::sdk::ITagStore *target) = 0;

View File

@ -46,7 +46,7 @@ namespace musik { namespace core { namespace sdk {
virtual long Samples() const = 0;
virtual void SetSamples(long samples) = 0;
virtual long Bytes() const = 0;
virtual void Destroy() = 0;
virtual void Release() = 0;
};
} } }

View File

@ -40,7 +40,7 @@ namespace musik { namespace core { namespace sdk {
class IDSP {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual bool Process(IBuffer *buffer) = 0;
};

View File

@ -40,11 +40,10 @@ namespace musik { namespace core { namespace sdk {
class IDataStream {
public:
/* v1 */
virtual bool Open(const char *uri, unsigned int options = 0) = 0;
virtual bool Close() = 0;
virtual void Interrupt() = 0;
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual PositionType Read(void *buffer, PositionType readBytes) = 0;
virtual bool SetPosition(PositionType position) = 0;
virtual PositionType Position() = 0;
@ -53,8 +52,6 @@ namespace musik { namespace core { namespace sdk {
virtual long Length() = 0;
virtual const char* Type() = 0;
virtual const char* Uri() = 0;
/* v5 */
virtual bool CanPrefetch() = 0;
};

View File

@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk {
public:
virtual bool CanRead(const char *uri) = 0;
virtual IDataStream* Open(const char *uri, unsigned int options = 0) = 0;
virtual void Destroy() = 0;
virtual void Release() = 0;
};
} } }

View File

@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk {
class IDecoder {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual double SetPosition(double seconds) = 0;
virtual bool GetBuffer(IBuffer *buffer) = 0;
virtual double GetDuration() = 0;

View File

@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk {
class IDecoderFactory{
public:
virtual IDecoder* CreateDecoder() = 0;
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual bool CanHandle(const char* type) const = 0;
};

View File

@ -41,14 +41,14 @@ namespace musik { namespace core { namespace sdk {
class IDevice {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual const char* Name() const = 0;
virtual const char* Id() const = 0;
};
class IDeviceList {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual size_t Count() const = 0;
virtual const IDevice* At(size_t index) const = 0;
};
@ -64,7 +64,7 @@ namespace musik { namespace core { namespace sdk {
return new Device(device->Id(), device->Name());
}
}
deviceList->Destroy();
deviceList->Release();
}
return result;
}
@ -78,7 +78,7 @@ namespace musik { namespace core { namespace sdk {
auto device = findDeviceById<Device, Output>(output, deviceId);
if (device) {
device->Destroy();
device->Release();
prefs->SetString(key, deviceId);
return true;
}

View File

@ -42,7 +42,7 @@ namespace musik { namespace core { namespace sdk {
class IIndexerSource {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual void OnBeforeScan() = 0;

View File

@ -43,12 +43,7 @@ namespace musik { namespace core { namespace sdk {
class IIndexerWriter {
public:
virtual ITagStore* CreateWriter() = 0;
virtual bool Save(
IIndexerSource* source,
ITagStore* track,
const char* externalId = "") = 0;
virtual bool Save(IIndexerSource* source, ITagStore* track, const char* externalId = "") = 0;
virtual bool RemoveByUri(IIndexerSource* source, const char* uri) = 0;
virtual bool RemoveByExternalId(IIndexerSource* source, const char* id) = 0;
virtual int RemoveAll(IIndexerSource* source) = 0;

View File

@ -44,7 +44,7 @@ namespace musik { namespace core { namespace sdk {
class IOutput {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual void Pause() = 0;
virtual void Resume() = 0;
virtual void SetVolume(double volume) = 0;

View File

@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk {
class IPcmVisualizer : public IVisualizer {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual void Write(IBuffer *target) = 0;
};

View File

@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk {
class IPlaybackRemote {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual void SetPlaybackService(IPlaybackService* playback) = 0;
virtual void OnTrackChanged(ITrack* track) = 0;
virtual void OnPlaybackStateChanged(PlaybackState state) = 0;

View File

@ -38,7 +38,7 @@ namespace musik { namespace core { namespace sdk {
class IPlugin {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual const char* Name() = 0;
virtual const char* Version() = 0;
virtual const char* Author() = 0;

View File

@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk {
class ISpectrumVisualizer : public IVisualizer {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual void Write(float *spectrum, int size) = 0;
};

View File

@ -42,7 +42,7 @@ namespace musik { namespace core { namespace sdk {
public:
virtual bool Read(const char *uri, musik::core::sdk::ITagStore *target) = 0;
virtual bool CanRead(const char *extension) = 0;
virtual void Destroy() = 0;
virtual void Release() = 0;
};
} } }

View File

@ -40,7 +40,7 @@ namespace musik { namespace core { namespace sdk {
class IVisualizer {
public:
virtual void Destroy() = 0;
virtual void Release() = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
virtual bool Visible() = 0;

View File

@ -107,7 +107,7 @@ static std::string getOutputDeviceName() {
IDevice* device = output->GetDefaultDevice();
if (device) {
deviceName = device->Name();
device->Destroy();
device->Release();
}
}

View File

@ -55,9 +55,9 @@ static std::vector<std::shared_ptr<IOutput> > plugins;
static std::set<std::string> invalidCrossfadeOutputs = { "WaveOut" };
template <typename T>
struct DestroyDeleter {
struct ReleaseDeleter {
void operator()(T* t) {
if (t) t->Destroy();
if (t) t->Release();
}
};
@ -164,10 +164,10 @@ void PlaybackOverlays::ShowOutputDeviceOverlay(std::function<void()> callback) {
std::string currentDeviceName = _TSTR("settings_output_device_default");
std::shared_ptr<IDeviceList> deviceList = std::shared_ptr<IDeviceList>(
output->GetDeviceList(), DestroyDeleter<IDeviceList>());
output->GetDeviceList(), ReleaseDeleter<IDeviceList>());
std::shared_ptr<IDevice> device = std::shared_ptr<IDevice>(
output->GetDefaultDevice(), DestroyDeleter<IDevice>());
output->GetDefaultDevice(), ReleaseDeleter<IDevice>());
if (device) {
currentDeviceName = device->Name();

View File

@ -270,7 +270,7 @@ void ServerOverlay::Show(Callback callback) {
std::shared_ptr<IPlugin> ServerOverlay::FindServerPlugin() {
std::shared_ptr<IPlugin> result;
using Deleter = PluginFactory::DestroyDeleter<IPlugin>;
using Deleter = PluginFactory::ReleaseDeleter<IPlugin>;
PluginFactory::Instance().QueryInterface<IPlugin, Deleter>(
"GetPlugin",
[&result](std::shared_ptr<IPlugin> plugin, const std::string& fn) {

View File

@ -84,7 +84,7 @@ class AlsaDevice : public IDevice {
this->name = name;
}
virtual void Destroy() override {
virtual void Release() override {
delete this;
}
@ -102,7 +102,7 @@ class AlsaDevice : public IDevice {
class AlsaDeviceList : public musik::core::sdk::IDeviceList {
public:
virtual void Destroy() override {
virtual void Release() override {
delete this;
}
@ -221,7 +221,7 @@ std::string AlsaOut::GetPreferredDeviceId() {
break;
}
}
deviceList->Destroy();
deviceList->Release();
}
}
@ -302,7 +302,7 @@ error:
this->CloseDevice();
}
void AlsaOut::Destroy() {
void AlsaOut::Release() {
delete this;
}

View File

@ -54,7 +54,7 @@ class AlsaOut : public musik::core::sdk::IOutput {
virtual const char* Name() override { return "AlsaOut"; }
/* IOutput */
virtual void Destroy() override;
virtual void Release() override;
virtual void Pause() override ;
virtual void Resume() override;
virtual void SetVolume(double volume) override;

View File

@ -154,7 +154,7 @@ void CddaDataStream::Interrupt() {
}
void CddaDataStream::Destroy() {
void CddaDataStream::Release() {
delete this;
}

View File

@ -50,7 +50,7 @@ class CddaDataStream : public IDataStream {
CddaDataStream();
~CddaDataStream();
virtual void Destroy();
virtual void Release();
virtual bool Open(const char *filename, unsigned int options = 0);
virtual bool Close();
virtual void Interrupt();

View File

@ -61,6 +61,6 @@ IDataStream* CddaDataStreamFactory::Open(const char *uri, unsigned int options)
return NULL;
}
void CddaDataStreamFactory::Destroy() {
void CddaDataStreamFactory::Release() {
delete this;
}

View File

@ -45,5 +45,5 @@ class CddaDataStreamFactory : public IDataStreamFactory {
virtual bool CanRead(const char *uri);
virtual IDataStream* Open(const char *uri, unsigned int options = 0);
virtual void Destroy();
virtual void Release();
};

View File

@ -50,7 +50,7 @@ CddaDecoder::~CddaDecoder() {
delete[] this->buffer;
}
void CddaDecoder::Destroy() {
void CddaDecoder::Release() {
delete this;
}

View File

@ -48,7 +48,7 @@ class CddaDecoder : public IDecoder {
~CddaDecoder();
virtual bool Open(IDataStream* data) override;
virtual void Destroy() override;
virtual void Release() override;
virtual double SetPosition(double seconds) override;
virtual double GetDuration() override;
virtual bool GetBuffer(IBuffer *buffer) override;

View File

@ -43,7 +43,7 @@ CddaDecoderFactory::CddaDecoderFactory() {
CddaDecoderFactory::~CddaDecoderFactory() {
}
void CddaDecoderFactory::Destroy() {
void CddaDecoderFactory::Release() {
delete this;
}

View File

@ -43,6 +43,6 @@ public:
CddaDecoderFactory();
~CddaDecoderFactory();
virtual IDecoder* CreateDecoder();
virtual void Destroy();
virtual void Release();
virtual bool CanHandle(const char* type) const;
};

View File

@ -277,7 +277,7 @@ CddaIndexerSource::~CddaIndexerSource() {
model.RemoveEventListener(this);
}
void CddaIndexerSource::Destroy() {
void CddaIndexerSource::Release() {
delete this;
}

View File

@ -47,7 +47,7 @@ class CddaIndexerSource :
~CddaIndexerSource();
/* IIndexerSource */
virtual void Destroy();
virtual void Release();
virtual void OnBeforeScan();
virtual void OnAfterScan();
virtual int SourceId();

View File

@ -50,7 +50,7 @@ BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
}
class CddaDecoderPlugin : public musik::core::sdk::IPlugin {
virtual void Destroy() { delete this; };
virtual void Release() { delete this; };
virtual const char* Name() { return PLUGIN_NAME; }
virtual const char* Version() { return "0.5.0"; }
virtual const char* Author() { return "Björn Olievier, clangen"; }

View File

@ -50,7 +50,7 @@ class CoreAudioDevice : public IDevice {
this->name = name;
}
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual const char* Name() const { return name.c_str(); }
virtual const char* Id() const { return id.c_str(); }
@ -60,7 +60,7 @@ class CoreAudioDevice : public IDevice {
class CoreAudioDeviceList : public IDeviceList {
public:
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual size_t Count() const { return devices.size(); }
virtual const IDevice* At(size_t index) const { return &devices.at(index); }
@ -197,7 +197,7 @@ int CoreAudioOut::Play(IBuffer *buffer, IBufferProvider *provider) {
CFRelease(deviceUid);
}
device->Destroy();
device->Release();
}
/* get it running! */
@ -254,7 +254,7 @@ CoreAudioOut::~CoreAudioOut() {
this->Stop();
}
void CoreAudioOut::Destroy() {
void CoreAudioOut::Release() {
delete this;
}

View File

@ -58,7 +58,7 @@ class CoreAudioOut : public musik::core::sdk::IOutput {
virtual const char* Name() override { return "CoreAudio"; }
/* IOutput */
virtual void Destroy() override;
virtual void Release() override;
virtual void Pause() override;
virtual void Resume() override;
virtual void SetVolume(double volume) override;

View File

@ -70,7 +70,7 @@ class DxDevice : public musik::core::sdk::IDevice {
this->name = name;
}
virtual void Destroy() override { delete this; }
virtual void Release() override { delete this; }
virtual const char* Name() const override { return name.c_str(); }
virtual const char* Id() const override { return id.c_str(); }
@ -80,7 +80,7 @@ class DxDevice : public musik::core::sdk::IDevice {
class DxDeviceList : public musik::core::sdk::IDeviceList {
public:
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual size_t Count() const override { return devices.size(); }
virtual const IDevice* At(size_t index) const override { return &devices.at(index); }
@ -121,7 +121,7 @@ class DrainBuffer :
virtual void SetSamples(long samples) { this->samples = samples; }
virtual long Bytes() const { return this->samples * sizeof(float); }
virtual void OnBufferProcessed(IBuffer *buffer) { }
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
private:
int channels, samples, rate;
@ -172,7 +172,7 @@ DirectSoundOut::DirectSoundOut()
DirectSoundOut::~DirectSoundOut() {
}
void DirectSoundOut::Destroy() {
void DirectSoundOut::Release() {
this->Reset();
delete this;
}
@ -452,7 +452,7 @@ LPCGUID DirectSoundOut::GetPreferredDeviceId() {
}
}
}
devices->Destroy();
devices->Release();
}
}

View File

@ -59,7 +59,7 @@ class DirectSoundOut : public IOutput {
/* IPlugin */
virtual const char* Name() { return "DirectSound"; };
virtual void Destroy();
virtual void Release();
/* IOutput */
virtual void Pause() override;

View File

@ -41,7 +41,7 @@
class DirectSoundPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual const char* Name() { return "DirectSound IOutput"; };
virtual const char* Version() { return "0.5.0"; };
virtual const char* Author() { return "clangen"; };

View File

@ -209,7 +209,7 @@ FLAC__StreamDecoderWriteStatus FlacDecoder::FlacWrite(
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
void FlacDecoder::Destroy() {
void FlacDecoder::Release() {
delete this;
}

View File

@ -47,7 +47,7 @@ class FlacDecoder : public musik::core::sdk::IDecoder {
FlacDecoder();
~FlacDecoder();
virtual void Destroy() override;
virtual void Release() override;
virtual double SetPosition(double seconds) override;
virtual bool GetBuffer(IBuffer *buffer) override;
virtual double GetDuration() override;

View File

@ -54,7 +54,7 @@ FlacDecoderFactory::FlacDecoderFactory() {
FlacDecoderFactory::~FlacDecoderFactory() {
}
void FlacDecoderFactory::Destroy() {
void FlacDecoderFactory::Release() {
delete this;
}

View File

@ -41,6 +41,6 @@ class FlacDecoderFactory : public musik::core::sdk::IDecoderFactory {
FlacDecoderFactory();
~FlacDecoderFactory();
virtual musik::core::sdk::IDecoder* CreateDecoder();
virtual void Destroy();
virtual void Release();
virtual bool CanHandle(const char* type) const;
};

View File

@ -53,7 +53,7 @@
class FlacPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; };
virtual void Release() { delete this; };
virtual const char* Name() { return "FLAC IDecoder"; }
virtual const char* Version() { return "0.4.0"; }
virtual const char* Author() { return "Daniel Önnerby, clangen"; }

View File

@ -340,7 +340,7 @@ bool HttpDataStream::Close() {
return true;
}
void HttpDataStream::Destroy() {
void HttpDataStream::Release() {
this->Close();
delete this;
}

View File

@ -50,7 +50,7 @@ class HttpDataStream : public IDataStream {
HttpDataStream();
~HttpDataStream();
virtual void Destroy();
virtual void Release();
virtual bool Open(const char *uri, unsigned int options = 0);
virtual bool Close();
virtual PositionType Read(void* buffer, PositionType readBytes);

View File

@ -62,6 +62,6 @@ IDataStream* HttpDataStreamFactory::Open(const char *uri, unsigned int options)
return nullptr;
}
void HttpDataStreamFactory::Destroy() {
void HttpDataStreamFactory::Release() {
delete this;
}

View File

@ -43,5 +43,5 @@ class HttpDataStreamFactory : public IDataStreamFactory {
virtual bool CanRead(const char *uri);
virtual IDataStream* Open(const char *uri, unsigned int options = 0);
virtual void Destroy();
virtual void Release();
};

View File

@ -61,7 +61,7 @@ static class HttpDataStreamPlugin : public musik::core::sdk::IPlugin {
boost::filesystem::path::imbue(utf8Locale);
}
virtual void Destroy() { };
virtual void Release() { };
virtual const char* Name() { return "HTTP IDataStream"; }
virtual const char* Version() { return "0.1.0"; }
virtual const char* Author() { return "clangen"; }

View File

@ -151,7 +151,7 @@ bool M4aDecoder::Open(musik::core::sdk::IDataStream *stream) {
return false;
}
void M4aDecoder::Destroy() {
void M4aDecoder::Release() {
mp4ff_close(decoderFile);
if (decoder) {

View File

@ -43,7 +43,7 @@ class M4aDecoder : public musik::core::sdk::IDecoder {
M4aDecoder();
~M4aDecoder();
virtual void Destroy() override;
virtual void Release() override;
virtual double SetPosition(double seconds) override;
virtual bool GetBuffer(musik::core::sdk::IBuffer *buffer) override;
virtual double GetDuration() override;

View File

@ -53,7 +53,7 @@ M4aDecoderFactory::M4aDecoderFactory() {
M4aDecoderFactory::~M4aDecoderFactory() {
}
void M4aDecoderFactory::Destroy() {
void M4aDecoderFactory::Release() {
delete this;
}

View File

@ -41,6 +41,6 @@ class M4aDecoderFactory : public musik::core::sdk::IDecoderFactory {
M4aDecoderFactory();
~M4aDecoderFactory();
virtual musik::core::sdk::IDecoder* CreateDecoder();
virtual void Destroy();
virtual void Release();
virtual bool CanHandle(const char* source) const;
};

View File

@ -53,7 +53,7 @@
class AacDecoderPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; };
virtual void Release() { delete this; };
virtual const char* Name() { return "M4A IDecoder"; };
virtual const char* Version() { return "0.4.0"; };
virtual const char* Author() { return "Björn Olievier, clangen"; };

View File

@ -88,7 +88,7 @@ NomadDecoder::NomadDecoder() {
NomadDecoder::~NomadDecoder() {
}
void NomadDecoder::Destroy() {
void NomadDecoder::Release() {
if (this->nomadContext) {
nomad_close(this->nomadContext);
this->nomadContext = nullptr;

View File

@ -50,7 +50,7 @@ class NomadDecoder : public musik::core::sdk::IDecoder {
virtual double SetPosition(double seconds) override;
virtual bool GetBuffer(musik::core::sdk::IBuffer *buffer) override;
virtual double GetDuration() override;
virtual void Destroy() override;
virtual void Release() override;
virtual bool Exhausted() override { return this->exhausted; }
private:

View File

@ -53,7 +53,7 @@ NomadDecoderFactory::NomadDecoderFactory() {
NomadDecoderFactory::~NomadDecoderFactory() {
}
void NomadDecoderFactory::Destroy() {
void NomadDecoderFactory::Release() {
delete this;
}

View File

@ -41,6 +41,6 @@ class NomadDecoderFactory : public musik::core::sdk::IDecoderFactory {
NomadDecoderFactory();
~NomadDecoderFactory();
virtual musik::core::sdk::IDecoder* CreateDecoder();
virtual void Destroy();
virtual void Release();
virtual bool CanHandle(const char* type) const;
};

View File

@ -52,7 +52,7 @@
#endif
class NomadPlugin : public musik::core::sdk::IPlugin {
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual const char* Name() { return "nomad IDecoder"; }
virtual const char* Version() { return "0.2.0"; }
virtual const char* Author() { return "clangen"; }

View File

@ -53,7 +53,7 @@ NullOut::NullOut() {
NullOut::~NullOut() {
}
void NullOut::Destroy() {
void NullOut::Release() {
delete this;
}

View File

@ -46,7 +46,7 @@ class NullOut : public IOutput {
/* IPlugin */
virtual const char* Name() override { return "Null"; };
virtual void Destroy() override;
virtual void Release() override;
/* IOutput */
virtual void Pause() override;

View File

@ -46,7 +46,7 @@
class NullPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual const char* Name() { return "Null IOutput"; }
virtual const char* Version() { return "0.2.0"; }
virtual const char* Author() { return "clangen"; }

View File

@ -109,7 +109,7 @@ bool OggDecoder::Open(musik::core::sdk::IDataStream *fileStream) {
return true;
}
void OggDecoder::Destroy() {
void OggDecoder::Release() {
ov_clear(&this->oggFile);
delete this;
}

View File

@ -45,7 +45,7 @@ class OggDecoder : public IDecoder {
OggDecoder();
~OggDecoder();
virtual void Destroy() override;
virtual void Release() override;
virtual double SetPosition(double second) override;
virtual bool GetBuffer(IBuffer *buffer) override;
virtual double GetDuration() override;

View File

@ -51,7 +51,7 @@ OggDecoderFactory::OggDecoderFactory() {
OggDecoderFactory::~OggDecoderFactory() {
}
void OggDecoderFactory::Destroy() {
void OggDecoderFactory::Release() {
delete this;
}

View File

@ -44,6 +44,6 @@ class OggDecoderFactory : public IDecoderFactory {
~OggDecoderFactory();
virtual IDecoder* CreateDecoder();
virtual void Destroy();
virtual void Release();
virtual bool CanHandle(const char* type) const;
};

View File

@ -51,7 +51,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
class OggDecoderPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; };
virtual void Release() { delete this; };
virtual const char* Name() { return "Ogg IDecoder"; }
virtual const char* Version() { return "0.4.0"; }
virtual const char* Author() { return "Björn Olievier, clangen"; }

View File

@ -57,7 +57,7 @@ class PulseDevice : public musik::core::sdk::IDevice {
this->name = name;
}
virtual void Destroy() {
virtual void Release() {
delete this;
}
@ -75,7 +75,7 @@ class PulseDevice : public musik::core::sdk::IDevice {
class PulseDeviceList : public musik::core::sdk::IDeviceList {
public:
virtual void Destroy() {
virtual void Release() {
delete this;
}
@ -231,7 +231,7 @@ std::string PulseOut::GetPreferredDeviceId() {
std::string deviceId = getDeviceId();
auto device = findDeviceById<PulseDevice>(this, deviceId);
if (device) {
device->Destroy();
device->Release();
return deviceId;
}
return "";
@ -289,7 +289,7 @@ void PulseOut::OpenDevice(musik::core::sdk::IBuffer* buffer) {
}
}
void PulseOut::Destroy() {
void PulseOut::Release() {
std::cerr << "PulseOut: destroy\n";
delete this;
}

View File

@ -50,7 +50,7 @@ class PulseOut : public musik::core::sdk::IOutput {
virtual const char* Name() override { return "PulseAudio"; }
/* IOutput */
virtual void Destroy() override;
virtual void Release() override;
virtual void Pause() override;
virtual void Resume() override;
virtual void SetVolume(double volume) override;

View File

@ -99,7 +99,7 @@ TaglibMetadataReader::TaglibMetadataReader() {
TaglibMetadataReader::~TaglibMetadataReader() {
}
void TaglibMetadataReader::Destroy() {
void TaglibMetadataReader::Release() {
delete this;
}

View File

@ -65,7 +65,7 @@ class TaglibMetadataReader : public musik::core::sdk::ITagReader {
virtual bool Read(const char *uri, musik::core::sdk::ITagStore *target);
virtual bool CanRead(const char *extension);
virtual void Destroy();
virtual void Release();
private:
template <typename T> void ReadFromMap(

View File

@ -51,7 +51,7 @@
class TaglibPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual const char* Name() { return "Taglib 1.11 ITagReader"; }
virtual const char* Version() { return "0.6.0"; }
virtual const char* Author() { return "Daniel Önnerby, clangen"; }

View File

@ -80,7 +80,7 @@ class WasapiDevice : public musik::core::sdk::IDevice {
this->name = name;
}
virtual void Destroy() override { delete this; }
virtual void Release() override { delete this; }
virtual const char* Name() const override { return name.c_str(); }
virtual const char* Id() const override { return id.c_str(); }
@ -90,7 +90,7 @@ class WasapiDevice : public musik::core::sdk::IDevice {
class WasapiDeviceList : public musik::core::sdk::IDeviceList {
public:
virtual void Destroy() override { delete this; }
virtual void Release() override { delete this; }
virtual size_t Count() const override { return devices.size(); }
virtual const IDevice* At(size_t index) const override { return &devices.at(index); }
@ -219,7 +219,7 @@ WasapiOut::WasapiOut()
WasapiOut::~WasapiOut() {
}
void WasapiOut::Destroy() {
void WasapiOut::Release() {
this->Reset();
if (this->enumerator) {

View File

@ -57,7 +57,7 @@ class WasapiOut : public IOutput {
/* IPlugin */
virtual const char* Name() { return "WASAPI"; };
virtual void Destroy();
virtual void Release();
/* IOutput */
virtual void Pause() override;

View File

@ -41,7 +41,7 @@
class WasapiPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual const char* Name() { return "Wasapi IOutput"; }
virtual const char* Version() { return "0.5.0"; }
virtual const char* Author() { return "clangen"; }

View File

@ -54,7 +54,7 @@ class WaveOutDevice : public musik::core::sdk::IDevice {
this->name = name;
}
virtual void Destroy() override { delete this; }
virtual void Release() override { delete this; }
virtual const char* Name() const override { return name.c_str(); }
virtual const char* Id() const override { return id.c_str(); }
@ -64,7 +64,7 @@ class WaveOutDevice : public musik::core::sdk::IDevice {
class WaveOutDeviceList : public musik::core::sdk::IDeviceList {
public:
virtual void Destroy() override { delete this; }
virtual void Release() override { delete this; }
virtual size_t Count() const override { return devices.size(); }
virtual const IDevice* At(size_t index) const override { return &devices.at(index); }
@ -119,7 +119,7 @@ WaveOut::WaveOut()
WaveOut::~WaveOut() {
}
void WaveOut::Destroy() {
void WaveOut::Release() {
{
LockT lock(this->outputDeviceMutex);

View File

@ -52,7 +52,7 @@ class WaveOut : public IOutput {
/* IPlugin */
virtual const char* Name() { return "WaveOut"; };
virtual void Destroy();
virtual void Release();
/* IOutput */
virtual void Pause() override;

View File

@ -39,7 +39,7 @@
class WaveOutPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual const char* Name() { return "WaveOut IOutput"; }
virtual const char* Version() { return "0.7.0"; }
virtual const char* Author() { return "Bj\xC3\xB6rn Olievier, clangen"; }

View File

@ -410,7 +410,7 @@ int HttpServer::HandleRequest(
}
else {
if (file) {
file->Destroy();
file->Release();
file = nullptr;
}
@ -484,7 +484,7 @@ int HttpServer::HandleRequest(
}
}
else {
file->Destroy();
file->Release();
file = nullptr;
}
}

View File

@ -179,7 +179,7 @@ IDataStream* Transcoder::TranscodeAndWait(Context& context, const std::string& u
std::this_thread::yield();
}
transcoder->Destroy();
transcoder->Release();
PruneTranscodeCache(context);
return context.environment->GetDataStream(uri.c_str());

View File

@ -134,17 +134,17 @@ bool TranscodingDataStream::Close() {
void TranscodingDataStream::Dispose() {
if (this->pcmBuffer) {
this->pcmBuffer->Destroy();
this->pcmBuffer->Release();
this->pcmBuffer = nullptr;
}
if (this->decoder) {
this->decoder->Destroy();
this->decoder->Release();
this->decoder = nullptr;
}
if (this->input) {
this->input->Destroy();
this->input->Release();
this->input = nullptr;
}
@ -167,7 +167,7 @@ void TranscodingDataStream::Interrupt() {
this->interrupted = true;
}
void TranscodingDataStream::Destroy() {
void TranscodingDataStream::Release() {
this->Dispose();
}

View File

@ -62,7 +62,7 @@ class TranscodingDataStream : public musik::core::sdk::IDataStream {
virtual bool Open(const char *uri, unsigned int options = 0) override;
virtual bool Close() override;
virtual void Interrupt() override;
virtual void Destroy() override;
virtual void Release() override;
virtual PositionType Read(void *buffer, PositionType readBytes) override;
virtual bool SetPosition(PositionType position) override;
virtual PositionType Position() override;

View File

@ -74,7 +74,7 @@ static class PlaybackRemote : public IPlaybackRemote {
this->Stop();
}
virtual void Destroy() {
virtual void Release() {
}
void Reload() {
@ -158,7 +158,7 @@ static class Plugin : public IPlugin {
boost::filesystem::path::imbue(utf8Locale);
}
virtual void Destroy() { }
virtual void Release() { }
virtual const char* Name() { return "WebSockets IPlaybackRemote"; }
virtual const char* Version() { return "0.6.0"; }
virtual const char* Author() { return "clangen"; }

View File

@ -203,7 +203,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) {
class VisualizerPlugin : public musik::core::sdk::IPlugin {
public:
virtual void Destroy() { delete this; }
virtual void Release() { delete this; }
virtual const char* Name() { return "GdiVis"; }
virtual const char* Version() { return "0.2.0"; }
virtual const char* Author() { return "clangen"; }
@ -220,7 +220,7 @@ class Visualizer : public musik::core::sdk::ISpectrumVisualizer {
return "GdiVis";
}
virtual void Destroy() {
virtual void Release() {
this->Hide();
delete this;
}

View File

@ -157,7 +157,7 @@ class MMShellHook:
public musik::core::sdk::IPlugin,
public musik::core::sdk::IPlaybackRemote {
public:
virtual void Destroy() {
virtual void Release() {
}
virtual const char* Name() {