Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeugma440 committed Oct 22, 2023
1 parent 7a594e0 commit 7d08e8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ATL/AudioData/AudioDataIOFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public IAudioDataIO GetFromStream(Stream s)
long offset = 0;
s.Read(data, 0, 32);
// Hardcoded case of ID3v2 as it is the sole standard metadata system to appear at the beginning of file
if (ID3v2.isValidHeader(data))
if (ID3v2.IsValidHeader(data))
{
byte[] data2 = new byte[4];
Array.Copy(data, 6, data2, 0, 4); // bytes 6-9 only
Expand Down
17 changes: 9 additions & 8 deletions ATL/AudioData/IO/ID3v2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class ID3v2 : MetaDataIO
// Technical 'shortcut' data
private static readonly byte[] BOM_UTF16_LE = { 0xFF, 0xFE };
private static readonly byte[] BOM_UTF16_BE = { 0xFE, 0xFF };
private static readonly byte[] BOM_NONE = { };
private static readonly byte[] BOM_NONE = Array.Empty<byte>();

private static readonly byte[] NULLTERMINATOR = { 0x00 };
private static readonly byte[] NULLTERMINATOR_2 = { 0x00, 0x00 };
Expand Down Expand Up @@ -315,7 +315,7 @@ private sealed class TagInfo
// **** BASE HEADER PROPERTIES ****
public bool UsesUnsynchronisation => (Flags & FLAG_TAG_UNSYNCHRONIZED) > 0;

public bool HasExtendedHeader => ((Flags & FLAG_TAG_HAS_EXTENDED_HEADER) > 0) && (Version > TAG_VERSION_2_2); // Determinated from flags; indicates if tag has an extended header (ID3v2.3+)
public bool HasExtendedHeader => (Flags & FLAG_TAG_HAS_EXTENDED_HEADER) > 0 && Version > TAG_VERSION_2_2; // Determinated from flags; indicates if tag has an extended header (ID3v2.3+)

private bool HasFooter => (Flags & FLAG_TAG_HAS_FOOTER) > 0; // Determinated from flags; indicates if tag has a footer (ID3v2.4+)

Expand Down Expand Up @@ -366,7 +366,8 @@ public int TagSizeRestrictionKB
};
}
}
public bool HasTextEncodingRestriction => (TagRestrictions & 0x20) >> 5 > 0;

// public bool HasTextEncodingRestriction => (TagRestrictions & 0x20) >> 5 > 0;

public int TextFieldSizeRestriction
{
Expand Down Expand Up @@ -510,19 +511,19 @@ protected override bool canHandleNonStandardField(string code, string value)
return true; // Will be transformed to a TXXX field
}

public static bool isValidHeader(byte[] data)
internal static bool IsValidHeader(byte[] data)
{
if (data.Length < 3) return false;
return Utils.Latin1Encoding.GetString(data).StartsWith(ID3V2_ID);
}

private bool readHeader(BufferedBinaryReader SourceFile, TagInfo Tag, long offset)
private static bool readHeader(BufferedBinaryReader SourceFile, TagInfo Tag, long offset)
{
// Reads mandatory (base) header
SourceFile.Seek(offset, SeekOrigin.Begin);
Tag.ID = SourceFile.ReadBytes(3);

if (!isValidHeader(Tag.ID)) return false;
if (!IsValidHeader(Tag.ID)) return false;

Tag.Version = SourceFile.ReadByte();
Tag.Revision = SourceFile.ReadByte();
Expand Down Expand Up @@ -1114,7 +1115,7 @@ public bool Read(Stream source, long offset, ReadTagParams readTagParams)
tagData.PaddingSize = tagHeader.GetPaddingSize();

// Process data if loaded and header valid
if (result && isValidHeader(tagHeader.ID))
if (result && IsValidHeader(tagHeader.ID))
{
tagExists = true;
// Fill properties with header data
Expand Down Expand Up @@ -1411,7 +1412,7 @@ private int writeFrames(TagData tag, BinaryWriter w, Encoding tagEncoding)
return nbFrames;
}

private void writeFrameHeader(BinaryWriter w, string frameCode, bool useUnsynchronization, bool useDataSize = false)
private static void writeFrameHeader(BinaryWriter w, string frameCode, bool useUnsynchronization, bool useDataSize = false)
{
w.Write(Utils.Latin1Encoding.GetBytes(frameCode));
w.Write(0);
Expand Down
2 changes: 1 addition & 1 deletion ATL/AudioData/IO/WMA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private void resetData()
ResetData();
}

private void generateLowerMappings()
private static void generateLowerMappings()
{
foreach (var mapping in frameMapping)
{
Expand Down

0 comments on commit 7d08e8d

Please sign in to comment.