mirror of https://github.com/ppy/osu
Use TagLib instead of ManagedBass
This commit is contained in:
parent
f0cd18a721
commit
8f093b9a11
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace osu.Game.IO.FileAbstraction
|
||||||
|
{
|
||||||
|
public class StreamFileAbstraction : TagLib.File.IFileAbstraction
|
||||||
|
{
|
||||||
|
public StreamFileAbstraction(string filename, Stream fileStream)
|
||||||
|
{
|
||||||
|
ReadStream = fileStream;
|
||||||
|
Name = filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
public Stream ReadStream { get; }
|
||||||
|
public Stream WriteStream => ReadStream;
|
||||||
|
|
||||||
|
public void CloseStream(Stream aStream)
|
||||||
|
{
|
||||||
|
aStream.Position = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using ManagedBass;
|
using osu.Game.IO.FileAbstraction;
|
||||||
using osu.Framework.Audio.Callbacks;
|
|
||||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
|
|
||||||
|
@ -52,9 +51,27 @@ public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream data = context.WorkingBeatmap.GetStream(storagePath);
|
Stream data = context.WorkingBeatmap.GetStream(storagePath);
|
||||||
var fileCallbacks = new FileCallbacks(new DataStreamFileProcedures(data));
|
StreamFileAbstraction fileAbstraction = new StreamFileAbstraction(filename, data);
|
||||||
int decodeStream = Bass.CreateStream(StreamSystem.NoBuffer, BassFlags.Decode, fileCallbacks.Callbacks, fileCallbacks.Handle);
|
|
||||||
if (decodeStream == 0)
|
// We use TagLib here for platform invariance; BASS cannot detect audio presence on Linux.
|
||||||
|
TagLib.File tagFile = null;
|
||||||
|
string errorReason = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tagFile = TagLib.File.Create(fileAbstraction);
|
||||||
|
}
|
||||||
|
catch (TagLib.CorruptFileException) { errorReason = "Corrupt file"; }
|
||||||
|
catch (TagLib.UnsupportedFormatException) { errorReason = "Unsupported format"; }
|
||||||
|
|
||||||
|
if (errorReason != null)
|
||||||
|
{
|
||||||
|
yield return new IssueTemplateFileError(this).Create(filename, errorReason);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tagFile.Properties.AudioChannels == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
yield return new IssueTemplateHasAudioTrack(this).Create(filename);
|
yield return new IssueTemplateHasAudioTrack(this).Create(filename);
|
||||||
|
|
|
@ -42,5 +42,6 @@
|
||||||
<PackageReference Include="SharpCompress" Version="0.28.3" />
|
<PackageReference Include="SharpCompress" Version="0.28.3" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
|
<PackageReference Include="TagLibSharp" Version="2.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in New Issue