Skip to content

Commit d7d241d

Browse files
author
Chris Jakeman
committed
Change sound structures from Explicit to Sequential
1 parent b0c8b66 commit d7d241d

File tree

2 files changed

+55
-55
lines changed

2 files changed

+55
-55
lines changed

Source/RunActivity/RunActivity.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<DefineConstants>TRACE;DEBUG;WINDOWS;NEW_ACTION;WITH_NEW_SAVE;ACTIVITY_EDITOR</DefineConstants>
2323
<ErrorReport>prompt</ErrorReport>
2424
<WarningLevel>4</WarningLevel>
25-
<PlatformTarget>AnyCPU</PlatformTarget>
25+
<PlatformTarget>x86</PlatformTarget>
2626
<Prefer32Bit>false</Prefer32Bit>
2727
<LangVersion>7.3</LangVersion>
2828
</PropertyGroup>

Source/RunActivity/Viewer3D/OpenAL.cs

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public static string GetErrorString(int error)
402402
return "Out Of Memory";
403403
else if (error == AL_NO_ERROR)
404404
return "No Error";
405-
405+
406406
return "";
407407
}
408408

@@ -455,7 +455,7 @@ private static void CheckMaxSourcesConfig()
455455
ORTS.Common.NativeMethods.WritePrivateProfileString("General", "sources", "1024", configFile);
456456
}
457457
}
458-
catch(Exception ex)
458+
catch (Exception ex)
459459
{
460460
Trace.TraceError("Couldn't check or set OpenAL max sound sources in %AppData%\\Roaming\\alsoft.ini: ", ex.Message);
461461
}
@@ -465,26 +465,26 @@ private static void CheckMaxSourcesConfig()
465465
/// <summary>
466466
/// WAVEFILEHEADER binary structure
467467
/// </summary>
468-
[StructLayout(LayoutKind.Explicit, Pack = 1)]
468+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
469469
public struct WAVEFILEHEADER
470470
{
471-
[FieldOffset(0), MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
471+
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
472472
public char[] szRIFF;
473-
[FieldOffset(4), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
473+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
474474
public uint ulRIFFSize;
475-
[FieldOffset(8), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
475+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
476476
public uint padding;
477477
}
478478

479479
/// <summary>
480480
/// RIFFCHUNK binary structure
481481
/// </summary>
482-
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi, Pack = 1)]
482+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
483483
public struct RIFFCHUNK
484484
{
485-
[FieldOffset(0), MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
485+
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
486486
public char[] szChunkName;
487-
[FieldOffset(4), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
487+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
488488
public uint ulChunkSize;
489489
}
490490

@@ -519,14 +519,14 @@ public struct WAVEFORMATEXTENSIBLE
519519
/// CUECHUNK binary structure
520520
/// Describes the CUE chunk list of a wave file
521521
/// </summary>
522-
[StructLayout(LayoutKind.Explicit, Pack = 1)]
522+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
523523
public struct CUECHUNK
524524
{
525-
[FieldOffset(0), MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
525+
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
526526
public char[] szChunkName;
527-
[FieldOffset(4), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
527+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
528528
public uint ulChunkSize;
529-
[FieldOffset(8), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
529+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
530530
public uint ulNumCuePts;
531531
}
532532

@@ -550,30 +550,30 @@ public struct CUEPT
550550
/// SMPLCHUNK binary structure
551551
/// Describes the SMPL chunk list of a wave file
552552
/// </summary>
553-
[StructLayout(LayoutKind.Explicit, Pack = 1)]
553+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
554554
public struct SMPLCHUNK
555555
{
556-
[FieldOffset(0), MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
556+
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
557557
public char[] ChunkName;
558-
[FieldOffset(4), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
558+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
559559
public uint ChunkSize;
560-
[FieldOffset(8), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
560+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
561561
public uint Manufacturer;
562-
[FieldOffset(12), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
562+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
563563
public uint Product;
564-
[FieldOffset(16), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
564+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
565565
public uint SmplPeriod;
566-
[FieldOffset(20), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
566+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
567567
public uint MIDIUnityNote;
568-
[FieldOffset(24), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
568+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
569569
public uint MIDIPitchFraction;
570-
[FieldOffset(28), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
570+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
571571
public uint SMPTEFormat;
572-
[FieldOffset(32), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
572+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
573573
public uint SMPTEOffset;
574-
[FieldOffset(36), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
574+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
575575
public uint NumSmplLoops;
576-
[FieldOffset(40), MarshalAs(UnmanagedType.U4, SizeConst = 4)]
576+
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
577577
public uint SamplerData;
578578
}
579579

@@ -604,26 +604,26 @@ public enum WAVEFORMATTYPE
604604
public class WaveFileData
605605
{
606606
// Constants from C header files
607-
private const ushort WAVE_FORMAT_PCM = 1;
608-
private const ushort WAVE_FORMAT_EXTENSIBLE = 0xFFFE;
609-
610-
private const ushort SPEAKER_FRONT_LEFT = 0x1;
611-
private const ushort SPEAKER_FRONT_RIGHT = 0x2;
612-
private const ushort SPEAKER_FRONT_CENTER = 0x4;
613-
private const ushort SPEAKER_LOW_FREQUENCY = 0x8;
614-
private const ushort SPEAKER_BACK_LEFT = 0x10;
615-
private const ushort SPEAKER_BACK_RIGHT = 0x20;
616-
private const ushort SPEAKER_FRONT_LEFT_OF_CENTER = 0x40;
617-
private const ushort SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80;
618-
private const ushort SPEAKER_BACK_CENTER = 0x100;
619-
private const ushort SPEAKER_SIDE_LEFT = 0x200;
620-
private const ushort SPEAKER_SIDE_RIGHT = 0x400;
621-
private const ushort SPEAKER_TOP_CENTER = 0x800;
622-
private const ushort SPEAKER_TOP_FRONT_LEFT = 0x1000;
623-
private const ushort SPEAKER_TOP_FRONT_CENTER = 0x2000;
624-
private const ushort SPEAKER_TOP_FRONT_RIGHT = 0x4000;
625-
private const ushort SPEAKER_TOP_BACK_LEFT = 0x8000;
626-
607+
private const ushort WAVE_FORMAT_PCM = 1;
608+
private const ushort WAVE_FORMAT_EXTENSIBLE = 0xFFFE;
609+
610+
private const ushort SPEAKER_FRONT_LEFT = 0x1;
611+
private const ushort SPEAKER_FRONT_RIGHT = 0x2;
612+
private const ushort SPEAKER_FRONT_CENTER = 0x4;
613+
private const ushort SPEAKER_LOW_FREQUENCY = 0x8;
614+
private const ushort SPEAKER_BACK_LEFT = 0x10;
615+
private const ushort SPEAKER_BACK_RIGHT = 0x20;
616+
private const ushort SPEAKER_FRONT_LEFT_OF_CENTER = 0x40;
617+
private const ushort SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80;
618+
private const ushort SPEAKER_BACK_CENTER = 0x100;
619+
private const ushort SPEAKER_SIDE_LEFT = 0x200;
620+
private const ushort SPEAKER_SIDE_RIGHT = 0x400;
621+
private const ushort SPEAKER_TOP_CENTER = 0x800;
622+
private const ushort SPEAKER_TOP_FRONT_LEFT = 0x1000;
623+
private const ushort SPEAKER_TOP_FRONT_CENTER = 0x2000;
624+
private const ushort SPEAKER_TOP_FRONT_RIGHT = 0x4000;
625+
private const ushort SPEAKER_TOP_BACK_LEFT = 0x8000;
626+
627627
// General info about current wave file
628628
public bool isKnownType;
629629
public WAVEFORMATEXTENSIBLE wfEXT;
@@ -677,7 +677,7 @@ private bool ParseWAV(string n)
677677
// Read Wave file header
678678
WAVEFILEHEADER waveFileHeader = new WAVEFILEHEADER();
679679
{
680-
GetNextStructureValue<WAVEFILEHEADER>(pFile, out waveFileHeader, - 1);
680+
GetNextStructureValue<WAVEFILEHEADER>(pFile, out waveFileHeader, -1);
681681
// Check if wave file
682682
string hdr = new string(waveFileHeader.szRIFF);
683683
if (hdr != "RIFF" && hdr != "WAVE")
@@ -689,7 +689,7 @@ private bool ParseWAV(string n)
689689
while (GetNextStructureValue<RIFFCHUNK>(pFile, out riffChunk, -1))
690690
{
691691
// Format chunk
692-
hdr = new string (riffChunk.szChunkName);
692+
hdr = new string(riffChunk.szChunkName);
693693
if (hdr == "fmt ")
694694
{
695695
WAVEFORMATEXTENSIBLE waveFmt = new WAVEFORMATEXTENSIBLE();
@@ -701,7 +701,7 @@ private bool ParseWAV(string n)
701701
if (waveFmt.Format.wFormatTag == WAVE_FORMAT_PCM)
702702
{
703703
isKnownType = true;
704-
wtType = WAVEFORMATTYPE.WT_PCM;
704+
wtType = WAVEFORMATTYPE.WT_PCM;
705705
waveFmt.wValidBitsPerSample = waveFmt.Format.wBitsPerSample;
706706
}
707707
else if (waveFmt.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE)
@@ -803,7 +803,7 @@ private bool ParseWAV(string n)
803803
/// </summary>
804804
/// <param name="pulFormat">Place to put the format number</param>
805805
/// <returns>True if success</returns>
806-
private bool GetALFormat(ref int pulFormat, ref bool mstsMonoTreatment, ushort origNChannels )
806+
private bool GetALFormat(ref int pulFormat, ref bool mstsMonoTreatment, ushort origNChannels)
807807
{
808808
pulFormat = 0;
809809

@@ -1084,7 +1084,7 @@ public static bool OpenWavFile(string Name, ref int[] BufferIDs, ref int[] Buffe
10841084
wfi.CuePoints[i] = 0xFFFFFFFF;
10851085
adjPos = prevAdjPos;
10861086
}
1087-
1087+
10881088
BufferLens[i] = (int)adjPos - (int)prevAdjPos;
10891089
if (BufferLens[i] > 0)
10901090
{
@@ -1095,7 +1095,7 @@ public static bool OpenWavFile(string Name, ref int[] BufferIDs, ref int[] Buffe
10951095
{
10961096
BufferIDs[i] = 0;
10971097
}
1098-
1098+
10991099
if (i == wfi.CuePoints.Length - 1)
11001100
{
11011101
BufferLens[i + 1] = (int)wfi.ulDataSize - (int)adjPos;
@@ -1129,7 +1129,7 @@ static byte[] GetFromArray(byte[] buffer, int offset, int len)
11291129
Buffer.BlockCopy(buffer, offset, retval, 0, len);
11301130
return retval;
11311131
}
1132-
1132+
11331133
/// <summary>
11341134
/// Reads a given structure from a FileStream
11351135
/// </summary>
@@ -1161,11 +1161,11 @@ public static bool GetNextStructureValue<T>(FileStream fs, out T retval, int len
11611161
handle.Free();
11621162
return true;
11631163
}
1164-
catch
1164+
catch
11651165
{
11661166
return false;
11671167
}
1168-
}
1168+
}
11691169
}
11701170
}
11711171

0 commit comments

Comments
 (0)