Audio: Uniformize SampleCount/SampleRate type

Former-commit-id: a67b0f10a4aeb1399834221d32859ab0e376813e
This commit is contained in:
Lynix
2015-09-24 00:39:48 +02:00
parent 2fd3872099
commit ce3bbf6c78
6 changed files with 39 additions and 13 deletions

View File

@@ -95,7 +95,7 @@ namespace
return m_format;
}
nzUInt64 GetSampleCount() const override
nzUInt32 GetSampleCount() const override
{
return m_sampleCount;
}
@@ -152,11 +152,11 @@ namespace
return false;
}
m_sampleCount = infos.channels*infos.frames;
m_sampleCount = static_cast<nzUInt32>(infos.channels*infos.frames);
m_sampleRate = infos.samplerate;
// Durée de la musique (s) = samples / channels*rate
m_duration = static_cast<nzUInt32>(1000*m_sampleCount / (m_format*m_sampleRate));
m_duration = static_cast<nzUInt32>(1000ULL*m_sampleCount / (m_format*m_sampleRate));
// https://github.com/LaurentGomila/SFML/issues/271
// http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_SCALE_FLOAT_INT_READ
@@ -168,7 +168,7 @@ namespace
if (forceMono && m_format != nzAudioFormat_Mono)
{
m_mixToMono = true;
m_sampleCount = infos.frames;
m_sampleCount = static_cast<nzUInt32>(infos.frames);
}
else
m_mixToMono = false;
@@ -206,8 +206,8 @@ namespace
SNDFILE* m_handle;
bool m_mixToMono;
nzUInt32 m_duration;
nzUInt64 m_sampleCount;
nzUInt32 m_sampleRate;
unsigned int m_sampleCount;
unsigned int m_sampleRate;
};
bool IsSupported(const NzString& extension)

View File

@@ -119,6 +119,32 @@ nzUInt32 NzMusic::GetPlayingOffset() const
return 0;
}
nzUInt32 NzMusic::GetSampleCount() const
{
#if NAZARA_AUDIO_SAFE
if (!m_impl)
{
NazaraError("Music not created");
return 0;
}
#endif
return m_impl->stream->GetSampleCount();
}
nzUInt32 NzMusic::GetSampleRate() const
{
#if NAZARA_AUDIO_SAFE
if (!m_impl)
{
NazaraError("Music not created");
return 0;
}
#endif
return m_impl->stream->GetSampleRate();
}
nzSoundStatus NzMusic::GetStatus() const
{
#if NAZARA_AUDIO_SAFE

View File

@@ -25,8 +25,8 @@ struct NzSoundBufferImpl
nzAudioFormat format;
nzUInt32 duration;
std::unique_ptr<nzInt16[]> samples;
unsigned int sampleCount;
unsigned int sampleRate;
nzUInt32 sampleCount;
nzUInt32 sampleRate;
};
NzSoundBuffer::NzSoundBuffer(nzAudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const nzInt16* samples)