diff --git a/Source/Utilities/Audio/AudioLoader.cs b/Source/Utilities/Audio/AudioReader.cs similarity index 82% rename from Source/Utilities/Audio/AudioLoader.cs rename to Source/Utilities/Audio/AudioReader.cs index 09baf18b..83c7dcbd 100644 --- a/Source/Utilities/Audio/AudioLoader.cs +++ b/Source/Utilities/Audio/AudioReader.cs @@ -17,62 +17,62 @@ namespace OpenTK.Audio /// Encapsulates a sound stream and provides decoding and streaming capabilities. /// /// - public class AudioLoader : IDisposable + public class AudioReader : IDisposable { static object reader_lock = new object(); - static List readers = new List(); + static List readers = new List(); bool disposed; Stream stream; - AudioLoader implementation; + AudioReader implementation; #region --- Constructors --- - #region static AudioLoader() + #region static AudioReader() - static AudioLoader() + static AudioReader() { - // TODO: Plugin architecture for sound formats. This is overkill now that we only have a WaveLoader (future proofing). - readers.Add(new WaveLoader()); + // TODO: Plugin architecture for sound formats. This is overkill now that we only have a WaveReader (future proofing). + readers.Add(new WaveReader()); } #endregion - #region protected AudioLoader() + #region protected AudioReader() - protected AudioLoader() { } + protected AudioReader() { } #endregion - #region public AudioLoader(string filename) + #region public AudioReader(string filename) - /// Creates a new AudioLoader that can read the specified sound file. + /// Creates a new AudioReader that can read the specified sound file. /// The path to the sound file. - /// A new OpenTK.Audio.AudioLoader, which can be used to read from the specified sound file. - public AudioLoader(string filename) + /// A new OpenTK.Audio.AudioReader, which can be used to read from the specified sound file. + public AudioReader(string filename) : this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { } #endregion - #region public AudioLoader(Stream s) + #region public AudioReader(Stream s) - /// Creates a new AudioLoader that can read the specified soundstream. + /// Creates a new AudioReader that can read the specified soundstream. /// The System.IO.Stream to read from. - /// A new OpenTK.Audio.AudioLoader, which can be used to read from the specified sound stream. - public AudioLoader(Stream s) + /// A new OpenTK.Audio.AudioReader, which can be used to read from the specified sound stream. + public AudioReader(Stream s) { try { lock (reader_lock) { - foreach (AudioLoader reader in readers) + foreach (AudioReader reader in readers) { long pos = s.Position; if (reader.Supports(s)) { s.Position = pos; - implementation = (AudioLoader) + implementation = (AudioReader) reader.GetType().GetConstructor( System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, @@ -198,7 +198,7 @@ namespace OpenTK.Audio #region IDisposable Members - /// Closes the underlying Stream and disposes of the AudioLoader resources. + /// Closes the underlying Stream and disposes of the AudioReader resources. public virtual void Dispose() { this.Dispose(true); @@ -217,7 +217,7 @@ namespace OpenTK.Audio } } - ~AudioLoader() + ~AudioReader() { this.Dispose(false); } diff --git a/Source/Utilities/Audio/AudioLoaderException.cs b/Source/Utilities/Audio/AudioReaderException.cs similarity index 58% rename from Source/Utilities/Audio/AudioLoaderException.cs rename to Source/Utilities/Audio/AudioReaderException.cs index 80b769cf..66f3bdfc 100644 --- a/Source/Utilities/Audio/AudioLoaderException.cs +++ b/Source/Utilities/Audio/AudioReaderException.cs @@ -12,13 +12,13 @@ using System.Text; namespace OpenTK.Audio { - /// Represents exceptions related to OpenTK.Audio.AudioLoader objects. - public class AudioLoaderException : AudioException + /// Represents exceptions related to OpenTK.Audio.AudioReader objects. + public class AudioReaderException : AudioException { - /// Constructs a new AudioLoaderException. - public AudioLoaderException() : base() { } - /// Constructs a new AudioLoaderException with the specified error message. - /// The error message of the AudioLoaderException. - public AudioLoaderException(string message) : base(message) { } + /// Constructs a new AudioReaderException. + public AudioReaderException() : base() { } + /// Constructs a new AudioReaderException with the specified error message. + /// The error message of the AudioReaderException. + public AudioReaderException(string message) : base(message) { } } } diff --git a/Source/Utilities/Audio/WaveLoader.cs b/Source/Utilities/Audio/WaveReader.cs similarity index 94% rename from Source/Utilities/Audio/WaveLoader.cs rename to Source/Utilities/Audio/WaveReader.cs index 800a48dc..ce5f5230 100644 --- a/Source/Utilities/Audio/WaveLoader.cs +++ b/Source/Utilities/Audio/WaveReader.cs @@ -15,7 +15,7 @@ using System.Runtime.InteropServices; namespace OpenTK.Audio { - internal sealed class WaveLoader : AudioLoader + internal sealed class WaveReader : AudioReader { SoundData decoded_data; @@ -40,9 +40,9 @@ namespace OpenTK.Audio BinaryReader reader; - internal WaveLoader() { } + internal WaveReader() { } - internal WaveLoader(Stream s) + internal WaveReader(Stream s) { if (s == null) throw new ArgumentNullException(); if (!s.CanRead) throw new ArgumentException("Cannot read from specified Stream."); @@ -191,7 +191,7 @@ namespace OpenTK.Audio //return new SoundData(decoded_data, new SoundFormat(channels, bits_per_sample, sample_rate)); return decoded_data; } - catch (AudioLoaderException e) + catch (AudioReaderException e) { reader.Close(); throw; @@ -211,7 +211,7 @@ namespace OpenTK.Audio { base.Stream = value; if (!ReadHeaders(reader)) - throw new AudioLoaderException("Invalid WAVE/RIFF file: invalid or corrupt signature."); + throw new AudioReaderException("Invalid WAVE/RIFF file: invalid or corrupt signature."); Debug.Write(String.Format("Opened WAVE/RIFF file: ({0}, {1}, {2}, {3}) ", sample_rate.ToString(), bits_per_sample.ToString(), channels.ToString(), audio_format.ToString()));