Opened 15 years ago

Closed 15 years ago

Last modified 6 years ago

#9067 closed patch

Wave/ADPCM Endianness Fixes (WIP)

Reported by: SF/mthreepwood Owned by: fingolfin
Priority: normal Component: Audio
Version: Keywords:
Cc: Game:

Description

As the mixer states, an audio stream should be in the platform's native endianness. Considering that, several of the ADPCM decoders use the TO_LE_16 macro and then engines (such as AGOS and SCUMM) read all of the data out of the AudioStream returned and use it in a LinearMemoryStream (via Mixer::playRaw()). This would be fine for LE systems, but breaks sounds on BE systems. This patch changes the ADPCM decoders to not use TO_LE_16 and changes the calls in both AGOS and SCUMM (HE) to adapt to this as well as makeWAVStream(). AGOS uses the streams directly and SCUMM still reads out the data, but sets the Little Endian flag if on an LE system. As a bonus, the WAV code now supports looping so the AGOS code that originally was used for that has been removed. The Feeble Files' DXA sound problem on BE systems is fixed by this patch.

As of the other engines which use loadWAVFromStream(), I converted both sword1 and Tucker to use makeWAVStream(), but I have not tested them. I did not modify SAGA, Sword2 or Gob - they are more complicated than the other engines. They may even work without any changes if the sound is raw, but I do not know.

This patch is against the 1.0.0 branch. I will also upload a patch for the trunk (my trunk was modified at the time of writing, and it was easier to code for the branch).

dhewg tested the patch on both Linux and Wii with the Feeble Files DXA. I tested on my Mac (x86) with football2002. I did not test sword1 or tucker (I don't have Tucker and I only have the PSX version of sword1).

Ticket imported from: #2834677. Ticket imported from: patches/1172.

Attachments (3)

wave_endianness_fix.diff (12.4 KB ) - added by SF/mthreepwood 15 years ago.
Patch against 1.0.0 branch
wave_endianness_fix_2.diff (12.9 KB ) - added by dhewg 15 years ago.
Patch superseeding wave_endianness_fix.diff
wave_endianness_fix_3.diff (12.1 KB ) - added by SF/mthreepwood 15 years ago.
Patch against current trunk (r45085)

Download all attachments as: .zip

Change History (12)

by SF/mthreepwood, 15 years ago

Attachment: wave_endianness_fix.diff added

Patch against 1.0.0 branch

comment:1 by dhewg, 15 years ago

Ack, this fixes bug #2211901, which is still present in SVN - despite it beeing set to "Fixed"

by dhewg, 15 years ago

Attachment: wave_endianness_fix_2.diff added

Patch superseeding wave_endianness_fix.diff

comment:2 by dhewg, 15 years ago

Commited a hotfix for bug #2211901, which is less intrusive and can be tested now.

clone's patch is still valid, and should be the way to clean up the endian mess. Uploaded wave_endianness_fix_2.diff, which adapts the initial patch and reverts the hotfix too.

comment:3 by fingolfin, 15 years ago

This patch seems sensible to me, but I don't think we should apply it to the 1.0.0 branch at this stage: As i understand dhewg fixed the issue there with a hotfix, so there is no improved stability to be gained, but a risk of breaking engines.

However, it would be good to apply this to trunk ASAP so we can start testing it for regressions in the modified engines.

comment:4 by sev-, 15 years ago

Please adjust the patch for trunk. Especially change to tucker/resource.cpp is not obvious to me

comment:5 by SF/mthreepwood, 15 years ago

OK, I'll make a patch for the trunk.

by SF/mthreepwood, 15 years ago

Attachment: wave_endianness_fix_3.diff added

Patch against current trunk (r45085)

comment:6 by SF/mthreepwood, 15 years ago

I added a new patch for the trunk (which is essentially the same as the previous one).

@sev: The Tucker changes were moving from loadWAVFromStream() to makeWAVStream()

comment:7 by fingolfin, 15 years ago

Great work, commited to trunk.

comment:8 by fingolfin, 15 years ago

Owner: set to fingolfin
Status: newclosed

comment:9 by digitall, 6 years ago

Component: Audio
Note: See TracTickets for help on using tickets.