mirror of
https://github.com/SFML/SFML.git
synced 2025-01-18 23:35:11 +08:00
Fix Ogg ov_read call on big-endian systems
In the `ov_read` API, the fouth parameter says what endianness the samples should be returned in - `0` for little-endian, and `1` for big-endian. SFML wants samples in the host endian, so we need to set this parameter to 1 on big-endian systems. Fixes a unit test failure on big-endian systems.
This commit is contained in:
parent
f930cbc562
commit
34ec2795a1
@ -135,6 +135,7 @@ For a closer look at breaking changes and how to migrate from SFML 2, check out
|
|||||||
|
|
||||||
- Fixed `sf::SoundStream::play` bug (#2037)
|
- Fixed `sf::SoundStream::play` bug (#2037)
|
||||||
- Fixed poor `sf::SoundStream::setPlayingOffset` precision (#3101)
|
- Fixed poor `sf::SoundStream::setPlayingOffset` precision (#3101)
|
||||||
|
- Fixed a bug when reading Ogg files on big endian systems (#3340)
|
||||||
|
|
||||||
### Network
|
### Network
|
||||||
|
|
||||||
|
@ -169,6 +169,9 @@ target_compile_definitions(sfml-audio PRIVATE MA_NO_MP3 MA_NO_FLAC MA_NO_ENCODIN
|
|||||||
# use standard fixed-width integer types
|
# use standard fixed-width integer types
|
||||||
target_compile_definitions(sfml-audio PRIVATE MA_USE_STDINT)
|
target_compile_definitions(sfml-audio PRIVATE MA_USE_STDINT)
|
||||||
|
|
||||||
|
# detect the endianness as required by Ogg
|
||||||
|
target_compile_definitions(sfml-audio PRIVATE SFML_IS_BIG_ENDIAN=$<STREQUAL:${CMAKE_CXX_BYTE_ORDER},BIG_ENDIAN>)
|
||||||
|
|
||||||
# setup dependencies
|
# setup dependencies
|
||||||
target_link_libraries(sfml-audio
|
target_link_libraries(sfml-audio
|
||||||
PUBLIC SFML::System
|
PUBLIC SFML::System
|
||||||
|
@ -196,8 +196,8 @@ std::uint64_t SoundFileReaderOgg::read(std::int16_t* samples, std::uint64_t maxC
|
|||||||
std::uint64_t count = 0;
|
std::uint64_t count = 0;
|
||||||
while (count < maxCount)
|
while (count < maxCount)
|
||||||
{
|
{
|
||||||
const int bytesToRead = static_cast<int>(maxCount - count) * static_cast<int>(sizeof(std::int16_t));
|
const int bytesToRead = static_cast<int>(maxCount - count) * static_cast<int>(sizeof(std::int16_t));
|
||||||
const long bytesRead = ov_read(&m_vorbis, reinterpret_cast<char*>(samples), bytesToRead, 0, 2, 1, nullptr);
|
const long bytesRead = ov_read(&m_vorbis, reinterpret_cast<char*>(samples), bytesToRead, SFML_IS_BIG_ENDIAN, 2, 1, nullptr);
|
||||||
if (bytesRead > 0)
|
if (bytesRead > 0)
|
||||||
{
|
{
|
||||||
const long samplesRead = bytesRead / static_cast<long>(sizeof(std::int16_t));
|
const long samplesRead = bytesRead / static_cast<long>(sizeof(std::int16_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user