Skip to content

Commit

Permalink
MKA : Properly read files whose first Cluster doesn't start at Timest…
Browse files Browse the repository at this point in the history
…amp 0 [#310]
  • Loading branch information
Zeugma440 committed Feb 3, 2025
1 parent b8066fd commit 4918f2e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ATL/AudioData/IO/MKA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,18 +404,25 @@ private bool readPhysicalData(EBMLReader reader)

// Find AudioDataOffset using Clusters' timecodes
reader.seek(segmentOffset);
// Cluster with Timecode 0
// Seek Cluster with Timecode 0
crits = new HashSet<Tuple<long, int>>
{
new Tuple<long, int>(ID_TIMESTAMP, 0), // Timestamp
};
res = reader.seekElement(ID_CLUSTER, crits); // Cluster
res = reader.seekElement(ID_CLUSTER, crits);
if (res != EBMLReader.SeekResult.FOUND_MATCH)
{
LogDelegator.GetLogDelegate()(Log.LV_WARNING, "Couldn't locate Cluster for timestamp 0");
return false;
// Seek first cluster instead
reader.seek(segmentOffset);
if (!reader.seekElement(ID_CLUSTER))
{
LogDelegator.GetLogDelegate()(Log.LV_WARNING, "Couldn't locate any Cluster!");
return false;
}
}
long zeroClusterOffset = reader.Position;

long firstClusterOffset = reader.Position;

long blockAudioSize = -1;
while (-1 == AudioDataOffset)
Expand All @@ -440,7 +447,7 @@ private bool readPhysicalData(EBMLReader reader)
else break;
}

reader.seek(zeroClusterOffset);
reader.seek(firstClusterOffset);
while (-1 == AudioDataOffset)
{
if (reader.seekElement(ID_SIMPLEBLOCK)) // SimpleBlock
Expand Down

0 comments on commit 4918f2e

Please # to comment.