OpenRA/OpenRA · error · InvalidDataException

Invalid repeat start block length in voc file

Error message

Invalid repeat start block length in voc file

What it means

Thrown when a Repeat start block (block code 6) does not have exactly 2 bytes of payload. The repeat-start marker must contain a single UInt16 specifying the loop count. A different length means the block is malformed.

Source

Thrown at OpenRA.Mods.Cnc/AudioLoaders/VocLoader.cs:216

					}

					// Silence
					case 3:
					{
						if (block.Length != 3)
							throw new InvalidDataException("Invalid silence block length in voc file");
						block.SampleBlock.Offset = 0;
						block.SampleBlock.Samples = stream.ReadUInt16() + 1;
						var freqDiv = stream.ReadUInt8();
						block.SampleBlock.Rate = GetSampleRateFromVocRate(freqDiv);
						break;
					}

					// Repeat start
					case 6:
					{
						if (block.Length != 2)
							throw new InvalidDataException("Invalid repeat start block length in voc file");
						block.LoopBlock.Count = stream.ReadUInt16() + 1;
						break;
					}

					// Repeat end
					case 7:
						break;

					// Extra info
					case 8:
					{
						if (block.Length != 4)
							throw new InvalidDataException("Invalid info block length in voc file");
						int freqDiv = stream.ReadUInt16();
						if (freqDiv == 65536)
							throw new InvalidDataException("Invalid frequency divisor 65536 in voc file");
						var codec = stream.ReadUInt8();
						if (codec != 0)

View on GitHub (pinned to a520984d91)

Solutions

  1. Re-extract the asset from a trusted source.
  2. Remove or fix loop markers using a VOC-aware audio editor.
  3. If generating VOC files, ensure code-6 blocks always have Length set to 2.
Defensive patterns

Strategy: try-catch

Try / catch

try { sound = new VocFormat(stream); }
catch (InvalidDataException) { /* file rejected */ }

Prevention

When it happens

Trigger: VocFormat.Preload, case 6: the check `block.Length != 2` fires when the 3-byte block length field is not 2.

Common situations: Corrupted or hand-edited VOC files with loop markers. VOC files from converters that emit non-standard repeat block sizes.

Related errors


AI-assisted analysis of OpenRA/OpenRA@a520984d91 (2026-08-13). Data as JSON: /api/errors/07e17d81f1ed2cfa. Report an issue: GitHub.