0x0ade / XnaToFna

Relink games / tools using the XNA Framework 4.0 to use FNA instead
zlib License
51 stars 5 forks source link

The Monolithic WMA/WMV Content Thread #2

Open flibitijibibo opened 7 years ago

flibitijibibo commented 7 years ago

This is where we dump bugs related to Windows Media content not being fixed or bugs that are introduced by the content conversion.

Starting with a Stardew Valley WaveBank, which interestingly doesn't use xWMA at all:

System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
  at System.IO.BinaryReader.FillBuffer (System.Int32 numBytes) [0x0008f] in /builddir/build/BUILD/mono-4.6.2/mcs/class/referencesource/mscorlib/system/io/binaryreader.cs:571 
  at System.IO.BinaryReader.ReadUInt32 () [0x00000] in /builddir/build/BUILD/mono-4.6.2/mcs/class/referencesource/mscorlib/system/io/binaryreader.cs:191 
  at Microsoft.Xna.Framework.Audio.WaveBank.LoadWaveBank (Microsoft.Xna.Framework.Audio.AudioEngine audioEngine, System.IO.BinaryReader reader, System.Boolean streaming) [0x00010] in /home/flibitijibibo/.wine/drive_c/Program Files/Steam/steamapps/common/Stardew Valley/XnaToFna/lib-projs/FNA/src/Audio/WaveBank.cs:293 
  at Microsoft.Xna.Framework.Audio.WaveBank..ctor (Microsoft.Xna.Framework.Audio.AudioEngine audioEngine, System.String nonStreamingWaveBankFilename) [0x00043] in /home/flibitijibibo/.wine/drive_c/Program Files/Steam/steamapps/common/Stardew Valley/XnaToFna/lib-projs/FNA/src/Audio/WaveBank.cs:181 
  at StardewValley.Game1.Initialize () [0x00117] in <8735ddc4c49943f59d59831f1ffc73cf>:0 
  at Microsoft.Xna.Framework.Game.DoInitialize () [0x0000f] in /home/flibitijibibo/.wine/drive_c/Program Files/Steam/steamapps/common/Stardew Valley/XnaToFna/lib-projs/FNA/src/Game.cs:828 
  at Microsoft.Xna.Framework.Game.Run () [0x00014] in /home/flibitijibibo/.wine/drive_c/Program Files/Steam/steamapps/common/Stardew Valley/XnaToFna/lib-projs/FNA/src/Game.cs:417 
  at StardewValley.Program.Main (System.String[] args) [0x00028] in <8735ddc4c49943f59d59831f1ffc73cf>:0
0x0ade commented 7 years ago

For whatever reason, XnaToFna spits out a zero-byte file on Linux, also explaining why it fails so early, checking the file header...

0x0ade commented 7 years ago

In src/Content/WaveBank.cs:

        public static void UpdateWaveBank(string path, BinaryReader reader, BinaryWriter writer) {
            if (!IsFFMPEGAvailable) return;
            Log($"[UpdateWaveBank] Updating wave bank {path}");
  1. There's a missing reader.BaseStream.CopyTo(writer.BaseStream); to at least fill the temporary output.
  2. XnaToFna.ContentHelper.IsFFMPEGAvailable incorrectly returns false on Linux.
0x0ade commented 7 years ago

The following commit fixes the 0 byte XWB issue: https://github.com/0x0ade/XnaToFna/commit/0ad8154ccd7ad64a81aa6e5b7df63b72d2189b46

  1. If FFMPEG is not available, it just copies over the data from the input stream.
  2. I forgot that the platform enum is actually a flag enum, meaning a check != 0 was predetermined to fail in this specific case.

Additionally, https://github.com/0x0ade/XnaToFna/commit/55c097c07b89d40c8a244d92ffbafd831582ee6a now makes XnaToFna log if FFMPEG is missing.

0x0ade commented 6 years ago

https://github.com/0x0ade/XnaToFna/commit/cf99acf09beaaa65937748f26c7f06943cec3d6c adds XMA2 "support," which is part of #3

flibitijibibo commented 5 years ago

xWMA should be covered by https://github.com/FNA-XNA/FAudio/issues/32 instead of XnaToFna. If we wanted to be extra involved we could also implement a WMA backend for XNA_Song.c but honestly since we need a converter for WMV files anyway, I'm not too worried about that...