aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-29 02:16:16 -0800
committerChris Robinson <[email protected]>2018-12-29 02:16:16 -0800
commit71a4d6db6f88cbb735cd959b3dd16d83a27474cf (patch)
tree4aff47e22dc5c8486c7229e23848edb34cc11ada
parent3c637d5fd70e7bdb5dfc79c515359cba3eb0c9af (diff)
Return a unique_ptr for the backend
-rw-r--r--Alc/alc.cpp3
-rw-r--r--Alc/backends/alsa.cpp6
-rw-r--r--Alc/backends/alsa.h2
-rw-r--r--Alc/backends/base.cpp2
-rw-r--r--Alc/backends/base.h5
-rw-r--r--Alc/backends/coreaudio.cpp6
-rw-r--r--Alc/backends/coreaudio.h2
-rw-r--r--Alc/backends/dsound.cpp6
-rw-r--r--Alc/backends/dsound.h2
-rw-r--r--Alc/backends/jack.cpp4
-rw-r--r--Alc/backends/jack.h2
-rw-r--r--Alc/backends/loopback.cpp4
-rw-r--r--Alc/backends/loopback.h2
-rw-r--r--Alc/backends/null.cpp4
-rw-r--r--Alc/backends/null.h2
-rw-r--r--Alc/backends/opensl.cpp6
-rw-r--r--Alc/backends/opensl.h2
-rw-r--r--Alc/backends/oss.cpp6
-rw-r--r--Alc/backends/oss.h2
-rw-r--r--Alc/backends/portaudio.cpp6
-rw-r--r--Alc/backends/portaudio.h2
-rw-r--r--Alc/backends/pulseaudio.cpp6
-rw-r--r--Alc/backends/pulseaudio.h2
-rw-r--r--Alc/backends/qsa.cpp6
-rw-r--r--Alc/backends/qsa.h2
-rw-r--r--Alc/backends/sdl2.cpp4
-rw-r--r--Alc/backends/sdl2.h2
-rw-r--r--Alc/backends/sndio.cpp6
-rw-r--r--Alc/backends/sndio.h2
-rw-r--r--Alc/backends/solaris.cpp4
-rw-r--r--Alc/backends/solaris.h2
-rw-r--r--Alc/backends/wasapi.cpp6
-rw-r--r--Alc/backends/wasapi.h2
-rw-r--r--Alc/backends/wave.cpp4
-rw-r--r--Alc/backends/wave.h2
-rw-r--r--Alc/backends/winmm.cpp6
-rw-r--r--Alc/backends/winmm.h2
-rw-r--r--OpenAL32/Include/alMain.h2
38 files changed, 68 insertions, 68 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index c625fd20..517e98d3 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -2203,7 +2203,6 @@ ALCdevice_struct::~ALCdevice_struct()
{
TRACE("%p\n", this);
- delete Backend;
Backend = nullptr;
size_t count{std::accumulate(BufferList.cbegin(), BufferList.cend(), size_t{0u},
@@ -4037,7 +4036,7 @@ ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer,
ALCenum err{ALC_INVALID_VALUE};
{ std::lock_guard<std::mutex> _{dev->BackendLock};
- BackendBase *backend{dev->Backend};
+ BackendBase *backend{dev->Backend.get()};
if(samples >= 0 && backend->availableSamples() >= (ALCuint)samples)
err = backend->captureSamples(buffer, samples);
}
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp
index 543c2bee..7ff26a33 100644
--- a/Alc/backends/alsa.cpp
+++ b/Alc/backends/alsa.cpp
@@ -1292,12 +1292,12 @@ void AlsaBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *AlsaBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr AlsaBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new AlsaPlayback{device};
+ return BackendPtr{new AlsaPlayback{device}};
if(type == BackendType::Capture)
- return new AlsaCapture{device};
+ return BackendPtr{new AlsaCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/alsa.h b/Alc/backends/alsa.h
index 15a646f9..5730ba9a 100644
--- a/Alc/backends/alsa.h
+++ b/Alc/backends/alsa.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/base.cpp b/Alc/backends/base.cpp
index 1fef0439..0afc4ee1 100644
--- a/Alc/backends/base.cpp
+++ b/Alc/backends/base.cpp
@@ -19,7 +19,7 @@ void ALCdevice_Unlock(ALCdevice *device)
ClockLatency GetClockLatency(ALCdevice *device)
{
- BackendBase *backend{device->Backend};
+ BackendBase *backend{device->Backend.get()};
ClockLatency ret{backend->getClockLatency()};
ret.Latency += device->FixedLatency;
return ret;
diff --git a/Alc/backends/base.h b/Alc/backends/base.h
index 0fc7de38..0b9803a2 100644
--- a/Alc/backends/base.h
+++ b/Alc/backends/base.h
@@ -1,6 +1,7 @@
#ifndef ALC_BACKENDS_BASE_H
#define ALC_BACKENDS_BASE_H
+#include <memory>
#include <chrono>
#include <string>
#include <mutex>
@@ -53,7 +54,7 @@ struct BackendBase {
BackendBase(ALCdevice *device) noexcept;
virtual ~BackendBase();
};
-
+using BackendPtr = std::unique_ptr<BackendBase>;
enum class BackendType {
Playback,
@@ -70,7 +71,7 @@ struct BackendFactory {
virtual void probe(DevProbe type, std::string *outnames) = 0;
- virtual BackendBase *createBackend(ALCdevice *device, BackendType type) = 0;
+ virtual BackendPtr createBackend(ALCdevice *device, BackendType type) = 0;
};
#endif /* ALC_BACKENDS_BASE_H */
diff --git a/Alc/backends/coreaudio.cpp b/Alc/backends/coreaudio.cpp
index f4010631..2caa0852 100644
--- a/Alc/backends/coreaudio.cpp
+++ b/Alc/backends/coreaudio.cpp
@@ -703,11 +703,11 @@ void CoreAudioBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *CoreAudioBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr CoreAudioBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new CoreAudioPlayback{device};
+ return BackendPtr{new CoreAudioPlayback{device}};
if(type == BackendType::Capture)
- return new CoreAudioCapture{device};
+ return BackendPtr{new CoreAudioCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/coreaudio.h b/Alc/backends/coreaudio.h
index d0ac9558..fd6dd4fc 100644
--- a/Alc/backends/coreaudio.h
+++ b/Alc/backends/coreaudio.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp
index bdb9cf28..aa0f80df 100644
--- a/Alc/backends/dsound.cpp
+++ b/Alc/backends/dsound.cpp
@@ -949,11 +949,11 @@ void DSoundBackendFactory::probe(DevProbe type, std::string *outnames)
CoUninitialize();
}
-BackendBase *DSoundBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr DSoundBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new DSoundPlayback{device};
+ return BackendPtr{new DSoundPlayback{device}};
if(type == BackendType::Capture)
- return new DSoundCapture{device};
+ return BackendPtr{new DSoundCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/dsound.h b/Alc/backends/dsound.h
index 819c4231..89484b4d 100644
--- a/Alc/backends/dsound.h
+++ b/Alc/backends/dsound.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp
index eb96392f..e917d3e6 100644
--- a/Alc/backends/jack.cpp
+++ b/Alc/backends/jack.cpp
@@ -558,10 +558,10 @@ void JackBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *JackBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr JackBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new JackPlayback{device};
+ return BackendPtr{new JackPlayback{device}};
return nullptr;
}
diff --git a/Alc/backends/jack.h b/Alc/backends/jack.h
index 421fafde..0948213f 100644
--- a/Alc/backends/jack.h
+++ b/Alc/backends/jack.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/loopback.cpp b/Alc/backends/loopback.cpp
index 6bce90ff..6404d413 100644
--- a/Alc/backends/loopback.cpp
+++ b/Alc/backends/loopback.cpp
@@ -70,10 +70,10 @@ bool LoopbackBackendFactory::querySupport(BackendType type)
void LoopbackBackendFactory::probe(DevProbe, std::string*)
{ }
-BackendBase *LoopbackBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr LoopbackBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Loopback)
- new LoopbackBackend{device};
+ return BackendPtr{new LoopbackBackend{device}};
return nullptr;
}
diff --git a/Alc/backends/loopback.h b/Alc/backends/loopback.h
index cf5eb02a..e40ce963 100644
--- a/Alc/backends/loopback.h
+++ b/Alc/backends/loopback.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp
index 480b5554..3aee7204 100644
--- a/Alc/backends/null.cpp
+++ b/Alc/backends/null.cpp
@@ -169,10 +169,10 @@ void NullBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *NullBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr NullBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new NullBackend{device};
+ return BackendPtr{new NullBackend{device}};
return nullptr;
}
diff --git a/Alc/backends/null.h b/Alc/backends/null.h
index 87796b7a..1488e1d0 100644
--- a/Alc/backends/null.h
+++ b/Alc/backends/null.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp
index c6a8cf82..adcc943c 100644
--- a/Alc/backends/opensl.cpp
+++ b/Alc/backends/opensl.cpp
@@ -934,12 +934,12 @@ void OSLBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *OSLBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr OSLBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new OpenSLPlayback{device};
+ return BackendPtr{new OpenSLPlayback{device}};
if(type == BackendType::Capture)
- return new OpenSLCapture{device};
+ return BackendPtr{new OpenSLCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/opensl.h b/Alc/backends/opensl.h
index d553b80d..cf694f01 100644
--- a/Alc/backends/opensl.h
+++ b/Alc/backends/opensl.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp
index 90da18c7..776d665b 100644
--- a/Alc/backends/oss.cpp
+++ b/Alc/backends/oss.cpp
@@ -751,11 +751,11 @@ void OSSBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *OSSBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr OSSBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new OSSPlayback{device};
+ return BackendPtr{new OSSPlayback{device}};
if(type == BackendType::Capture)
- return new OSScapture{device};
+ return BackendPtr{new OSScapture{device}};
return nullptr;
}
diff --git a/Alc/backends/oss.h b/Alc/backends/oss.h
index f59bfe18..e07cd573 100644
--- a/Alc/backends/oss.h
+++ b/Alc/backends/oss.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp
index ae01da70..258f981e 100644
--- a/Alc/backends/portaudio.cpp
+++ b/Alc/backends/portaudio.cpp
@@ -467,12 +467,12 @@ void PortBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *PortBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr PortBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new PortPlayback{device};
+ return BackendPtr{new PortPlayback{device}};
if(type == BackendType::Capture)
- return new PortCapture{device};
+ return BackendPtr{new PortCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/portaudio.h b/Alc/backends/portaudio.h
index 84ef11d9..1fd45ff3 100644
--- a/Alc/backends/portaudio.h
+++ b/Alc/backends/portaudio.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index 8a089b88..e714ac3f 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -1664,12 +1664,12 @@ void PulseBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *PulseBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr PulseBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new PulsePlayback{device};
+ return BackendPtr{new PulsePlayback{device}};
if(type == BackendType::Capture)
- return new PulseCapture{device};
+ return BackendPtr{new PulseCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/pulseaudio.h b/Alc/backends/pulseaudio.h
index b7e71d82..336276e6 100644
--- a/Alc/backends/pulseaudio.h
+++ b/Alc/backends/pulseaudio.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp
index 0c695d92..abf046b1 100644
--- a/Alc/backends/qsa.cpp
+++ b/Alc/backends/qsa.cpp
@@ -952,12 +952,12 @@ void QSABackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *QSABackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr QSABackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new PlaybackWrapper{device};
+ return BackendPtr{new PlaybackWrapper{device}};
if(type == BackendType::Capture)
- return new CaptureWrapper{device};
+ return BackendPtr{new CaptureWrapper{device}};
return nullptr;
}
diff --git a/Alc/backends/qsa.h b/Alc/backends/qsa.h
index c136f652..fdd81b4f 100644
--- a/Alc/backends/qsa.h
+++ b/Alc/backends/qsa.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/sdl2.cpp b/Alc/backends/sdl2.cpp
index 72c2dbcd..7665146a 100644
--- a/Alc/backends/sdl2.cpp
+++ b/Alc/backends/sdl2.cpp
@@ -223,9 +223,9 @@ void SDL2BackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *SDL2BackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr SDL2BackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new Sdl2Backend{device};
+ return BackendPtr{new Sdl2Backend{device}};
return nullptr;
}
diff --git a/Alc/backends/sdl2.h b/Alc/backends/sdl2.h
index 34d30b16..aefe1ef5 100644
--- a/Alc/backends/sdl2.h
+++ b/Alc/backends/sdl2.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp
index a592632c..dd2cb8a8 100644
--- a/Alc/backends/sndio.cpp
+++ b/Alc/backends/sndio.cpp
@@ -492,11 +492,11 @@ void SndIOBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *SndIOBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr SndIOBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new SndioPlayback{device};
+ return BackendPtr{new SndioPlayback{device}};
if(type == BackendType::Capture)
- return new SndioCapture{device};
+ return BackendPtr{new SndioCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/sndio.h b/Alc/backends/sndio.h
index 2280ca2c..5cd4ff8a 100644
--- a/Alc/backends/sndio.h
+++ b/Alc/backends/sndio.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp
index 5b93f8ca..dd940887 100644
--- a/Alc/backends/solaris.cpp
+++ b/Alc/backends/solaris.cpp
@@ -292,9 +292,9 @@ void SolarisBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *SolarisBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr SolarisBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new SolarisBackend{device};
+ return BackendPtr{new SolarisBackend{device}};
return nullptr;
}
diff --git a/Alc/backends/solaris.h b/Alc/backends/solaris.h
index 60c5c677..99623be4 100644
--- a/Alc/backends/solaris.h
+++ b/Alc/backends/solaris.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp
index ca4bdbd3..51a2f58d 100644
--- a/Alc/backends/wasapi.cpp
+++ b/Alc/backends/wasapi.cpp
@@ -1810,12 +1810,12 @@ void WasapiBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *WasapiBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr WasapiBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new WasapiPlayback{device};
+ return BackendPtr{new WasapiPlayback{device}};
if(type == BackendType::Capture)
- return new WasapiCapture{device};
+ return BackendPtr{new WasapiCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/wasapi.h b/Alc/backends/wasapi.h
index 16395371..ab9f8162e 100644
--- a/Alc/backends/wasapi.h
+++ b/Alc/backends/wasapi.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp
index ef0f6db7..435de766 100644
--- a/Alc/backends/wave.cpp
+++ b/Alc/backends/wave.cpp
@@ -380,10 +380,10 @@ void WaveBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *WaveBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr WaveBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new WaveBackend{device};
+ return BackendPtr{new WaveBackend{device}};
return nullptr;
}
diff --git a/Alc/backends/wave.h b/Alc/backends/wave.h
index 6dde7e0b..f3617b6d 100644
--- a/Alc/backends/wave.h
+++ b/Alc/backends/wave.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp
index dad505f4..3c9aa776 100644
--- a/Alc/backends/winmm.cpp
+++ b/Alc/backends/winmm.cpp
@@ -634,12 +634,12 @@ void WinMMBackendFactory::probe(DevProbe type, std::string *outnames)
}
}
-BackendBase *WinMMBackendFactory::createBackend(ALCdevice *device, BackendType type)
+BackendPtr WinMMBackendFactory::createBackend(ALCdevice *device, BackendType type)
{
if(type == BackendType::Playback)
- return new WinMMPlayback{device};
+ return BackendPtr{new WinMMPlayback{device}};
if(type == BackendType::Capture)
- return new WinMMCapture{device};
+ return BackendPtr{new WinMMCapture{device}};
return nullptr;
}
diff --git a/Alc/backends/winmm.h b/Alc/backends/winmm.h
index 85f23b3a..4d9fe32d 100644
--- a/Alc/backends/winmm.h
+++ b/Alc/backends/winmm.h
@@ -12,7 +12,7 @@ public:
void probe(DevProbe type, std::string *outnames) override;
- BackendBase *createBackend(ALCdevice *device, BackendType type) override;
+ BackendPtr createBackend(ALCdevice *device, BackendType type) override;
static BackendFactory &getFactory();
};
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 391ef8df..e23eb1fb 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -786,7 +786,7 @@ struct ALCdevice_struct {
std::atomic<ALCcontext*> ContextList{nullptr};
std::mutex BackendLock;
- BackendBase *Backend{nullptr};
+ std::unique_ptr<BackendBase> Backend;
std::atomic<ALCdevice*> next{nullptr};