Skip to content

Conversation

@jcowgill
Copy link
Contributor

@jcowgill jcowgill commented Dec 8, 2024

Description

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.

There's a very old forum thread mentioning this: https://en.sfml-dev.org/forums/index.php?topic=22653

Tasks

  • Tested on Linux
  • Tested on Windows
  • Tested on macOS
  • Tested on iOS
  • Tested on Android

How to test this PR?

I have run the testsuite on a big-endian system and it passes with this change (it was previously failing).

@coveralls
Copy link
Collaborator

coveralls commented Dec 8, 2024

Pull Request Test Coverage Report for Build 12224968092

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 57.03%

Totals Coverage Status
Change from base Build 12198438625: -0.001%
Covered Lines: 12059
Relevant Lines: 19988

💛 - Coveralls
@eXpl0it3r eXpl0it3r added this to the 3.0 milestone Dec 8, 2024
@ChrisThrasher
Copy link
Member

Fixes a unit test failure on big-endian systems.

Would you please share the test failure?

@jcowgill
Copy link
Contributor Author

jcowgill commented Dec 8, 2024

Fixes a unit test failure on big-endian systems.

Would you please share the test failure?

From https://buildd.debian.org/status/fetch.php?pkg=libsfml&arch=s390x&ver=3.0.0%7Erc1%2Bdfsg-1&stamp=1733197260&raw=0

50/50 Test #48: [Audio] sf::InputSoundFile ........***Failed    0.01 sec
Failed to open sound file (couldn't open stream)
    Provided path: "does/not/exist.wav"
    Absolute path: "/<<PKGBUILDDIR>>/test/does/not/exist.wav"
Failed to open sound file (couldn't open stream)
    Provided path: "does/not/exist.wav"
    Absolute path: "/<<PKGBUILDDIR>>/test/does/not/exist.wav"
Failed to seek sound stream
Filters: "\[Audio\] sf::InputSoundFile"
Randomness seeded to: 3763875633

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test-sfml-audio is a Catch2 v3.7.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
[Audio] sf::InputSoundFile
  read()
  Successful read
  ogg
-------------------------------------------------------------------------------
./test/Audio/InputSoundFile.test.cpp:369
...............................................................................

./test/Audio/InputSoundFile.test.cpp:373: FAILED:
  CHECK( samples == std::array<std::int16_t, 4>{-827, -985, -1168, -1319} )
with expansion:
  { -14852, 10236, 28923, -9734 }
  ==
  { -827, -985, -1168, -1319 }

./test/Audio/InputSoundFile.test.cpp:375: FAILED:
  CHECK( samples == std::array<std::int16_t, 4>{-1738, -1883, -2358, -2497} )
with expansion:
  { 14073, -23048, -13578, 16374 }
  ==
  { -1738, -1883, -2358, -2497 }

===============================================================================
test cases:   1 |   0 passed | 1 failed
assertions: 168 | 166 passed | 2 failed

Note this build has some patches so they're not "pure". -rc1 only has build system patches though which I don't think will affect this MR.

The other -rc1 builds: https://buildd.debian.org/status/logs.php?pkg=libsfml&ver=3.0.0%7Erc1%2Bdfsg-1

@ChrisThrasher
Copy link
Member

ChrisThrasher commented Dec 8, 2024

Note this build has some patches so they're not "pure". -rc1 only has build system patches though which I don't think will affect this MR.

As an aside, please reach out if you would like to potentially upstream any of those patches. I'm always interested in doing what I can to make the lives of package managers easier! You can find my email in the commit history or reach out in our Discord server.

Copy link
Member

@ChrisThrasher ChrisThrasher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a few minor style changes. Thanks for the PR!

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.
@SFML SFML deleted a comment from ChrisThrasher Dec 8, 2024
@ChrisThrasher ChrisThrasher merged commit 34ec279 into SFML:master Dec 8, 2024
120 checks passed
@jcowgill jcowgill deleted the ogg-endian branch December 26, 2024 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants