Skip to content

Commit

Permalink
Merge pull request #1218 from b-editor/implement-gethashcode-for-medi…
Browse files Browse the repository at this point in the history
…a-sources

feat: implement GetHashCode for VideoSource, SoundSource, and BitmapSource
  • Loading branch information
yuto-trd authored Dec 28, 2024
2 parents 4a57d3f + f848398 commit c5edf55
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Beutl.Engine/Media/Source/BitmapSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@ public override bool Equals(object? obj)
&& !IsDisposed && !source.IsDisposed
&& ReferenceEquals(_bitmap.Value, source._bitmap.Value);
}

public override int GetHashCode()
{
// ReSharper disable once NonReadonlyMemberInGetHashCode
return HashCode.Combine(!IsDisposed ? _bitmap.Value : null);
}
}
6 changes: 6 additions & 0 deletions src/Beutl.Engine/Media/Source/SoundSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ public override bool Equals(object? obj)
&& ReferenceEquals(_mediaReader.Value, source._mediaReader.Value);
}

public override int GetHashCode()
{
// ReSharper disable once NonReadonlyMemberInGetHashCode
return HashCode.Combine(!IsDisposed ? _mediaReader.Value : null);
}

private int ToSamples(TimeSpan timeSpan)
{
return (int)(timeSpan.TotalSeconds * SampleRate);
Expand Down
6 changes: 6 additions & 0 deletions src/Beutl.Engine/Media/Source/VideoSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public override bool Equals(object? obj)
&& ReferenceEquals(_mediaReader.Value, source._mediaReader.Value);
}

public override int GetHashCode()
{
// ReSharper disable once NonReadonlyMemberInGetHashCode
return HashCode.Combine(!IsDisposed ? _mediaReader.Value : null);
}

IVideoSource IVideoSource.Clone() => Clone();

IMediaSource IMediaSource.Clone() => Clone();
Expand Down

0 comments on commit c5edf55

Please sign in to comment.