From e21ae3204e43c0dd1dc4f157a26280d35582d582 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sat, 3 Sep 2022 17:36:41 -0600 Subject: [PATCH] Replace `sf::Int16` with `std::int16_t` --- examples/voip/Client.cpp | 4 +- examples/voip/Server.cpp | 18 ++++---- include/SFML/Audio/InputSoundFile.hpp | 4 +- include/SFML/Audio/Music.hpp | 8 ++-- include/SFML/Audio/OutputSoundFile.hpp | 4 +- include/SFML/Audio/SoundBuffer.hpp | 24 ++++++----- include/SFML/Audio/SoundBufferRecorder.hpp | 6 +-- include/SFML/Audio/SoundFileReader.hpp | 4 +- include/SFML/Audio/SoundFileWriter.hpp | 4 +- include/SFML/Audio/SoundRecorder.hpp | 18 ++++---- include/SFML/Audio/SoundStream.hpp | 4 +- include/SFML/Config.hpp | 1 - include/SFML/Network/Packet.hpp | 4 +- src/SFML/Audio/InputSoundFile.cpp | 2 +- src/SFML/Audio/OutputSoundFile.cpp | 2 +- src/SFML/Audio/SoundBuffer.cpp | 6 +-- src/SFML/Audio/SoundBufferRecorder.cpp | 2 +- src/SFML/Audio/SoundFileReaderFlac.cpp | 20 ++++----- src/SFML/Audio/SoundFileReaderFlac.hpp | 14 +++---- src/SFML/Audio/SoundFileReaderMp3.cpp | 2 +- src/SFML/Audio/SoundFileReaderMp3.hpp | 2 +- src/SFML/Audio/SoundFileReaderOgg.cpp | 6 +-- src/SFML/Audio/SoundFileReaderOgg.hpp | 2 +- src/SFML/Audio/SoundFileReaderWav.cpp | 14 +++---- src/SFML/Audio/SoundFileReaderWav.hpp | 2 +- src/SFML/Audio/SoundFileWriterFlac.cpp | 2 +- src/SFML/Audio/SoundFileWriterFlac.hpp | 2 +- src/SFML/Audio/SoundFileWriterOgg.cpp | 2 +- src/SFML/Audio/SoundFileWriterOgg.hpp | 2 +- src/SFML/Audio/SoundFileWriterWav.cpp | 4 +- src/SFML/Audio/SoundFileWriterWav.hpp | 2 +- src/SFML/Audio/SoundStream.cpp | 2 +- src/SFML/Network/Packet.cpp | 8 ++-- src/SFML/Window/Win32/WindowImplWin32.cpp | 48 +++++++++++----------- test/Network/Packet.cpp | 10 ++--- test/System/Config.cpp | 1 - 36 files changed, 130 insertions(+), 130 deletions(-) diff --git a/examples/voip/Client.cpp b/examples/voip/Client.cpp index 5c89ddfe..24082710 100644 --- a/examples/voip/Client.cpp +++ b/examples/voip/Client.cpp @@ -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; diff --git a/examples/voip/Server.cpp b/examples/voip/Server.cpp index c3aa0cc4..214fe8d6 100644 --- a/examples/voip/Server.cpp +++ b/examples/voip/Server.cpp @@ -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(packet.getData()) + 1, - sampleCount * sizeof(sf::Int16)); + sampleCount * sizeof(std::int16_t)); } } else if (id == serverEndOfStream) @@ -156,13 +156,13 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - sf::TcpListener m_listener; - sf::TcpSocket m_client; - std::recursive_mutex m_mutex; - std::vector m_samples; - std::vector m_tempBuffer; - std::size_t m_offset; - bool m_hasFinished; + sf::TcpListener m_listener; + sf::TcpSocket m_client; + std::recursive_mutex m_mutex; + std::vector m_samples; + std::vector m_tempBuffer; + std::size_t m_offset; + bool m_hasFinished; }; diff --git a/include/SFML/Audio/InputSoundFile.hpp b/include/SFML/Audio/InputSoundFile.hpp index baabe08e..15e09577 100644 --- a/include/SFML/Audio/InputSoundFile.hpp +++ b/include/SFML/Audio/InputSoundFile.hpp @@ -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 /// { diff --git a/include/SFML/Audio/Music.hpp b/include/SFML/Audio/Music.hpp index b4bb5aee..20f0069f 100644 --- a/include/SFML/Audio/Music.hpp +++ b/include/SFML/Audio/Music.hpp @@ -271,10 +271,10 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - InputSoundFile m_file; //!< The streamed music file - std::vector m_samples; //!< Temporary buffer of samples - std::recursive_mutex m_mutex; //!< Mutex protecting the data - Span m_loopSpan; //!< Loop Range Specifier + InputSoundFile m_file; //!< The streamed music file + std::vector m_samples; //!< Temporary buffer of samples + std::recursive_mutex m_mutex; //!< Mutex protecting the data + Span m_loopSpan; //!< Loop Range Specifier }; } // namespace sf diff --git a/include/SFML/Audio/OutputSoundFile.hpp b/include/SFML/Audio/OutputSoundFile.hpp index ab25a522..f57b648e 100644 --- a/include/SFML/Audio/OutputSoundFile.hpp +++ b/include/SFML/Audio/OutputSoundFile.hpp @@ -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 samples = ...; +/// std::vector samples = ...; /// /// // Write them to the file /// file.write(samples.data(), samples.size()); diff --git a/include/SFML/Audio/SoundBuffer.hpp b/include/SFML/Audio/SoundBuffer.hpp index e5a05547..7ac10427 100644 --- a/include/SFML/Audio/SoundBuffer.hpp +++ b/include/SFML/Audio/SoundBuffer.hpp @@ -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 @@ -273,10 +275,10 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - unsigned int m_buffer; //!< OpenAL buffer identifier - std::vector m_samples; //!< Samples buffer - Time m_duration; //!< Sound duration - mutable SoundList m_sounds; //!< List of sounds that are using this buffer + unsigned int m_buffer; //!< OpenAL buffer identifier + std::vector m_samples; //!< Samples buffer + Time m_duration; //!< Sound duration + mutable SoundList m_sounds; //!< List of sounds that are using this buffer }; } // namespace sf diff --git a/include/SFML/Audio/SoundBufferRecorder.hpp b/include/SFML/Audio/SoundBufferRecorder.hpp index a20b99d6..f85d9e1e 100644 --- a/include/SFML/Audio/SoundBufferRecorder.hpp +++ b/include/SFML/Audio/SoundBufferRecorder.hpp @@ -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,8 +95,8 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - std::vector m_samples; //!< Temporary sample buffer to hold the recorded data - SoundBuffer m_buffer; //!< Sound buffer that will contain the recorded data + std::vector m_samples; //!< Temporary sample buffer to hold the recorded data + SoundBuffer m_buffer; //!< Sound buffer that will contain the recorded data }; } // namespace sf diff --git a/include/SFML/Audio/SoundFileReader.hpp b/include/SFML/Audio/SoundFileReader.hpp index 52be0195..dafd2a3d 100644 --- a/include/SFML/Audio/SoundFileReader.hpp +++ b/include/SFML/Audio/SoundFileReader.hpp @@ -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 diff --git a/include/SFML/Audio/SoundFileWriter.hpp b/include/SFML/Audio/SoundFileWriter.hpp index 75c0e120..c8b6c55e 100644 --- a/include/SFML/Audio/SoundFileWriter.hpp +++ b/include/SFML/Audio/SoundFileWriter.hpp @@ -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 diff --git a/include/SFML/Audio/SoundRecorder.hpp b/include/SFML/Audio/SoundRecorder.hpp index 2aef0c15..b799c59f 100644 --- a/include/SFML/Audio/SoundRecorder.hpp +++ b/include/SFML/Audio/SoundRecorder.hpp @@ -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 @@ -302,13 +302,13 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - std::thread m_thread; //!< Thread running the background recording task - std::vector 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 - std::string m_deviceName; //!< Name of the audio capture device - unsigned int m_channelCount; //!< Number of recording channels + std::thread m_thread; //!< Thread running the background recording task + std::vector 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 + std::string m_deviceName; //!< Name of the audio capture device + unsigned int m_channelCount; //!< Number of recording channels }; } // namespace sf @@ -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, ...) /// ... diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 1628d8ec..560e6e7f 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -53,8 +53,8 @@ public: //////////////////////////////////////////////////////////// struct Chunk { - const Int16* samples; //!< Pointer to the audio samples - std::size_t sampleCount; //!< Number of samples pointed by Samples + const std::int16_t* samples; //!< Pointer to the audio samples + std::size_t sampleCount; //!< Number of samples pointed by Samples }; //////////////////////////////////////////////////////////// diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index baa6f545..d404b4f4 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -168,7 +168,6 @@ namespace sf { // 16 bits integer types -using Int16 = std::int16_t; using Uint16 = std::uint16_t; // 32 bits integer types diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp index 613ed949..663a1292 100644 --- a/include/SFML/Network/Packet.hpp +++ b/include/SFML/Network/Packet.hpp @@ -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 diff --git a/src/SFML/Audio/InputSoundFile.cpp b/src/SFML/Audio/InputSoundFile.cpp index ce4b4fa8..1d023d2b 100644 --- a/src/SFML/Audio/InputSoundFile.cpp +++ b/src/SFML/Audio/InputSoundFile.cpp @@ -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) diff --git a/src/SFML/Audio/OutputSoundFile.cpp b/src/SFML/Audio/OutputSoundFile.cpp index 62b52289..c90a08b6 100644 --- a/src/SFML/Audio/OutputSoundFile.cpp +++ b/src/SFML/Audio/OutputSoundFile.cpp @@ -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); diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index d271c5a2..7c22fd0b 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -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(m_samples.size() * sizeof(Int16)); + auto size = static_cast(m_samples.size() * sizeof(std::int16_t)); alCheck(alBufferData(m_buffer, format, m_samples.data(), size, static_cast(sampleRate))); // Compute the duration diff --git a/src/SFML/Audio/SoundBufferRecorder.cpp b/src/SFML/Audio/SoundBufferRecorder.cpp index df038cef..3a656f0f 100644 --- a/src/SFML/Audio/SoundBufferRecorder.cpp +++ b/src/SFML/Audio/SoundBufferRecorder.cpp @@ -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)); diff --git a/src/SFML/Audio/SoundFileReaderFlac.cpp b/src/SFML/Audio/SoundFileReaderFlac.cpp index ef36c759..d70ddda3 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.cpp +++ b/src/SFML/Audio/SoundFileReaderFlac.cpp @@ -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(buffer[j][i] << 8); + sample = static_cast(buffer[j][i] << 8); break; case 16: - sample = static_cast(buffer[j][i]); + sample = static_cast(buffer[j][i]); break; case 24: - sample = static_cast(buffer[j][i] >> 8); + sample = static_cast(buffer[j][i] >> 8); break; case 32: - sample = static_cast(buffer[j][i] >> 16); + sample = static_cast(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,11 +312,11 @@ 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::difference_type>(maxCount), + m_clientData.leftovers.begin() + static_cast::difference_type>(maxCount), samples); - std::vector leftovers(m_clientData.leftovers.begin() + - static_cast::difference_type>(maxCount), - m_clientData.leftovers.end()); + std::vector leftovers(m_clientData.leftovers.begin() + + static_cast::difference_type>(maxCount), + m_clientData.leftovers.end()); m_clientData.leftovers.swap(leftovers); return maxCount; } diff --git a/src/SFML/Audio/SoundFileReaderFlac.hpp b/src/SFML/Audio/SoundFileReaderFlac.hpp index be0ff1aa..e4d939b8 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.hpp +++ b/src/SFML/Audio/SoundFileReaderFlac.hpp @@ -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: //////////////////////////////////////////////////////////// @@ -110,12 +110,12 @@ public: //////////////////////////////////////////////////////////// struct ClientData { - InputStream* stream; - SoundFileReader::Info info; - Int16* buffer; - Uint64 remaining; - std::vector leftovers; - bool error; + InputStream* stream; + SoundFileReader::Info info; + std::int16_t* buffer; + Uint64 remaining; + std::vector leftovers; + bool error; }; private: diff --git a/src/SFML/Audio/SoundFileReaderMp3.cpp b/src/SFML/Audio/SoundFileReaderMp3.cpp index 16172fa7..3f0b3d95 100644 --- a/src/SFML/Audio/SoundFileReaderMp3.cpp +++ b/src/SFML/Audio/SoundFileReaderMp3.cpp @@ -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(mp3dec_ex_read(&m_decoder, samples, static_cast(toRead))); diff --git a/src/SFML/Audio/SoundFileReaderMp3.hpp b/src/SFML/Audio/SoundFileReaderMp3.hpp index 67055b0f..e808f576 100644 --- a/src/SFML/Audio/SoundFileReaderMp3.hpp +++ b/src/SFML/Audio/SoundFileReaderMp3.hpp @@ -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: //////////////////////////////////////////////////////////// diff --git a/src/SFML/Audio/SoundFileReaderOgg.cpp b/src/SFML/Audio/SoundFileReaderOgg.cpp index 05046d9d..a197a066 100644 --- a/src/SFML/Audio/SoundFileReaderOgg.cpp +++ b/src/SFML/Audio/SoundFileReaderOgg.cpp @@ -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(maxCount - count) * static_cast(sizeof(Int16)); + int bytesToRead = static_cast(maxCount - count) * static_cast(sizeof(std::int16_t)); long bytesRead = ov_read(&m_vorbis, reinterpret_cast(samples), bytesToRead, 0, 2, 1, nullptr); if (bytesRead > 0) { - long samplesRead = bytesRead / static_cast(sizeof(Int16)); + long samplesRead = bytesRead / static_cast(sizeof(std::int16_t)); count += static_cast(samplesRead); samples += samplesRead; } diff --git a/src/SFML/Audio/SoundFileReaderOgg.hpp b/src/SFML/Audio/SoundFileReaderOgg.hpp index 711c6ca9..fff9a0e4 100644 --- a/src/SFML/Audio/SoundFileReaderOgg.hpp +++ b/src/SFML/Audio/SoundFileReaderOgg.hpp @@ -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: //////////////////////////////////////////////////////////// diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp index 21389abe..f6270ab1 100644 --- a/src/SFML/Audio/SoundFileReaderWav.cpp +++ b/src/SFML/Audio/SoundFileReaderWav.cpp @@ -46,13 +46,13 @@ bool decode(sf::InputStream& stream, std::uint8_t& value) return static_cast(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(stream.read(bytes, static_cast(sizeof(bytes)))) != sizeof(bytes)) return false; - value = static_cast(bytes[0] | (bytes[1] << 8)); + value = static_cast(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((static_cast(sample) - 128) << 8); + *samples++ = static_cast((static_cast(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(sample >> 8); + *samples++ = static_cast(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(sample >> 16); + *samples++ = static_cast(sample >> 16); else return count; break; diff --git a/src/SFML/Audio/SoundFileReaderWav.hpp b/src/SFML/Audio/SoundFileReaderWav.hpp index b3a768de..ac8e05d0 100644 --- a/src/SFML/Audio/SoundFileReaderWav.hpp +++ b/src/SFML/Audio/SoundFileReaderWav.hpp @@ -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: //////////////////////////////////////////////////////////// diff --git a/src/SFML/Audio/SoundFileWriterFlac.cpp b/src/SFML/Audio/SoundFileWriterFlac.cpp index ed9b1ec7..1571e47d 100644 --- a/src/SFML/Audio/SoundFileWriterFlac.cpp +++ b/src/SFML/Audio/SoundFileWriterFlac.cpp @@ -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) { diff --git a/src/SFML/Audio/SoundFileWriterFlac.hpp b/src/SFML/Audio/SoundFileWriterFlac.hpp index 53454486..66b0d1ef 100644 --- a/src/SFML/Audio/SoundFileWriterFlac.hpp +++ b/src/SFML/Audio/SoundFileWriterFlac.hpp @@ -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: //////////////////////////////////////////////////////////// diff --git a/src/SFML/Audio/SoundFileWriterOgg.cpp b/src/SFML/Audio/SoundFileWriterOgg.cpp index 0acadbda..1294c15e 100644 --- a/src/SFML/Audio/SoundFileWriterOgg.cpp +++ b/src/SFML/Audio/SoundFileWriterOgg.cpp @@ -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; diff --git a/src/SFML/Audio/SoundFileWriterOgg.hpp b/src/SFML/Audio/SoundFileWriterOgg.hpp index 331af3fc..6129c609 100644 --- a/src/SFML/Audio/SoundFileWriterOgg.hpp +++ b/src/SFML/Audio/SoundFileWriterOgg.hpp @@ -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: //////////////////////////////////////////////////////////// diff --git a/src/SFML/Audio/SoundFileWriterWav.cpp b/src/SFML/Audio/SoundFileWriterWav.cpp index fd64b37f..9940b908 100644 --- a/src/SFML/Audio/SoundFileWriterWav.cpp +++ b/src/SFML/Audio/SoundFileWriterWav.cpp @@ -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(value & 0xFF), static_cast(value >> 8)}; stream.write(reinterpret_cast(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()); diff --git a/src/SFML/Audio/SoundFileWriterWav.hpp b/src/SFML/Audio/SoundFileWriterWav.hpp index 04526318..ab66718c 100644 --- a/src/SFML/Audio/SoundFileWriterWav.hpp +++ b/src/SFML/Audio/SoundFileWriterWav.hpp @@ -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: //////////////////////////////////////////////////////////// diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 85f76e88..119e4af1 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -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(data.sampleCount * sizeof(Int16)); + auto size = static_cast(data.sampleCount * sizeof(std::int16_t)); alCheck(alBufferData(buffer, m_format, data.samples, size, static_cast(m_sampleRate))); // Push it into the sound queue diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index 859dcba6..ab751aa3 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -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(ntohs(static_cast(data))); + data = static_cast(ntohs(static_cast(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(htons(static_cast(data))); + auto toWrite = static_cast(htons(static_cast(data))); append(&toWrite, sizeof(toWrite)); return *this; } diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 29011a9c..9129bf50 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -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(LOWORD(lParam)); - position.y = static_cast(HIWORD(lParam)); + position.x = static_cast(LOWORD(lParam)); + position.y = static_cast(HIWORD(lParam)); ScreenToClient(m_handle, &position); - auto delta = static_cast(HIWORD(wParam)); + auto delta = static_cast(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(LOWORD(lParam)); - position.y = static_cast(HIWORD(lParam)); + position.x = static_cast(LOWORD(lParam)); + position.y = static_cast(HIWORD(lParam)); ScreenToClient(m_handle, &position); - auto delta = static_cast(HIWORD(wParam)); + auto delta = static_cast(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(LOWORD(lParam)); - event.mouseButton.y = static_cast(HIWORD(lParam)); + event.mouseButton.x = static_cast(LOWORD(lParam)); + event.mouseButton.y = static_cast(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(LOWORD(lParam)); - event.mouseButton.y = static_cast(HIWORD(lParam)); + event.mouseButton.x = static_cast(LOWORD(lParam)); + event.mouseButton.y = static_cast(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(LOWORD(lParam)); - event.mouseButton.y = static_cast(HIWORD(lParam)); + event.mouseButton.x = static_cast(LOWORD(lParam)); + event.mouseButton.y = static_cast(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(LOWORD(lParam)); - event.mouseButton.y = static_cast(HIWORD(lParam)); + event.mouseButton.x = static_cast(LOWORD(lParam)); + event.mouseButton.y = static_cast(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(LOWORD(lParam)); - event.mouseButton.y = static_cast(HIWORD(lParam)); + event.mouseButton.x = static_cast(LOWORD(lParam)); + event.mouseButton.y = static_cast(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(LOWORD(lParam)); - event.mouseButton.y = static_cast(HIWORD(lParam)); + event.mouseButton.x = static_cast(LOWORD(lParam)); + event.mouseButton.y = static_cast(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(LOWORD(lParam)); - event.mouseButton.y = static_cast(HIWORD(lParam)); + event.mouseButton.x = static_cast(LOWORD(lParam)); + event.mouseButton.y = static_cast(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(LOWORD(lParam)); - event.mouseButton.y = static_cast(HIWORD(lParam)); + event.mouseButton.x = static_cast(LOWORD(lParam)); + event.mouseButton.y = static_cast(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(LOWORD(lParam)); - int y = static_cast(HIWORD(lParam)); + int x = static_cast(LOWORD(lParam)); + int y = static_cast(HIWORD(lParam)); // Get the client area of the window RECT area; diff --git a/test/Network/Packet.cpp b/test/Network/Packet.cpp index e8b43120..aaa3b41f 100644 --- a/test/Network/Packet.cpp +++ b/test/Network/Packet.cpp @@ -26,12 +26,12 @@ TEST_CASE("sf::Packet class - [network]") testPacketStreamOperators(std::numeric_limits::max()); } - SUBCASE("Int16") + SUBCASE("std::int16_t") { - testPacketStreamOperators(sf::Int16(0)); - testPacketStreamOperators(sf::Int16(1)); - testPacketStreamOperators(std::numeric_limits::min()); - testPacketStreamOperators(std::numeric_limits::max()); + testPacketStreamOperators(std::int16_t(0)); + testPacketStreamOperators(std::int16_t(1)); + testPacketStreamOperators(std::numeric_limits::min()); + testPacketStreamOperators(std::numeric_limits::max()); } SUBCASE("Int32") diff --git a/test/System/Config.cpp b/test/System/Config.cpp index b1fe65bc..c9a9ad98 100644 --- a/test/System/Config.cpp +++ b/test/System/Config.cpp @@ -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);