SHA256
Migrate to C#12
This commit is contained in:
24 files changed
+42
-42
No files matched your search
@@ -75,7 +75,7 @@ internal static class AudioSpectrumGenerator
|
||||
_store = _ownStore;
|
||||
}
|
||||
|
||||
_source = AudioClipResolver.GetOrAdd(_store, clip!.name, clip);
|
||||
_source = AudioClipResolver.GetOrAdd(_store, clip.name, clip);
|
||||
if (_source == null)
|
||||
{
|
||||
Melon<RenderMod>.Logger.Error($"[AudioSpectrumGenerator] Song clip '{clip.name}' could not be loaded, the spectrum will be empty.");
|
||||
@@ -125,7 +125,7 @@ internal static class AudioSpectrumGenerator
|
||||
{
|
||||
var n = samples.Length;
|
||||
var conductor = scrConductor.instance;
|
||||
if (_source == null || _store == null || !conductor || !conductor!.hasSongStarted || !conductor.song
|
||||
if (_source == null || _store == null || !conductor || !conductor.hasSongStarted || !conductor.song
|
||||
|| n == 0 || (n & (n - 1)) != 0)
|
||||
{
|
||||
Array.Clear(samples, 0, n);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using System;
|
||||
|
||||
namespace ADOFAIRenderer.Util.Audio;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -54,7 +54,7 @@ internal static class AudioClipResolver
|
||||
}
|
||||
|
||||
if (!clip) return store.GetOrAdd(key, () => null);
|
||||
return store.GetOrAdd(key, () => UnityClipLoader.Load(clip!, store));
|
||||
return store.GetOrAdd(key, () => UnityClipLoader.Load(clip, store));
|
||||
}
|
||||
|
||||
/// <summary>Opens <paramref name="path"/> with FFmpeg; mono MP3 files are wrapped in <see cref="MP3MonoLayoutReader"/> (game layout).</summary>
|
||||
|
||||
@@ -198,7 +198,7 @@ internal sealed class AudioClipStore : IDisposable
|
||||
// same key meanwhile, its entry wins and this source is discarded.
|
||||
lock (_sources)
|
||||
{
|
||||
if (_disposed || _sources.TryGetValue(key, out var raced))
|
||||
if (_disposed || _sources.TryGetValue(key, out _))
|
||||
{
|
||||
source?.DisposeInternal();
|
||||
return _disposed ? null : _sources[key];
|
||||
|
||||
@@ -196,6 +196,7 @@ internal sealed class DecodeStream : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>Greatest common divisor of two positive integers (Euclid).</summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static int GCD(int a, int b)
|
||||
{
|
||||
while (b != 0) (a, b) = (b, a % b);
|
||||
|
||||
@@ -81,6 +81,7 @@ internal sealed unsafe class FFmpegPCMReader : IPCMReader
|
||||
public long Position { get; private set; }
|
||||
|
||||
/// <summary>True when the stream is MP3 and is decoded with the game's MP3 timing (see class summary).</summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public bool IsMP3 { get; }
|
||||
|
||||
/// <summary>Number of demuxer seeks performed (for diagnostics).</summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ADOFAIRenderer.Util.Audio.Clip;
|
||||
@@ -20,6 +19,7 @@ namespace ADOFAIRenderer.Util.Audio.Clip;
|
||||
/// - Samples per frame: Layer I 384, Layer II 1152, Layer III 1152 (MPEG-1) or 576 (MPEG-2/2.5).
|
||||
/// - ID3v2 tags before the first frame: "ID3", version (2 bytes), flags (bit 0x10 = 10-byte footer), size (4 bytes, 7 bits each).
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
internal static class MP3HeaderFrame
|
||||
{
|
||||
/// <summary>Bytes searched for the first frame sync after the ID3v2 tags.</summary>
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace ADOFAIRenderer.Util.Audio.Clip;
|
||||
/// Output: 1 channel at the inner reader's sample rate. Frame 2k is inner frame k, frame 2k + 1 is 0.
|
||||
/// <see cref="TotalFrames"/> = 2 * inner TotalFrames.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
internal sealed class MP3MonoLayoutReader : IPCMReader
|
||||
{
|
||||
private readonly IPCMReader _inner;
|
||||
|
||||
@@ -164,7 +164,7 @@ internal sealed class OfflineAudioMixer : IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
_bgmKey = clip!.name;
|
||||
_bgmKey = clip.name;
|
||||
_bgmSource = AudioClipResolver.GetOrAdd(_store, _bgmKey, clip);
|
||||
if (_bgmSource == null)
|
||||
{
|
||||
@@ -268,7 +268,7 @@ internal sealed class OfflineAudioMixer : IDisposable
|
||||
|
||||
var state = new SourceState(voice, Math.Max(startTime, now), pitch, loop, loop ? endTime : double.PositiveInfinity,
|
||||
clipSource?.Duration ?? 0.0, _sampleRate);
|
||||
if (source) MapSource(source!, state);
|
||||
if (source) MapSource(source, state);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ internal sealed class SourceState
|
||||
public void BindClip(AudioClip? clip)
|
||||
{
|
||||
if (!clip) return;
|
||||
_length = clip!.length;
|
||||
_length = clip.length;
|
||||
_frequency = Math.Max(1, clip.frequency);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,14 +107,13 @@ internal sealed class VideoEncoder : IEquatable<VideoEncoder>
|
||||
/// (for the families the codec has); GPUUtil.GetPrioritizedEncoders keeps this order for the encoders that do not
|
||||
/// belong to the active GPU vendor.
|
||||
/// </summary>
|
||||
public static readonly IReadOnlyList<VideoEncoder> All = new[]
|
||||
{
|
||||
public static readonly IReadOnlyList<VideoEncoder> All = [
|
||||
H264_NVENC, H264_QSV, H264_AMF, H264_VideoToolbox, Libx264,
|
||||
HEVC_NVENC, HEVC_QSV, HEVC_AMF, HEVC_VideoToolbox, Libx265,
|
||||
VP9_NVENC, VP9_QSV, LibvpxVP9,
|
||||
AV1_NVENC, AV1_QSV, AV1_AMF, LibSvtAv1, LibAomAv1,
|
||||
LibVvenc
|
||||
};
|
||||
];
|
||||
|
||||
/// <summary>Lookup table of <see cref="All"/> by <see cref="Name"/> (case-insensitive), used by <see cref="FromName"/>.</summary>
|
||||
private static readonly Dictionary<string, VideoEncoder> ByName =
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using O5Kit.Control;
|
||||
using O5Kit.Core;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ADOFAIRenderer.Util.UI;
|
||||
|
||||
|
||||
Reference in new issue
Block a user