Skip to content

Commit

Permalink
more codacy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mariodivece committed Mar 17, 2019
1 parent 2d98ed5 commit b546ade
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
6 changes: 5 additions & 1 deletion Unosquare.FFME.Common/ClosedCaptions/ClosedCaptionPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// Represents a 3-byte packet of closed-captioning data in EIA-608 format.
/// See: http://jackyjung.tistory.com/attachment/499e14e28c347DB.pdf
/// </summary>
public sealed class ClosedCaptionPacket : IComparable<ClosedCaptionPacket>
public sealed class ClosedCaptionPacket : IComparable<ClosedCaptionPacket>, IEquatable<ClosedCaptionPacket>
{
#region Dictionaries

Expand Down Expand Up @@ -735,6 +735,10 @@ public override bool Equals(object obj)
return false;
}

/// <inheritdoc />
public bool Equals(ClosedCaptionPacket other) =>
ReferenceEquals(this, other);

/// <inheritdoc />
public override int GetHashCode()
{
Expand Down
12 changes: 3 additions & 9 deletions Unosquare.FFME.Common/Decoding/PacketBufferState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,10 @@ public bool Equals(PacketBufferState other) =>

/// <inheritdoc />
public override bool Equals(object obj) =>
obj is PacketBufferState && Equals((PacketBufferState)obj);
obj is PacketBufferState state && Equals(state);

/// <inheritdoc />
public override int GetHashCode()
{
return
Length.GetHashCode() ^
Count ^
CountThreshold ^
HasEnoughPackets.GetHashCode();
}
public override int GetHashCode() =>
throw new NotSupportedException($"{nameof(PacketBufferState)} does not support hashing.");
}
}
10 changes: 8 additions & 2 deletions Unosquare.FFME.Common/Engine/MediaBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
/// Reuse blocks as much as possible. Once you create a block from a frame,
/// you don't need the frame anymore so make sure you dispose the frame.
/// </summary>
public abstract class MediaBlock : IComparable<MediaBlock>, IComparable<TimeSpan>, IComparable<long>, IDisposable
public abstract class MediaBlock
: IComparable<MediaBlock>, IComparable<TimeSpan>, IComparable<long>, IEquatable<MediaBlock>, IDisposable
{
private readonly object SyncLock = new object();
private readonly ISyncLocker Locker = SyncLockerFactory.Create(useSlim: true);
Expand Down Expand Up @@ -249,9 +250,14 @@ public override bool Equals(object obj)
return false;
}

/// <inheritdoc />
public bool Equals(MediaBlock other) =>
ReferenceEquals(this, other);

/// <inheritdoc />
public override int GetHashCode() =>
StartTime.Ticks.GetHashCode() ^ m_Buffer.GetHashCode();
StartTime.Ticks.GetHashCode() ^
MediaType.GetHashCode();

/// <inheritdoc />
public void Dispose()
Expand Down
7 changes: 6 additions & 1 deletion Unosquare.FFME.Common/Engine/VideoSeekIndexEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
/// <summary>
/// Represents a seek entry to a position within the stream
/// </summary>
public sealed class VideoSeekIndexEntry : IComparable<VideoSeekIndexEntry>, IComparable<TimeSpan>
public sealed class VideoSeekIndexEntry
: IComparable<VideoSeekIndexEntry>, IComparable<TimeSpan>, IEquatable<VideoSeekIndexEntry>
{
private static readonly char[] CommaSeparator = new[] { ',' };

Expand Down Expand Up @@ -152,6 +153,10 @@ public override bool Equals(object obj)
return false;
}

/// <inheritdoc />
public bool Equals(VideoSeekIndexEntry other) =>
ReferenceEquals(this, other);

/// <inheritdoc />
public override int GetHashCode() =>
PresentationTime.GetHashCode() ^
Expand Down
6 changes: 4 additions & 2 deletions Unosquare.FFME.Windows/Rendering/Wave/DirectSoundPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ public struct DirectSoundBufferPositionNotify : IEquatable<DirectSoundBufferPosi
public IntPtr NotifyHandle;

/// <inheritdoc />
public bool Equals(DirectSoundBufferPositionNotify other) => NotifyHandle == other.NotifyHandle;
public bool Equals(DirectSoundBufferPositionNotify other) =>
NotifyHandle == other.NotifyHandle;

/// <inheritdoc />
public override bool Equals(object obj)
Expand All @@ -666,7 +667,8 @@ public override bool Equals(object obj)
}

/// <inheritdoc />
public override int GetHashCode() => NotifyHandle.GetHashCode();
public override int GetHashCode() =>
throw new NotSupportedException($"{nameof(DirectSoundBufferPositionNotify)} does not support hashing.");
}

// ReSharper disable NotAccessedField.Local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ public override bool Equals(object obj) =>

/// <inheritdoc />
public override int GetHashCode() =>
manufacturerGuid.GetHashCode() ^
productGuid.GetHashCode() ^
driverVersion ^
channels;
throw new NotSupportedException($"{nameof(LegacyAudioDeviceInfo)} does not support hashing.");

/// <summary>
/// Checks to see if a given SupportedWaveFormat is supported
Expand Down
6 changes: 1 addition & 5 deletions Unosquare.FFME.Windows/Rendering/Wave/MmTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ public override bool Equals(object obj) =>

/// <inheritdoc />
public override int GetHashCode() =>
Type.GetHashCode() ^
Ms.GetHashCode() ^
Sample.GetHashCode() ^
CB.GetHashCode() ^
Ticks.GetHashCode();
throw new NotSupportedException($"{nameof(MmTime)} does not support hashing.");
}
}

0 comments on commit b546ade

Please sign in to comment.