cleanup
This commit is contained in:
parent
0e73372c23
commit
5015b6ad95
@ -87,7 +87,6 @@ namespace NadekoBot.DataStructures
|
||||
ReadPos = secondRead;
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Readpos: {0} WritePos: {1}", ReadPos, WritePos);
|
||||
return toRead;
|
||||
}
|
||||
finally
|
||||
@ -99,12 +98,14 @@ namespace NadekoBot.DataStructures
|
||||
public Task WriteAsync(byte[] b, int offset, int toWrite, CancellationToken cancelToken) => Task.Run(async () =>
|
||||
{
|
||||
while (toWrite > RemainingCapacity)
|
||||
await Task.Delay(50, cancelToken);
|
||||
await Task.Delay(1000, cancelToken); // wait a lot, buffer should be large anyway
|
||||
|
||||
if (toWrite == 0)
|
||||
return;
|
||||
|
||||
await _locker.WaitAsync(cancelToken);
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Writing {0}", toWrite);
|
||||
if (WritePos < ReadPos)
|
||||
{
|
||||
Buffer.BlockCopy(b, offset, buffer, WritePos, toWrite);
|
||||
@ -130,8 +131,6 @@ namespace NadekoBot.DataStructures
|
||||
WritePos = 0;
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Readpos: {0} WritePos: {1} ({2})", ReadPos, WritePos, ReadPos - WritePos);
|
||||
return toWrite;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Services;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@ -19,9 +20,11 @@ namespace NadekoBot.DataStructures
|
||||
private readonly ConcurrentDictionary<DapiSearchType, SemaphoreSlim> _locks = new ConcurrentDictionary<DapiSearchType, SemaphoreSlim>();
|
||||
|
||||
private readonly SortedSet<ImageCacherObject> _cache;
|
||||
private readonly Logger _log;
|
||||
|
||||
public SearchImageCacher()
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
_rng = new NadekoRandom();
|
||||
_cache = new SortedSet<ImageCacherObject>();
|
||||
}
|
||||
@ -85,7 +88,7 @@ namespace NadekoBot.DataStructures
|
||||
|
||||
public async Task<ImageCacherObject[]> DownloadImages(string tag, bool isExplicit, DapiSearchType type)
|
||||
{
|
||||
Console.WriteLine($"Loading extra images from {type}");
|
||||
_log.Info($"Loading extra images from {type}");
|
||||
tag = tag?.Replace(" ", "_").ToLowerInvariant();
|
||||
if (isExplicit)
|
||||
tag = "rating%3Aexplicit+" + tag;
|
||||
|
@ -136,7 +136,6 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
await ReplyErrorLocalized("rar_err").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,6 @@ namespace NadekoBot.Modules.Searches
|
||||
// .FirstOrDefault(jt => jt["role"].ToString() == role)?["general"];
|
||||
// if (general == null)
|
||||
// {
|
||||
// //Console.WriteLine("General is null.");
|
||||
// return;
|
||||
// }
|
||||
// //get build data for this role
|
||||
@ -309,7 +308,6 @@ namespace NadekoBot.Modules.Searches
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// //Console.WriteLine(ex);
|
||||
// await channel.SendMessageAsync("💢 Failed retreiving data for that champion.").ConfigureAwait(false);
|
||||
// }
|
||||
// });
|
||||
|
@ -352,7 +352,7 @@ namespace NadekoBot
|
||||
#if GLOBAL_NADEKO
|
||||
isPublicNadeko = true;
|
||||
#endif
|
||||
//Console.WriteLine(string.Join(", ", CommandService.Commands
|
||||
//_log.Info(string.Join(", ", CommandService.Commands
|
||||
// .Distinct(x => x.Name + x.Module.Name)
|
||||
// .SelectMany(x => x.Aliases)
|
||||
// .GroupBy(x => x)
|
||||
|
@ -78,13 +78,9 @@ namespace NadekoBot.Services.Music
|
||||
}
|
||||
try
|
||||
{
|
||||
_log.Info("Checking for songs");
|
||||
if (data.Song == null)
|
||||
continue;
|
||||
|
||||
_log.Info("Connecting");
|
||||
|
||||
|
||||
_log.Info("Starting");
|
||||
using (var b = new SongBuffer(data.Song.Uri, ""))
|
||||
{
|
||||
@ -117,7 +113,6 @@ namespace NadekoBot.Services.Music
|
||||
|
||||
await (pauseTaskSource?.Task ?? Task.CompletedTask);
|
||||
}
|
||||
_log.Info(">>>>>>>>>READ 0<<<<<<<<<<");
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -172,7 +172,6 @@ namespace NadekoBot.Services.Music
|
||||
// while (!cancelToken.IsCancellationRequested && //song canceled for whatever reason
|
||||
// !(MusicPlayer.MaxPlaytimeSeconds != 0 && CurrentTime.TotalSeconds >= MusicPlayer.MaxPlaytimeSeconds)) // or exceedded max playtime
|
||||
// {
|
||||
// //Console.WriteLine($"Read: {songBuffer.ReadPosition}\nWrite: {songBuffer.WritePosition}\nContentLength:{songBuffer.ContentLength}\n---------");
|
||||
// var read = await inStream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
|
||||
// //await inStream.CopyToAsync(voiceClient.OutputStream);
|
||||
// if (read < _frameBytes)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NadekoBot.DataStructures;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
@ -14,11 +15,13 @@ namespace NadekoBot.Services.Music
|
||||
private PoopyRingBuffer _outStream = new PoopyRingBuffer();
|
||||
|
||||
private readonly SemaphoreSlim _lock = new SemaphoreSlim(1, 1);
|
||||
private readonly Logger _log;
|
||||
|
||||
public string SongUri { get; private set; }
|
||||
|
||||
public SongBuffer(string songUri, string skipTo)
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
this.SongUri = songUri;
|
||||
|
||||
this.p = Process.Start(new ProcessStartInfo
|
||||
@ -48,34 +51,31 @@ namespace NadekoBot.Services.Music
|
||||
int bytesRead = -1;
|
||||
while (!cancelToken.IsCancellationRequested && bytesRead != 0)
|
||||
{
|
||||
var toRead = buffer.Length;
|
||||
//var remCap = _outStream.RemainingCapacity;
|
||||
//if (remCap < readSize)
|
||||
//{
|
||||
// if (_outStream.RemainingCapacity == 0)
|
||||
// {
|
||||
// Console.WriteLine("Buffer full, not gonnna read from ffmpeg");
|
||||
// await Task.Delay(20);
|
||||
// continue;
|
||||
// }
|
||||
// toRead = remCap;
|
||||
//}
|
||||
|
||||
bytesRead = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, toRead, cancelToken).ConfigureAwait(false);
|
||||
bytesRead = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, readSize, cancelToken).ConfigureAwait(false);
|
||||
await _outStream.WriteAsync(buffer, 0, bytesRead, cancelToken);
|
||||
|
||||
if (_outStream.RemainingCapacity < _outStream.Capacity * 0.9f)
|
||||
if (_outStream.RemainingCapacity < _outStream.Capacity * 0.5f)
|
||||
if (toReturn.TrySetResult(true))
|
||||
Console.WriteLine("Prebuffering finished");
|
||||
_log.Info("Prebuffering finished");
|
||||
}
|
||||
Console.WriteLine("FFMPEG killed or song canceled");
|
||||
_log.Info("FFMPEG killed, song canceled, or song fully downloaded");
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
{
|
||||
_log.Error(@"You have not properly installed or configured FFMPEG.
|
||||
Please install and configure FFMPEG to play music.
|
||||
Check the guides for your platform on how to setup ffmpeg correctly:
|
||||
Windows Guide: https://goo.gl/OjKk8F
|
||||
Linux Guide: https://goo.gl/ShjCUo");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
_log.Info(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (toReturn.TrySetResult(false))
|
||||
Console.WriteLine("Prebuffering failed");
|
||||
//ignored
|
||||
_log.Info("Prebuffering failed");
|
||||
}
|
||||
}, cancelToken);
|
||||
|
||||
@ -89,7 +89,6 @@ namespace NadekoBot.Services.Music
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Console.WriteLine("DISPOSING");
|
||||
try { this.p.Kill(); }
|
||||
catch { }
|
||||
_outStream.Dispose();
|
||||
@ -203,7 +202,6 @@ namespace NadekoBot.Services.Music
|
||||
// {
|
||||
// if (outStream != null)
|
||||
// outStream.Dispose();
|
||||
// Console.WriteLine($"Buffering done.");
|
||||
// if (p != null)
|
||||
// {
|
||||
// try
|
||||
|
Loading…
Reference in New Issue
Block a user