Migrate to C#12

This commit is contained in:
copecone committed 2026-10-22 11:54:26 +09:00
1 parent 7eaf4f48e6
commit 98d31404cc
24 files changed
+42 -42

No files matched your search

+2 -2
View File
@@ -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);
-2
View File
@@ -1,5 +1,3 @@
using System;
namespace ADOFAIRenderer.Util.Audio;
/// <summary>
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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];
+1
View File
@@ -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);
+1
View File
@@ -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 -1
View File
@@ -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>
+1
View File
@@ -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;
+2 -2
View File
@@ -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;
}
+1 -1
View File
@@ -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);
}