@@ -19,42 +19,41 @@ public static class AudioCheckUtils
1919 /// Gets the audio format (ChannelType) from a stream using BASS.
2020 /// </summary>
2121 /// <param name="data">The audio file stream.</param>
22- /// <returns>The ChannelType of the audio, or 0 if detection fails.</returns>
22+ /// <returns>The ChannelType of the audio, or <see cref="ChannelType.Unknown"/> if detection fails.</returns>
2323 public static ChannelType GetAudioFormat ( Stream data )
2424 {
2525 if ( data . Length <= 0 )
26- return 0 ;
26+ return ChannelType . Unknown ;
2727
28- var fileCallbacks = new FileCallbacks ( new DataStreamFileProcedures ( data ) ) ;
29- int decodeStream = Bass . CreateStream ( StreamSystem . NoBuffer , BassFlags . Decode , fileCallbacks . Callbacks , fileCallbacks . Handle ) ;
30-
31- if ( decodeStream == 0 )
32- return 0 ;
28+ using ( var fileCallbacks = new FileCallbacks ( new DataStreamFileProcedures ( data ) ) )
29+ {
30+ int decodeStream = Bass . CreateStream ( StreamSystem . NoBuffer , BassFlags . Decode , fileCallbacks . Callbacks , fileCallbacks . Handle ) ;
31+ if ( decodeStream == 0 )
32+ return ChannelType . Unknown ;
3333
34- var audioInfo = Bass . ChannelGetInfo ( decodeStream ) ;
35- Bass . StreamFree ( decodeStream ) ;
34+ var audioInfo = Bass . ChannelGetInfo ( decodeStream ) ;
35+ Bass . StreamFree ( decodeStream ) ;
3636
37- return audioInfo . ChannelType ;
37+ return audioInfo . ChannelType ;
38+ }
3839 }
3940
4041 /// <summary>
4142 /// Gets the audio format for a specific file in a beatmapset.
4243 /// </summary>
4344 /// <param name="context">The beatmap verifier context.</param>
4445 /// <param name="filename">The filename to check.</param>
45- /// <returns>The ChannelType of the audio file, or 0 if detection fails.</returns>
46+ /// <returns>The ChannelType of the audio file, or <see cref="ChannelType.Unknown"/> if detection fails.</returns>
4647 public static ChannelType GetAudioFormatFromFile ( BeatmapVerifierContext context , string filename )
4748 {
4849 var beatmapSet = context . Beatmap . BeatmapInfo . BeatmapSet ;
4950 var audioFile = beatmapSet ? . GetFile ( filename ) ;
5051
5152 if ( beatmapSet == null || audioFile == null )
52- return 0 ;
53+ return ChannelType . Unknown ;
5354
5455 using ( Stream data = context . WorkingBeatmap . GetStream ( audioFile . File . GetStoragePath ( ) ) )
55- {
5656 return GetAudioFormat ( data ) ;
57- }
5857 }
5958 }
6059}
0 commit comments