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/ALCheck.hpp>
|
||||||
#include <SFML/Audio/Listener.hpp>
|
#include <SFML/Audio/Listener.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -103,32 +102,35 @@ AudioDevice::~AudioDevice()
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool AudioDevice::isExtensionSupported(const std::string& extension)
|
bool AudioDevice::isExtensionSupported(const std::string& extension)
|
||||||
{
|
{
|
||||||
// Create a temporary audio device in case none exists yet.
|
auto checkExtension = [&extension]
|
||||||
// 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);
|
|
||||||
|
|
||||||
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
|
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
|
||||||
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
|
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
|
||||||
else
|
else
|
||||||
return alIsExtensionPresent(extension.c_str()) != AL_FALSE;
|
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)
|
int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
||||||
{
|
{
|
||||||
// Create a temporary audio device in case none exists yet.
|
auto getFormat = [channelCount]
|
||||||
// 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);
|
|
||||||
|
|
||||||
// Find the good format according to the number of channels
|
// Find the good format according to the number of channels
|
||||||
int format = 0;
|
int format = 0;
|
||||||
switch (channelCount)
|
switch (channelCount)
|
||||||
|
@ -147,6 +149,20 @@ int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
||||||
format = 0;
|
format = 0;
|
||||||
|
|
||||||
return format;
|
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