mirror of
https://github.com/SFML/SFML.git
synced 2025-01-19 07:45:13 +08:00
Fix integer conversion warnings
This commit is contained in:
parent
5bed29dd19
commit
9052ccf218
@ -122,16 +122,16 @@ namespace
|
|||||||
switch (frame->header.bits_per_sample)
|
switch (frame->header.bits_per_sample)
|
||||||
{
|
{
|
||||||
case 8:
|
case 8:
|
||||||
sample = buffer[j][i] << 8;
|
sample = static_cast<sf::Int16>(buffer[j][i] << 8);
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
sample = buffer[j][i];
|
sample = static_cast<sf::Int16>(buffer[j][i]);
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
sample = buffer[j][i] >> 8;
|
sample = static_cast<sf::Int16>(buffer[j][i] >> 8);
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
sample = buffer[j][i] >> 16;
|
sample = static_cast<sf::Int16>(buffer[j][i] >> 16);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
@ -187,7 +187,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
|||||||
{
|
{
|
||||||
Uint32 sample = 0;
|
Uint32 sample = 0;
|
||||||
if (decode24bit(*m_stream, sample))
|
if (decode24bit(*m_stream, sample))
|
||||||
*samples++ = sample >> 8;
|
*samples++ = static_cast<Int16>(sample >> 8);
|
||||||
else
|
else
|
||||||
return count;
|
return count;
|
||||||
break;
|
break;
|
||||||
@ -197,7 +197,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
|||||||
{
|
{
|
||||||
Uint32 sample = 0;
|
Uint32 sample = 0;
|
||||||
if (decode(*m_stream, sample))
|
if (decode(*m_stream, sample))
|
||||||
*samples++ = sample >> 16;
|
*samples++ = static_cast<Int16>(sample >> 16);
|
||||||
else
|
else
|
||||||
return count;
|
return count;
|
||||||
break;
|
break;
|
||||||
|
@ -32,6 +32,14 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
unsigned char toLower(unsigned char character)
|
||||||
|
{
|
||||||
|
return static_cast<unsigned char>(std::tolower(character));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
namespace priv
|
namespace priv
|
||||||
@ -40,7 +48,7 @@ namespace priv
|
|||||||
bool SoundFileWriterFlac::check(const std::string& filename)
|
bool SoundFileWriterFlac::check(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::string extension = filename.substr(filename.find_last_of('.') + 1);
|
std::string extension = filename.substr(filename.find_last_of('.') + 1);
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
std::transform(extension.begin(), extension.end(), extension.begin(), toLower);
|
||||||
|
|
||||||
return extension == "flac";
|
return extension == "flac";
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,14 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
unsigned char toLower(unsigned char character)
|
||||||
|
{
|
||||||
|
return static_cast<unsigned char>(std::tolower(character));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
namespace priv
|
namespace priv
|
||||||
@ -41,7 +49,7 @@ namespace priv
|
|||||||
bool SoundFileWriterOgg::check(const std::string& filename)
|
bool SoundFileWriterOgg::check(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::string extension = filename.substr(filename.find_last_of('.') + 1);
|
std::string extension = filename.substr(filename.find_last_of('.') + 1);
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
std::transform(extension.begin(), extension.end(), extension.begin(), toLower);
|
||||||
|
|
||||||
return extension == "ogg";
|
return extension == "ogg";
|
||||||
}
|
}
|
||||||
@ -149,7 +157,7 @@ void SoundFileWriterOgg::write(const Int16* samples, Uint64 count)
|
|||||||
|
|
||||||
// Tell the library how many samples we've written
|
// Tell the library how many samples we've written
|
||||||
vorbis_analysis_wrote(&m_state, std::min(frameCount, bufferSize));
|
vorbis_analysis_wrote(&m_state, std::min(frameCount, bufferSize));
|
||||||
|
|
||||||
frameCount -= bufferSize;
|
frameCount -= bufferSize;
|
||||||
|
|
||||||
// Flush any produced block
|
// Flush any produced block
|
||||||
|
@ -68,6 +68,11 @@ namespace
|
|||||||
};
|
};
|
||||||
stream.write(reinterpret_cast<const char*>(bytes), sizeof(bytes));
|
stream.write(reinterpret_cast<const char*>(bytes), sizeof(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char toLower(unsigned char character)
|
||||||
|
{
|
||||||
|
return static_cast<unsigned char>(std::tolower(character));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -78,7 +83,7 @@ namespace priv
|
|||||||
bool SoundFileWriterWav::check(const std::string& filename)
|
bool SoundFileWriterWav::check(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::string extension = filename.substr(filename.find_last_of('.') + 1);
|
std::string extension = filename.substr(filename.find_last_of('.') + 1);
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
std::transform(extension.begin(), extension.end(), extension.begin(), toLower);
|
||||||
|
|
||||||
return extension == "wav";
|
return extension == "wav";
|
||||||
}
|
}
|
||||||
@ -160,7 +165,7 @@ bool SoundFileWriterWav::writeHeader(unsigned int sampleRate, unsigned int chann
|
|||||||
encode(m_file, static_cast<Uint32>(sampleRate));
|
encode(m_file, static_cast<Uint32>(sampleRate));
|
||||||
Uint32 byteRate = sampleRate * channelCount * 2;
|
Uint32 byteRate = sampleRate * channelCount * 2;
|
||||||
encode(m_file, byteRate);
|
encode(m_file, byteRate);
|
||||||
Uint16 blockAlign = channelCount * 2;
|
Uint16 blockAlign = static_cast<Uint16>(channelCount * 2);
|
||||||
encode(m_file, blockAlign);
|
encode(m_file, blockAlign);
|
||||||
Uint16 bitsPerSample = 16;
|
Uint16 bitsPerSample = 16;
|
||||||
encode(m_file, bitsPerSample);
|
encode(m_file, bitsPerSample);
|
||||||
|
Loading…
Reference in New Issue
Block a user