We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5187

Summary: [PATCH] ogg playback not working on big-endian devices when using Tremor instead of Vorbis
Product: SDL_mixer Reporter: sergiou87 <sergio.padrino+libsdl>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2    
Version: 2.0.4   
Hardware: PowerPC   
OS: Other   
Attachments: Fix for ogg playback on big-endian hosts

Description sergiou87 2020-06-14 10:15:05 UTC
Created attachment 4382 [details]
Fix for ogg playback on big-endian hosts

The root of the problem is that SDL_mixer *always* provides an audio stream in little-endian byte order (AUDIO_S16). This has two consequences:

- Since Tremor doesn't swap bytes for big-endian devices, it means ov_read from Tremor will provide data in big-endian instead of little-endian as required by the AUDIO_S16 mentioned above, so audio will be unplayable.

- When using Vorbis, bytes will be swapped twice in big-endian devices: first by ov_read to little-endian when reading the file data, and then to big-endian by SDL_Convert_Byteswap before sending the data to the audio device.

Applying this patch fixes Tremor support on big-endian devices and improves
performance/efficiency of Vorbis on big-endian devices.

You can see the changes here: https://github.com/sergiou87/SDL_mixer/commit/a2ceebacdd005791c04b60e5a88c254c619bdffc

Also attached a patch in case it's easier to handle. Happy to submit it to the commit mailing list also if makes things easier.
Comment 1 Sam Lantinga 2020-06-15 17:08:47 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL_mixer/rev/e6f2d0a83df5