Audio: Fix some type warning
Former-commit-id: 37c2bdbdfc591ff3cc031ee1498ae1050183b4bd [formerly e96bf359c986942fc707834c9c5992eca9c57b22] [formerly a1c53ad3ae4218aea8163f5f33245e352b820a34 [formerly a3c51b11bd591e8accad191bfa5547323436e4cb]] Former-commit-id: 5d7faba8324c26970f0ca0681d695e6650cff32f [formerly c564a0adc734737472ea066e5d362637f9697138] Former-commit-id: 7979614ff5460597b01e042e7e520ad7d55c7493
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <Nazara/Audio/Audio.hpp>
|
||||
#include <Nazara/Audio/Config.hpp>
|
||||
#include <Nazara/Audio/OpenAL.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
@@ -40,7 +41,7 @@ namespace Nz
|
||||
AudioFormat format;
|
||||
UInt32 duration;
|
||||
std::unique_ptr<Int16[]> samples;
|
||||
UInt32 sampleCount;
|
||||
UInt64 sampleCount;
|
||||
UInt32 sampleRate;
|
||||
};
|
||||
|
||||
@@ -57,8 +58,7 @@ namespace Nz
|
||||
*
|
||||
* \see Create
|
||||
*/
|
||||
|
||||
SoundBuffer::SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples)
|
||||
SoundBuffer::SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples)
|
||||
{
|
||||
Create(format, sampleCount, sampleRate, samples);
|
||||
|
||||
@@ -76,7 +76,6 @@ namespace Nz
|
||||
*
|
||||
* \see Destroy
|
||||
*/
|
||||
|
||||
SoundBuffer::~SoundBuffer()
|
||||
{
|
||||
OnSoundBufferRelease(this);
|
||||
@@ -96,8 +95,7 @@ namespace Nz
|
||||
* \remark Produces a NazaraError if creation went wrong with NAZARA_AUDIO_SAFE defined,
|
||||
* this could happen if parameters are invalid or creation of OpenAL buffers failed
|
||||
*/
|
||||
|
||||
bool SoundBuffer::Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples)
|
||||
bool SoundBuffer::Create(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
@@ -132,19 +130,18 @@ namespace Nz
|
||||
|
||||
ALuint buffer;
|
||||
alGenBuffers(1, &buffer);
|
||||
|
||||
if (alGetError() != AL_NO_ERROR)
|
||||
{
|
||||
NazaraError("Failed to create OpenAL buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
alBufferData(buffer, OpenAL::AudioFormat[format], samples, sampleCount*sizeof(Int16), sampleRate);
|
||||
CallOnExit clearBufferOnExit([buffer] () { alDeleteBuffers(1, &buffer); });
|
||||
|
||||
alBufferData(buffer, OpenAL::AudioFormat[format], samples, static_cast<ALsizei>(sampleCount*sizeof(Int16)), static_cast<ALsizei>(sampleRate));
|
||||
|
||||
if (alGetError() != AL_NO_ERROR)
|
||||
{
|
||||
alDeleteBuffers(1, &buffer);
|
||||
|
||||
NazaraError("Failed to set OpenAL buffer");
|
||||
return false;
|
||||
}
|
||||
@@ -158,6 +155,8 @@ namespace Nz
|
||||
m_impl->samples.reset(new Int16[sampleCount]);
|
||||
std::memcpy(&m_impl->samples[0], samples, sampleCount*sizeof(Int16));
|
||||
|
||||
clearBufferOnExit.Reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -182,16 +181,9 @@ namespace Nz
|
||||
*
|
||||
* \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined
|
||||
*/
|
||||
|
||||
UInt32 SoundBuffer::GetDuration() const
|
||||
{
|
||||
#if NAZARA_AUDIO_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Sound buffer not created");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(m_impl, "Sound buffer not created");
|
||||
|
||||
return m_impl->duration;
|
||||
}
|
||||
@@ -205,13 +197,7 @@ namespace Nz
|
||||
|
||||
AudioFormat SoundBuffer::GetFormat() const
|
||||
{
|
||||
#if NAZARA_AUDIO_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Sound buffer not created");
|
||||
return AudioFormat_Unknown;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(m_impl, "Sound buffer not created");
|
||||
|
||||
return m_impl->format;
|
||||
}
|
||||
@@ -222,16 +208,9 @@ namespace Nz
|
||||
*
|
||||
* \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined
|
||||
*/
|
||||
|
||||
const Int16* SoundBuffer::GetSamples() const
|
||||
{
|
||||
#if NAZARA_AUDIO_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Sound buffer not created");
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(m_impl, "Sound buffer not created");
|
||||
|
||||
return m_impl->samples.get();
|
||||
}
|
||||
@@ -242,16 +221,9 @@ namespace Nz
|
||||
*
|
||||
* \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined
|
||||
*/
|
||||
|
||||
unsigned int SoundBuffer::GetSampleCount() const
|
||||
UInt64 SoundBuffer::GetSampleCount() const
|
||||
{
|
||||
#if NAZARA_AUDIO_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Sound buffer not created");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(m_impl, "Sound buffer not created");
|
||||
|
||||
return m_impl->sampleCount;
|
||||
}
|
||||
@@ -262,16 +234,9 @@ namespace Nz
|
||||
*
|
||||
* \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined
|
||||
*/
|
||||
|
||||
unsigned int SoundBuffer::GetSampleRate() const
|
||||
UInt32 SoundBuffer::GetSampleRate() const
|
||||
{
|
||||
#if NAZARA_AUDIO_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Sound buffer not created");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(m_impl, "Sound buffer not created");
|
||||
|
||||
return m_impl->sampleRate;
|
||||
}
|
||||
@@ -293,7 +258,6 @@ namespace Nz
|
||||
* \param filePath Path to the file
|
||||
* \param params Parameters for the sound buffer
|
||||
*/
|
||||
|
||||
bool SoundBuffer::LoadFromFile(const String& filePath, const SoundBufferParams& params)
|
||||
{
|
||||
return SoundBufferLoader::LoadFromFile(this, filePath, params);
|
||||
@@ -307,7 +271,6 @@ namespace Nz
|
||||
* \param size Size of the memory
|
||||
* \param params Parameters for the sound buffer
|
||||
*/
|
||||
|
||||
bool SoundBuffer::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params)
|
||||
{
|
||||
return SoundBufferLoader::LoadFromMemory(this, data, size, params);
|
||||
@@ -320,7 +283,6 @@ namespace Nz
|
||||
* \param stream Stream to the sound buffer
|
||||
* \param params Parameters for the sound buffer
|
||||
*/
|
||||
|
||||
bool SoundBuffer::LoadFromStream(Stream& stream, const SoundBufferParams& params)
|
||||
{
|
||||
return SoundBufferLoader::LoadFromStream(this, stream, params);
|
||||
@@ -332,7 +294,6 @@ namespace Nz
|
||||
*
|
||||
* \param format Format to check
|
||||
*/
|
||||
|
||||
bool SoundBuffer::IsFormatSupported(AudioFormat format)
|
||||
{
|
||||
return Audio::IsFormatSupported(format);
|
||||
@@ -344,7 +305,6 @@ namespace Nz
|
||||
*
|
||||
* \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined
|
||||
*/
|
||||
|
||||
unsigned int SoundBuffer::GetOpenALBuffer() const
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -364,7 +324,6 @@ namespace Nz
|
||||
*
|
||||
* \remark Produces a NazaraError if sub-initialization failed
|
||||
*/
|
||||
|
||||
bool SoundBuffer::Initialize()
|
||||
{
|
||||
if (!SoundBufferLibrary::Initialize())
|
||||
@@ -385,7 +344,6 @@ namespace Nz
|
||||
/*!
|
||||
* \brief Uninitializes the libraries and managers
|
||||
*/
|
||||
|
||||
void SoundBuffer::Uninitialize()
|
||||
{
|
||||
SoundBufferManager::Uninitialize();
|
||||
|
||||
Reference in New Issue
Block a user