mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
Updated editorconfig to (mostly?) require braces around if/else statements, and applied the new formatting rules
This commit is contained in:
@@ -54,7 +54,7 @@ public sealed class MusicPlayer : IMusicPlayer
|
||||
|
||||
_songBuffer = new PoopyBufferImmortalized(_vc.InputLength);
|
||||
|
||||
_thread = new(async() =>
|
||||
_thread = new(async () =>
|
||||
{
|
||||
await PlayLoop();
|
||||
});
|
||||
@@ -282,7 +282,8 @@ public sealed class MusicPlayer : IMusicPlayer
|
||||
var data = sb.Read(vc.InputLength, out var length);
|
||||
|
||||
// if nothing is read from the buffer, song is finished
|
||||
if (data.Length == 0) return null;
|
||||
if (data.Length == 0)
|
||||
return null;
|
||||
|
||||
_adjustVolume(data, Volume);
|
||||
return _proxy.SendPcmFrame(vc, data, length);
|
||||
@@ -325,7 +326,8 @@ public sealed class MusicPlayer : IMusicPlayer
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static void AdjustVolumeInt16(Span<byte> audioSamples, float volume)
|
||||
{
|
||||
if (Math.Abs(volume - 1f) < 0.0001f) return;
|
||||
if (Math.Abs(volume - 1f) < 0.0001f)
|
||||
return;
|
||||
|
||||
var samples = MemoryMarshal.Cast<byte, short>(audioSamples);
|
||||
|
||||
@@ -339,7 +341,8 @@ public sealed class MusicPlayer : IMusicPlayer
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static void AdjustVolumeFloat32(Span<byte> audioSamples, float volume)
|
||||
{
|
||||
if (Math.Abs(volume - 1f) < 0.0001f) return;
|
||||
if (Math.Abs(volume - 1f) < 0.0001f)
|
||||
return;
|
||||
|
||||
var samples = MemoryMarshal.Cast<byte, float>(audioSamples);
|
||||
|
||||
|
@@ -87,7 +87,8 @@ public sealed partial class MusicQueue : IMusicQueue
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (tracks.Count == 0) return Enqueue(trackInfo, queuer, out trackIndex);
|
||||
if (tracks.Count == 0)
|
||||
return Enqueue(trackInfo, queuer, out trackIndex);
|
||||
|
||||
var currentNode = tracks.First!;
|
||||
int i;
|
||||
@@ -165,7 +166,8 @@ public sealed partial class MusicQueue : IMusicQueue
|
||||
{
|
||||
var removedNode = tracks.First!;
|
||||
int i;
|
||||
for (i = 0; i < remoteAtIndex; i++) removedNode = removedNode.Next!;
|
||||
for (i = 0; i < remoteAtIndex; i++)
|
||||
removedNode = removedNode.Next!;
|
||||
|
||||
trackInfo = removedNode.Value;
|
||||
tracks.Remove(removedNode);
|
||||
@@ -303,7 +305,8 @@ public sealed partial class MusicQueue : IMusicQueue
|
||||
if (remoteAt < 0 || remoteAt >= tracks.Count)
|
||||
return false;
|
||||
|
||||
if (remoteAt == index) isCurrent = true;
|
||||
if (remoteAt == index)
|
||||
isCurrent = true;
|
||||
|
||||
RemoveAtInternal(remoteAt, out trackInfo);
|
||||
|
||||
|
@@ -35,7 +35,8 @@ public sealed class VoiceProxy : IVoiceProxy
|
||||
try
|
||||
{
|
||||
var gw = gateway;
|
||||
if (gw is null || gw.Stopped || !gw.Started) return false;
|
||||
if (gw is null || gw.Stopped || !gw.Started)
|
||||
return false;
|
||||
|
||||
vc.SendPcmFrame(gw, data, 0, length);
|
||||
return true;
|
||||
@@ -51,7 +52,8 @@ public sealed class VoiceProxy : IVoiceProxy
|
||||
var errorCount = 0;
|
||||
do
|
||||
{
|
||||
if (State == VoiceProxyState.Stopped) break;
|
||||
if (State == VoiceProxyState.Stopped)
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -43,7 +43,8 @@ public sealed class LocalTrackResolver : ILocalTrackResolver
|
||||
.Where(x =>
|
||||
{
|
||||
if (!x.Attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System)
|
||||
&& _musicExtensions.Contains(x.Extension.ToUpperInvariant())) return true;
|
||||
&& _musicExtensions.Contains(x.Extension.ToUpperInvariant()))
|
||||
return true;
|
||||
return false;
|
||||
})
|
||||
.ToList();
|
||||
|
@@ -27,14 +27,16 @@ public sealed class SoundcloudResolver : ISoundcloudResolver
|
||||
using var http = _httpFactory.CreateClient();
|
||||
var responseString = await http.GetStringAsync($"https://scapi.nadeko.bot/resolve?url={playlist}");
|
||||
var scvids = JObject.Parse(responseString)["tracks"]?.ToObject<SoundCloudVideo[]>();
|
||||
if (scvids is null) yield break;
|
||||
if (scvids is null)
|
||||
yield break;
|
||||
|
||||
foreach (var videosChunk in scvids.Where(x => x.Streamable is true).Chunk(5))
|
||||
{
|
||||
var cachableTracks = videosChunk.Select(VideoModelToCachedData).ToList();
|
||||
|
||||
await cachableTracks.Select(_trackCacher.CacheTrackDataAsync).WhenAll();
|
||||
foreach (var info in cachableTracks.Select(CachableDataToTrackInfo)) yield return info;
|
||||
foreach (var info in cachableTracks.Select(CachableDataToTrackInfo))
|
||||
yield return info;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user