Removed auto_ptr usage.
This commit is contained in:
parent
686d0fa76c
commit
8ebb622057
|
@ -29,7 +29,6 @@
|
|||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/Listener.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace
|
||||
|
@ -103,32 +102,35 @@ AudioDevice::~AudioDevice()
|
|||
////////////////////////////////////////////////////////////
|
||||
bool AudioDevice::isExtensionSupported(const std::string& extension)
|
||||
{
|
||||
// Create a temporary audio device in case none exists yet.
|
||||
// This device will not be used in this function and merely
|
||||
// makes sure there is a valid OpenAL device for extension
|
||||
// queries if none has been created yet.
|
||||
std::auto_ptr<AudioDevice> device;
|
||||
if (!audioDevice)
|
||||
device.reset(new AudioDevice);
|
||||
auto checkExtension = [&extension]
|
||||
{
|
||||
|
||||
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
|
||||
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
|
||||
else
|
||||
return alIsExtensionPresent(extension.c_str()) != AL_FALSE;
|
||||
};
|
||||
|
||||
if (!audioDevice)
|
||||
{
|
||||
// Create a temporary audio device in case none exists yet.
|
||||
// This device will not be used in this function and merely
|
||||
// makes sure there is a valid OpenAL device for extension
|
||||
// queries if none has been created yet.
|
||||
AudioDevice device;
|
||||
|
||||
return checkExtension();
|
||||
}
|
||||
|
||||
return checkExtension();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
||||
{
|
||||
// Create a temporary audio device in case none exists yet.
|
||||
// This device will not be used in this function and merely
|
||||
// makes sure there is a valid OpenAL device for format
|
||||
// queries if none has been created yet.
|
||||
std::auto_ptr<AudioDevice> device;
|
||||
if (!audioDevice)
|
||||
device.reset(new AudioDevice);
|
||||
|
||||
auto getFormat = [channelCount]
|
||||
{
|
||||
// Find the good format according to the number of channels
|
||||
int format = 0;
|
||||
switch (channelCount)
|
||||
|
@ -147,6 +149,20 @@ int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
|||
format = 0;
|
||||
|
||||
return format;
|
||||
};
|
||||
|
||||
if (!audioDevice)
|
||||
{
|
||||
// Create a temporary audio device in case none exists yet.
|
||||
// This device will not be used in this function and merely
|
||||
// makes sure there is a valid OpenAL device for format
|
||||
// queries if none has been created yet.
|
||||
AudioDevice device;
|
||||
|
||||
return getFormat();
|
||||
}
|
||||
|
||||
return getFormat();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue