More VS fixes
Former-commit-id: 7b613049d581c62ccefd3b63938e51571a04fa8f
This commit is contained in:
parent
504eb96b93
commit
b1081c63e5
|
|
@ -18,8 +18,8 @@ class NAZARA_API NzSoundStream
|
||||||
|
|
||||||
virtual nzUInt32 GetDuration() const = 0;
|
virtual nzUInt32 GetDuration() const = 0;
|
||||||
virtual nzAudioFormat GetFormat() const = 0;
|
virtual nzAudioFormat GetFormat() const = 0;
|
||||||
virtual unsigned int GetSampleCount() const = 0;
|
virtual nzUInt64 GetSampleCount() const = 0;
|
||||||
virtual unsigned int GetSampleRate() const = 0;
|
virtual nzUInt32 GetSampleRate() const = 0;
|
||||||
|
|
||||||
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
||||||
virtual void Seek(nzUInt32 offset) = 0;
|
virtual void Seek(nzUInt32 offset) = 0;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <Nazara/Audio/Enums.hpp>
|
#include <Nazara/Audio/Enums.hpp>
|
||||||
#include <Nazara/Audio/OpenAL.hpp>
|
#include <Nazara/Audio/OpenAL.hpp>
|
||||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||||
#include <Nazara/Audio/Loaders/sndfileLoader.hpp>
|
#include <Nazara/Audio/Formats/sndfileLoader.hpp>
|
||||||
#include <Nazara/Core/CallOnExit.hpp>
|
#include <Nazara/Core/CallOnExit.hpp>
|
||||||
#include <Nazara/Core/Core.hpp>
|
#include <Nazara/Core/Core.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
|
|
||||||
|
|
@ -81,12 +81,12 @@ namespace
|
||||||
sf_close(m_handle);
|
sf_close(m_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
nzUInt32 GetDuration() const
|
nzUInt32 GetDuration() const override
|
||||||
{
|
{
|
||||||
return m_duration;
|
return m_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
nzAudioFormat GetFormat() const
|
nzAudioFormat GetFormat() const override
|
||||||
{
|
{
|
||||||
// Nous avons besoin du nombre de canaux d'origine pour convertir en mono, nous trichons donc un peu...
|
// Nous avons besoin du nombre de canaux d'origine pour convertir en mono, nous trichons donc un peu...
|
||||||
if (m_mixToMono)
|
if (m_mixToMono)
|
||||||
|
|
@ -95,12 +95,12 @@ namespace
|
||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetSampleCount() const
|
nzUInt64 GetSampleCount() const override
|
||||||
{
|
{
|
||||||
return m_sampleCount;
|
return m_sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetSampleRate() const
|
nzUInt32 GetSampleRate() const override
|
||||||
{
|
{
|
||||||
return m_sampleRate;
|
return m_sampleRate;
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ namespace
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Un peu de RAII
|
// Un peu de RRID
|
||||||
NzCallOnExit onExit([this]
|
NzCallOnExit onExit([this]
|
||||||
{
|
{
|
||||||
sf_close(m_handle);
|
sf_close(m_handle);
|
||||||
|
|
@ -156,7 +156,7 @@ namespace
|
||||||
m_sampleRate = infos.samplerate;
|
m_sampleRate = infos.samplerate;
|
||||||
|
|
||||||
// Durée de la musique (s) = samples / channels*rate
|
// Durée de la musique (s) = samples / channels*rate
|
||||||
m_duration = 1000*m_sampleCount / (m_format*m_sampleRate);
|
m_duration = static_cast<nzUInt32>(1000*m_sampleCount / (m_format*m_sampleRate));
|
||||||
|
|
||||||
// https://github.com/LaurentGomila/SFML/issues/271
|
// https://github.com/LaurentGomila/SFML/issues/271
|
||||||
// http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_SCALE_FLOAT_INT_READ
|
// http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_SCALE_FLOAT_INT_READ
|
||||||
|
|
@ -184,17 +184,17 @@ namespace
|
||||||
if (m_mixToMono)
|
if (m_mixToMono)
|
||||||
{
|
{
|
||||||
// On garde un buffer sur le côté pour éviter la réallocation
|
// On garde un buffer sur le côté pour éviter la réallocation
|
||||||
m_mixBuffer.resize(m_format*sampleCount);
|
m_mixBuffer.resize(m_format * sampleCount);
|
||||||
unsigned int readSampleCount = sf_read_short(m_handle, m_mixBuffer.data(), m_format*sampleCount);
|
sf_count_t readSampleCount = sf_read_short(m_handle, m_mixBuffer.data(), m_format * sampleCount);
|
||||||
NzMixToMono(m_mixBuffer.data(), static_cast<nzInt16*>(buffer), m_format, sampleCount);
|
NzMixToMono(m_mixBuffer.data(), static_cast<nzInt16*>(buffer), m_format, sampleCount);
|
||||||
|
|
||||||
return readSampleCount / m_format;
|
return static_cast<unsigned int>(readSampleCount / m_format);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return sf_read_short(m_handle, static_cast<nzInt16*>(buffer), sampleCount);
|
return static_cast<unsigned int>(sf_read_short(m_handle, static_cast<nzInt16*>(buffer), sampleCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seek(nzUInt32 offset)
|
void Seek(nzUInt32 offset) override
|
||||||
{
|
{
|
||||||
sf_seek(m_handle, offset*m_sampleRate / 1000, SEEK_SET);
|
sf_seek(m_handle, offset*m_sampleRate / 1000, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
@ -205,9 +205,9 @@ namespace
|
||||||
nzAudioFormat m_format;
|
nzAudioFormat m_format;
|
||||||
SNDFILE* m_handle;
|
SNDFILE* m_handle;
|
||||||
bool m_mixToMono;
|
bool m_mixToMono;
|
||||||
unsigned int m_duration;
|
nzUInt32 m_duration;
|
||||||
unsigned int m_sampleCount;
|
nzUInt64 m_sampleCount;
|
||||||
unsigned int m_sampleRate;
|
nzUInt32 m_sampleRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IsSupported(const NzString& extension)
|
bool IsSupported(const NzString& extension)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue