mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Replace sf::Int16
with std::int16_t
This commit is contained in:
parent
50cec7d2ed
commit
e21ae3204e
@ -64,12 +64,12 @@ private:
|
||||
/// \see SoundRecorder::onProcessSamples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool onProcessSamples(const sf::Int16* samples, std::size_t sampleCount) override
|
||||
bool onProcessSamples(const std::int16_t* samples, std::size_t sampleCount) override
|
||||
{
|
||||
// Pack the audio samples into a network packet
|
||||
sf::Packet packet;
|
||||
packet << clientAudioData;
|
||||
packet.append(samples, sampleCount * sizeof(sf::Int16));
|
||||
packet.append(samples, sampleCount * sizeof(std::int16_t));
|
||||
|
||||
// Send the audio packet to the server
|
||||
return m_socket.send(packet) == sf::Socket::Done;
|
||||
|
@ -125,7 +125,7 @@ private:
|
||||
if (id == serverAudioData)
|
||||
{
|
||||
// Extract audio samples from the packet, and append it to our samples buffer
|
||||
std::size_t sampleCount = (packet.getDataSize() - 1) / sizeof(sf::Int16);
|
||||
std::size_t sampleCount = (packet.getDataSize() - 1) / sizeof(std::int16_t);
|
||||
|
||||
// Don't forget that the other thread can access the sample array at any time
|
||||
// (so we protect any operation on it with the mutex)
|
||||
@ -135,7 +135,7 @@ private:
|
||||
m_samples.resize(oldSize + sampleCount);
|
||||
std::memcpy(&(m_samples[oldSize]),
|
||||
static_cast<const char*>(packet.getData()) + 1,
|
||||
sampleCount * sizeof(sf::Int16));
|
||||
sampleCount * sizeof(std::int16_t));
|
||||
}
|
||||
}
|
||||
else if (id == serverEndOfStream)
|
||||
@ -159,8 +159,8 @@ private:
|
||||
sf::TcpListener m_listener;
|
||||
sf::TcpSocket m_client;
|
||||
std::recursive_mutex m_mutex;
|
||||
std::vector<sf::Int16> m_samples;
|
||||
std::vector<sf::Int16> m_tempBuffer;
|
||||
std::vector<std::int16_t> m_samples;
|
||||
std::vector<std::int16_t> m_tempBuffer;
|
||||
std::size_t m_offset;
|
||||
bool m_hasFinished;
|
||||
};
|
||||
|
@ -211,7 +211,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount);
|
||||
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the current file
|
||||
@ -279,7 +279,7 @@ private:
|
||||
/// << "sample count: " << file.getSampleCount() << std::endl;
|
||||
///
|
||||
/// // Read and process batches of samples until the end of file is reached
|
||||
/// sf::Int16 samples[1024];
|
||||
/// std::int16_t samples[1024];
|
||||
/// sf::Uint64 count;
|
||||
/// do
|
||||
/// {
|
||||
|
@ -272,7 +272,7 @@ private:
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
InputSoundFile m_file; //!< The streamed music file
|
||||
std::vector<Int16> m_samples; //!< Temporary buffer of samples
|
||||
std::vector<std::int16_t> m_samples; //!< Temporary buffer of samples
|
||||
std::recursive_mutex m_mutex; //!< Mutex protecting the data
|
||||
Span<Uint64> m_loopSpan; //!< Loop Range Specifier
|
||||
};
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
/// \param count Number of samples to write
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void write(const Int16* samples, Uint64 count);
|
||||
void write(const std::int16_t* samples, Uint64 count);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the current file
|
||||
@ -133,7 +133,7 @@ private:
|
||||
/// while (...)
|
||||
/// {
|
||||
/// // Read or generate audio samples from your custom source
|
||||
/// std::vector<sf::Int16> samples = ...;
|
||||
/// std::vector<std::int16_t> samples = ...;
|
||||
///
|
||||
/// // Write them to the file
|
||||
/// file.write(samples.data(), samples.size());
|
||||
|
@ -121,8 +121,7 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the sound buffer from an array of audio samples
|
||||
///
|
||||
/// The assumed format of the audio samples is 16 bits signed integer
|
||||
/// (sf::Int16).
|
||||
/// The assumed format of the audio samples is 16 bits signed integer.
|
||||
///
|
||||
/// \param samples Pointer to the array of samples in memory
|
||||
/// \param sampleCount Number of samples in the array
|
||||
@ -134,7 +133,10 @@ public:
|
||||
/// \see loadFromFile, loadFromMemory, saveToFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] bool loadFromSamples(const Int16* samples, Uint64 sampleCount, unsigned int channelCount, unsigned int sampleRate);
|
||||
[[nodiscard]] bool loadFromSamples(const std::int16_t* samples,
|
||||
Uint64 sampleCount,
|
||||
unsigned int channelCount,
|
||||
unsigned int sampleRate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Save the sound buffer to an audio file
|
||||
@ -154,16 +156,16 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the array of audio samples stored in the buffer
|
||||
///
|
||||
/// The format of the returned samples is 16 bits signed integer
|
||||
/// (sf::Int16). The total number of samples in this array
|
||||
/// is given by the getSampleCount() function.
|
||||
/// The format of the returned samples is 16 bits signed integer.
|
||||
/// The total number of samples in this array is given by the
|
||||
/// getSampleCount() function.
|
||||
///
|
||||
/// \return Read-only pointer to the array of sound samples
|
||||
///
|
||||
/// \see getSampleCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Int16* getSamples() const;
|
||||
const std::int16_t* getSamples() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of samples stored in the buffer
|
||||
@ -274,7 +276,7 @@ private:
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int m_buffer; //!< OpenAL buffer identifier
|
||||
std::vector<Int16> m_samples; //!< Samples buffer
|
||||
std::vector<std::int16_t> m_samples; //!< Samples buffer
|
||||
Time m_duration; //!< Sound duration
|
||||
mutable SoundList m_sounds; //!< List of sounds that are using this buffer
|
||||
};
|
||||
|
@ -83,7 +83,7 @@ protected:
|
||||
/// \return True to continue the capture, or false to stop it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] bool onProcessSamples(const Int16* samples, std::size_t sampleCount) override;
|
||||
[[nodiscard]] bool onProcessSamples(const std::int16_t* samples, std::size_t sampleCount) override;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop capturing audio data
|
||||
@ -95,7 +95,7 @@ private:
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::vector<Int16> m_samples; //!< Temporary sample buffer to hold the recorded data
|
||||
std::vector<std::int16_t> m_samples; //!< Temporary sample buffer to hold the recorded data
|
||||
SoundBuffer m_buffer; //!< Sound buffer that will contain the recorded data
|
||||
};
|
||||
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] virtual Uint64 read(Int16* samples, Uint64 maxCount) = 0;
|
||||
[[nodiscard]] virtual Uint64 read(std::int16_t* samples, Uint64 maxCount) = 0;
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
@ -149,7 +149,7 @@ public:
|
||||
/// sound
|
||||
/// }
|
||||
///
|
||||
/// sf::Uint64 read(sf::Int16* samples, sf::Uint64 maxCount) override
|
||||
/// sf::Uint64 read(std::int16_t* samples, sf::Uint64 maxCount) override
|
||||
/// {
|
||||
/// // read up to 'maxCount' samples into the 'samples' array,
|
||||
/// // convert them (for example from normalized float) if they are not stored
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
/// \param count Number of samples to write
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void write(const Int16* samples, Uint64 count) = 0;
|
||||
virtual void write(const std::int16_t* samples, Uint64 count) = 0;
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
@ -115,7 +115,7 @@ public:
|
||||
/// // return true on success
|
||||
/// }
|
||||
///
|
||||
/// void write(const sf::Int16* samples, sf::Uint64 count) override
|
||||
/// void write(const std::int16_t* samples, sf::Uint64 count) override
|
||||
/// {
|
||||
/// // write 'count' samples stored at address 'samples',
|
||||
/// // convert them (for example to normalized float) if the format requires it
|
||||
|
@ -240,7 +240,7 @@ protected:
|
||||
/// \return True to continue the capture, or false to stop it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount) = 0;
|
||||
[[nodiscard]] virtual bool onProcessSamples(const std::int16_t* samples, std::size_t sampleCount) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop capturing audio data
|
||||
@ -303,7 +303,7 @@ private:
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::thread m_thread; //!< Thread running the background recording task
|
||||
std::vector<Int16> m_samples; //!< Buffer to store captured samples
|
||||
std::vector<std::int16_t> m_samples; //!< Buffer to store captured samples
|
||||
unsigned int m_sampleRate; //!< Sample rate
|
||||
Time m_processingInterval; //!< Time period between calls to onProcessSamples
|
||||
bool m_isCapturing; //!< Capturing state
|
||||
@ -391,7 +391,7 @@ private:
|
||||
/// return true;
|
||||
/// }
|
||||
///
|
||||
/// [[nodiscard]] bool onProcessSamples(const Int16* samples, std::size_t sampleCount) override
|
||||
/// [[nodiscard]] bool onProcessSamples(const std::int16_t* samples, std::size_t sampleCount) override
|
||||
/// {
|
||||
/// // Do something with the new chunk of samples (store them, send them, ...)
|
||||
/// ...
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
struct Chunk
|
||||
{
|
||||
const Int16* samples; //!< Pointer to the audio samples
|
||||
const std::int16_t* samples; //!< Pointer to the audio samples
|
||||
std::size_t sampleCount; //!< Number of samples pointed by Samples
|
||||
};
|
||||
|
||||
|
@ -168,7 +168,6 @@
|
||||
namespace sf
|
||||
{
|
||||
// 16 bits integer types
|
||||
using Int16 = std::int16_t;
|
||||
using Uint16 = std::uint16_t;
|
||||
|
||||
// 32 bits integer types
|
||||
|
@ -223,7 +223,7 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \overload
|
||||
////////////////////////////////////////////////////////////
|
||||
Packet& operator>>(Int16& data);
|
||||
Packet& operator>>(std::int16_t& data);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \overload
|
||||
@ -304,7 +304,7 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \overload
|
||||
////////////////////////////////////////////////////////////
|
||||
Packet& operator<<(Int16 data);
|
||||
Packet& operator<<(std::int16_t data);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \overload
|
||||
|
@ -261,7 +261,7 @@ void InputSoundFile::seek(Time timeOffset)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 InputSoundFile::read(Int16* samples, Uint64 maxCount)
|
||||
Uint64 InputSoundFile::read(std::int16_t* samples, Uint64 maxCount)
|
||||
{
|
||||
Uint64 readSamples = 0;
|
||||
if (m_reader && samples && maxCount)
|
||||
|
@ -69,7 +69,7 @@ bool OutputSoundFile::openFromFile(const std::filesystem::path& filename, unsign
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void OutputSoundFile::write(const Int16* samples, Uint64 count)
|
||||
void OutputSoundFile::write(const std::int16_t* samples, Uint64 count)
|
||||
{
|
||||
if (m_writer && samples && count)
|
||||
m_writer->write(samples, count);
|
||||
|
@ -120,7 +120,7 @@ bool SoundBuffer::loadFromStream(InputStream& stream)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::loadFromSamples(const Int16* samples, Uint64 sampleCount, unsigned int channelCount, unsigned int sampleRate)
|
||||
bool SoundBuffer::loadFromSamples(const std::int16_t* samples, Uint64 sampleCount, unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
if (samples && sampleCount && channelCount && sampleRate)
|
||||
{
|
||||
@ -164,7 +164,7 @@ bool SoundBuffer::saveToFile(const std::filesystem::path& filename) const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const Int16* SoundBuffer::getSamples() const
|
||||
const std::int16_t* SoundBuffer::getSamples() const
|
||||
{
|
||||
return m_samples.empty() ? nullptr : m_samples.data();
|
||||
}
|
||||
@ -265,7 +265,7 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate)
|
||||
soundPtr->resetBuffer();
|
||||
|
||||
// Fill the buffer
|
||||
auto size = static_cast<ALsizei>(m_samples.size() * sizeof(Int16));
|
||||
auto size = static_cast<ALsizei>(m_samples.size() * sizeof(std::int16_t));
|
||||
alCheck(alBufferData(m_buffer, format, m_samples.data(), size, static_cast<ALsizei>(sampleRate)));
|
||||
|
||||
// Compute the duration
|
||||
|
@ -54,7 +54,7 @@ bool SoundBufferRecorder::onStart()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBufferRecorder::onProcessSamples(const Int16* samples, std::size_t sampleCount)
|
||||
bool SoundBufferRecorder::onProcessSamples(const std::int16_t* samples, std::size_t sampleCount)
|
||||
{
|
||||
std::copy(samples, samples + sampleCount, std::back_inserter(m_samples));
|
||||
|
||||
|
@ -123,20 +123,20 @@ FLAC__StreamDecoderWriteStatus streamWrite(const FLAC__StreamDecoder*,
|
||||
for (unsigned int j = 0; j < frame->header.channels; ++j)
|
||||
{
|
||||
// Decode the current sample
|
||||
sf::Int16 sample = 0;
|
||||
std::int16_t sample = 0;
|
||||
switch (frame->header.bits_per_sample)
|
||||
{
|
||||
case 8:
|
||||
sample = static_cast<sf::Int16>(buffer[j][i] << 8);
|
||||
sample = static_cast<std::int16_t>(buffer[j][i] << 8);
|
||||
break;
|
||||
case 16:
|
||||
sample = static_cast<sf::Int16>(buffer[j][i]);
|
||||
sample = static_cast<std::int16_t>(buffer[j][i]);
|
||||
break;
|
||||
case 24:
|
||||
sample = static_cast<sf::Int16>(buffer[j][i] >> 8);
|
||||
sample = static_cast<std::int16_t>(buffer[j][i] >> 8);
|
||||
break;
|
||||
case 32:
|
||||
sample = static_cast<sf::Int16>(buffer[j][i] >> 16);
|
||||
sample = static_cast<std::int16_t>(buffer[j][i] >> 16);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
@ -300,7 +300,7 @@ void SoundFileReaderFlac::seek(Uint64 sampleOffset)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 SoundFileReaderFlac::read(Int16* samples, Uint64 maxCount)
|
||||
Uint64 SoundFileReaderFlac::read(std::int16_t* samples, Uint64 maxCount)
|
||||
{
|
||||
assert(m_decoder);
|
||||
|
||||
@ -312,10 +312,10 @@ Uint64 SoundFileReaderFlac::read(Int16* samples, Uint64 maxCount)
|
||||
{
|
||||
// There are more leftovers than needed
|
||||
std::copy(m_clientData.leftovers.begin(),
|
||||
m_clientData.leftovers.begin() + static_cast<std::vector<Int16>::difference_type>(maxCount),
|
||||
m_clientData.leftovers.begin() + static_cast<std::vector<std::int16_t>::difference_type>(maxCount),
|
||||
samples);
|
||||
std::vector<Int16> leftovers(m_clientData.leftovers.begin() +
|
||||
static_cast<std::vector<Int16>::difference_type>(maxCount),
|
||||
std::vector<std::int16_t> leftovers(m_clientData.leftovers.begin() +
|
||||
static_cast<std::vector<std::int16_t>::difference_type>(maxCount),
|
||||
m_clientData.leftovers.end());
|
||||
m_clientData.leftovers.swap(leftovers);
|
||||
return maxCount;
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount) override;
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -112,9 +112,9 @@ public:
|
||||
{
|
||||
InputStream* stream;
|
||||
SoundFileReader::Info info;
|
||||
Int16* buffer;
|
||||
std::int16_t* buffer;
|
||||
Uint64 remaining;
|
||||
std::vector<Int16> leftovers;
|
||||
std::vector<std::int16_t> leftovers;
|
||||
bool error;
|
||||
};
|
||||
|
||||
|
@ -144,7 +144,7 @@ void SoundFileReaderMp3::seek(Uint64 sampleOffset)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 SoundFileReaderMp3::read(Int16* samples, Uint64 maxCount)
|
||||
Uint64 SoundFileReaderMp3::read(std::int16_t* samples, Uint64 maxCount)
|
||||
{
|
||||
Uint64 toRead = std::min(maxCount, m_numSamples - m_position);
|
||||
toRead = static_cast<Uint64>(mp3dec_ex_read(&m_decoder, samples, static_cast<std::size_t>(toRead)));
|
||||
|
@ -121,7 +121,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount) override;
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -135,7 +135,7 @@ void SoundFileReaderOgg::seek(Uint64 sampleOffset)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 SoundFileReaderOgg::read(Int16* samples, Uint64 maxCount)
|
||||
Uint64 SoundFileReaderOgg::read(std::int16_t* samples, Uint64 maxCount)
|
||||
{
|
||||
assert(m_vorbis.datasource);
|
||||
|
||||
@ -143,11 +143,11 @@ Uint64 SoundFileReaderOgg::read(Int16* samples, Uint64 maxCount)
|
||||
Uint64 count = 0;
|
||||
while (count < maxCount)
|
||||
{
|
||||
int bytesToRead = static_cast<int>(maxCount - count) * static_cast<int>(sizeof(Int16));
|
||||
int bytesToRead = static_cast<int>(maxCount - count) * static_cast<int>(sizeof(std::int16_t));
|
||||
long bytesRead = ov_read(&m_vorbis, reinterpret_cast<char*>(samples), bytesToRead, 0, 2, 1, nullptr);
|
||||
if (bytesRead > 0)
|
||||
{
|
||||
long samplesRead = bytesRead / static_cast<long>(sizeof(Int16));
|
||||
long samplesRead = bytesRead / static_cast<long>(sizeof(std::int16_t));
|
||||
count += static_cast<Uint64>(samplesRead);
|
||||
samples += samplesRead;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount) override;
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -46,13 +46,13 @@ bool decode(sf::InputStream& stream, std::uint8_t& value)
|
||||
return static_cast<std::size_t>(stream.read(&value, sizeof(value))) == sizeof(value);
|
||||
}
|
||||
|
||||
bool decode(sf::InputStream& stream, sf::Int16& value)
|
||||
bool decode(sf::InputStream& stream, std::int16_t& value)
|
||||
{
|
||||
unsigned char bytes[sizeof(value)];
|
||||
if (static_cast<std::size_t>(stream.read(bytes, static_cast<sf::Int64>(sizeof(bytes)))) != sizeof(bytes))
|
||||
return false;
|
||||
|
||||
value = static_cast<sf::Int16>(bytes[0] | (bytes[1] << 8));
|
||||
value = static_cast<std::int16_t>(bytes[0] | (bytes[1] << 8));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -149,7 +149,7 @@ void SoundFileReaderWav::seek(Uint64 sampleOffset)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
||||
Uint64 SoundFileReaderWav::read(std::int16_t* samples, Uint64 maxCount)
|
||||
{
|
||||
assert(m_stream);
|
||||
|
||||
@ -166,7 +166,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
||||
{
|
||||
std::uint8_t sample = 0;
|
||||
if (decode(*m_stream, sample))
|
||||
*samples++ = static_cast<Int16>((static_cast<Int16>(sample) - 128) << 8);
|
||||
*samples++ = static_cast<std::int16_t>((static_cast<std::int16_t>(sample) - 128) << 8);
|
||||
else
|
||||
return count;
|
||||
break;
|
||||
@ -174,7 +174,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
||||
|
||||
case 2:
|
||||
{
|
||||
Int16 sample = 0;
|
||||
std::int16_t sample = 0;
|
||||
if (decode(*m_stream, sample))
|
||||
*samples++ = sample;
|
||||
else
|
||||
@ -186,7 +186,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
||||
{
|
||||
Uint32 sample = 0;
|
||||
if (decode24bit(*m_stream, sample))
|
||||
*samples++ = static_cast<Int16>(sample >> 8);
|
||||
*samples++ = static_cast<std::int16_t>(sample >> 8);
|
||||
else
|
||||
return count;
|
||||
break;
|
||||
@ -196,7 +196,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
||||
{
|
||||
Uint32 sample = 0;
|
||||
if (decode(*m_stream, sample))
|
||||
*samples++ = static_cast<Int16>(sample >> 16);
|
||||
*samples++ = static_cast<std::int16_t>(sample >> 16);
|
||||
else
|
||||
return count;
|
||||
break;
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount) override;
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -93,7 +93,7 @@ bool SoundFileWriterFlac::open(const std::filesystem::path& filename, unsigned i
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundFileWriterFlac::write(const Int16* samples, Uint64 count)
|
||||
void SoundFileWriterFlac::write(const std::int16_t* samples, Uint64 count)
|
||||
{
|
||||
while (count > 0)
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
/// \param count Number of samples to write
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void write(const Int16* samples, Uint64 count) override;
|
||||
void write(const std::int16_t* samples, Uint64 count) override;
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -125,7 +125,7 @@ bool SoundFileWriterOgg::open(const std::filesystem::path& filename, unsigned in
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundFileWriterOgg::write(const Int16* samples, Uint64 count)
|
||||
void SoundFileWriterOgg::write(const std::int16_t* samples, Uint64 count)
|
||||
{
|
||||
// Vorbis has issues with buffers that are too large, so we ask for 64K
|
||||
constexpr int bufferSize = 65536;
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
/// \param count Number of samples to write
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void write(const Int16* samples, Uint64 count) override;
|
||||
void write(const std::int16_t* samples, Uint64 count) override;
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -38,7 +38,7 @@ namespace
|
||||
// The following functions takes integers in host byte order
|
||||
// and writes them to a stream as little endian
|
||||
|
||||
void encode(std::ostream& stream, sf::Int16 value)
|
||||
void encode(std::ostream& stream, std::int16_t value)
|
||||
{
|
||||
unsigned char bytes[] = {static_cast<unsigned char>(value & 0xFF), static_cast<unsigned char>(value >> 8)};
|
||||
stream.write(reinterpret_cast<const char*>(bytes), sizeof(bytes));
|
||||
@ -109,7 +109,7 @@ bool SoundFileWriterWav::open(const std::filesystem::path& filename, unsigned in
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundFileWriterWav::write(const Int16* samples, Uint64 count)
|
||||
void SoundFileWriterWav::write(const std::int16_t* samples, Uint64 count)
|
||||
{
|
||||
assert(m_file.good());
|
||||
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
/// \param count Number of samples to write
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void write(const Int16* samples, Uint64 count) override;
|
||||
void write(const std::int16_t* samples, Uint64 count) override;
|
||||
|
||||
private:
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -462,7 +462,7 @@ bool SoundStream::fillAndPushBuffer(unsigned int bufferNum, bool immediateLoop)
|
||||
unsigned int buffer = m_buffers[bufferNum];
|
||||
|
||||
// Fill the buffer
|
||||
auto size = static_cast<ALsizei>(data.sampleCount * sizeof(Int16));
|
||||
auto size = static_cast<ALsizei>(data.sampleCount * sizeof(std::int16_t));
|
||||
alCheck(alBufferData(buffer, m_format, data.samples, size, static_cast<ALsizei>(m_sampleRate)));
|
||||
|
||||
// Push it into the sound queue
|
||||
|
@ -155,12 +155,12 @@ Packet& Packet::operator>>(std::uint8_t& data)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Packet& Packet::operator>>(Int16& data)
|
||||
Packet& Packet::operator>>(std::int16_t& data)
|
||||
{
|
||||
if (checkSize(sizeof(data)))
|
||||
{
|
||||
std::memcpy(&data, &m_data[m_readPos], sizeof(data));
|
||||
data = static_cast<Int16>(ntohs(static_cast<uint16_t>(data)));
|
||||
data = static_cast<std::int16_t>(ntohs(static_cast<uint16_t>(data)));
|
||||
m_readPos += sizeof(data);
|
||||
}
|
||||
|
||||
@ -416,9 +416,9 @@ Packet& Packet::operator<<(std::uint8_t data)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Packet& Packet::operator<<(Int16 data)
|
||||
Packet& Packet::operator<<(std::int16_t data)
|
||||
{
|
||||
auto toWrite = static_cast<Int16>(htons(static_cast<uint16_t>(data)));
|
||||
auto toWrite = static_cast<std::int16_t>(htons(static_cast<uint16_t>(data)));
|
||||
append(&toWrite, sizeof(toWrite));
|
||||
return *this;
|
||||
}
|
||||
|
@ -779,11 +779,11 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Mouse position is in screen coordinates, convert it to window coordinates
|
||||
POINT position;
|
||||
position.x = static_cast<Int16>(LOWORD(lParam));
|
||||
position.y = static_cast<Int16>(HIWORD(lParam));
|
||||
position.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
position.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
ScreenToClient(m_handle, &position);
|
||||
|
||||
auto delta = static_cast<Int16>(HIWORD(wParam));
|
||||
auto delta = static_cast<std::int16_t>(HIWORD(wParam));
|
||||
|
||||
Event event;
|
||||
|
||||
@ -801,11 +801,11 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Mouse position is in screen coordinates, convert it to window coordinates
|
||||
POINT position;
|
||||
position.x = static_cast<Int16>(LOWORD(lParam));
|
||||
position.y = static_cast<Int16>(HIWORD(lParam));
|
||||
position.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
position.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
ScreenToClient(m_handle, &position);
|
||||
|
||||
auto delta = static_cast<Int16>(HIWORD(wParam));
|
||||
auto delta = static_cast<std::int16_t>(HIWORD(wParam));
|
||||
|
||||
Event event;
|
||||
event.type = Event::MouseWheelScrolled;
|
||||
@ -823,8 +823,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Left;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
@ -835,8 +835,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Left;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
@ -847,8 +847,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Right;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
@ -859,8 +859,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Right;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
@ -871,8 +871,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Middle;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
@ -883,8 +883,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Middle;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
@ -895,8 +895,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::XButton1 : Mouse::XButton2;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
@ -907,8 +907,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::XButton1 : Mouse::XButton2;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
event.mouseButton.x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
@ -933,8 +933,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
// Extract the mouse local coordinates
|
||||
int x = static_cast<Int16>(LOWORD(lParam));
|
||||
int y = static_cast<Int16>(HIWORD(lParam));
|
||||
int x = static_cast<std::int16_t>(LOWORD(lParam));
|
||||
int y = static_cast<std::int16_t>(HIWORD(lParam));
|
||||
|
||||
// Get the client area of the window
|
||||
RECT area;
|
||||
|
@ -26,12 +26,12 @@ TEST_CASE("sf::Packet class - [network]")
|
||||
testPacketStreamOperators(std::numeric_limits<std::int8_t>::max());
|
||||
}
|
||||
|
||||
SUBCASE("Int16")
|
||||
SUBCASE("std::int16_t")
|
||||
{
|
||||
testPacketStreamOperators(sf::Int16(0));
|
||||
testPacketStreamOperators(sf::Int16(1));
|
||||
testPacketStreamOperators(std::numeric_limits<sf::Int16>::min());
|
||||
testPacketStreamOperators(std::numeric_limits<sf::Int16>::max());
|
||||
testPacketStreamOperators(std::int16_t(0));
|
||||
testPacketStreamOperators(std::int16_t(1));
|
||||
testPacketStreamOperators(std::numeric_limits<std::int16_t>::min());
|
||||
testPacketStreamOperators(std::numeric_limits<std::int16_t>::max());
|
||||
}
|
||||
|
||||
SUBCASE("Int32")
|
||||
|
@ -14,7 +14,6 @@ TEST_CASE("SFML/Config.hpp")
|
||||
|
||||
SUBCASE("Fixed width types")
|
||||
{
|
||||
CHECK(sizeof(sf::Int16) == 2);
|
||||
CHECK(sizeof(sf::Uint16) == 2);
|
||||
|
||||
CHECK(sizeof(sf::Int32) == 4);
|
||||
|
Loading…
Reference in New Issue
Block a user