This fixes an issue identified with the WASAPI implementation in
https://github.com/ppy/osu-framework/pull/6088. It has no real effect
on current `master`, but fixes a deadlock that occurs with the
aforementioned framework branch when one lets a preview track play out
to the end - at this point all audio will stop and an attempt to perform
any synchronous BASS operation (playing another track, seeking) will
result in a deadlock.
It isn't terribly clear as to why this is happening precisely, but
there does not appear to be any need to stop and seek at that point,
so this feels like a decent workaround even if the actual issue is
upstream (and will unblock pushing out WASAPI support to users).
This paves the way for the framework code quality change
(https://github.com/ppy/osu-framework/pull/4873) which stops exposing
the constructor.
Most of the restructuring here is required to give `PreviewTrackManager`
an adjustable target to apply the global mute.
The previous implementation of `SampleInfo`'s equality members was not
completely correct in its treatment of the `sampleNames` array. While
`Equals()` compared the values of `sampleNames` using `SequenceEqual()`,
therefore performing a structural check that inspects the contents of
both arrays, `GetHashCode()` used `HashCode.Combine()` directly on the
arrays, therefore operating on reference equality. This could cause the
pooling mechanism of samples to fail, as pointed out in #11079.
To resolve, change the `GetHashCode()` implementation such that it also
considers the contents of the array rather than just the reference to
the array itself. This is achieved by leveraging
`StructuralEqualityComparer`.
Additionally, as a bonus, an array sort was added to the constructor of
`SampleInfo`. This is intended to be a "canonicalisation" processing
step for the array of sample names. Thanks to that sort, two instances
of `SampleInfo` that have the same sample names but permutated will also
turn out to be equal and have the same hash codes, given the
implementation of both equality members. This gives `SampleInfo`
set-like semantics.