Renamed AudioLoader and WaveLoader to AudioReader and WaveReader.

This commit is contained in:
the_fiddler 2008-04-06 14:32:59 +00:00
parent c587cc5189
commit eee67d64b5
3 changed files with 33 additions and 33 deletions

View file

@ -17,62 +17,62 @@ namespace OpenTK.Audio
/// Encapsulates a sound stream and provides decoding and streaming capabilities.
/// </summary>
/// <typeparam name="SampleType"></typeparam>
public class AudioLoader : IDisposable
public class AudioReader : IDisposable
{
static object reader_lock = new object();
static List<AudioLoader> readers = new List<AudioLoader>();
static List<AudioReader> readers = new List<AudioReader>();
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)
/// <summary>Creates a new AudioLoader that can read the specified sound file.</summary>
/// <summary>Creates a new AudioReader that can read the specified sound file.</summary>
/// <param name="filename">The path to the sound file.</param>
/// <returns>A new OpenTK.Audio.AudioLoader, which can be used to read from the specified sound file.</returns>
public AudioLoader(string filename)
/// <returns>A new OpenTK.Audio.AudioReader, which can be used to read from the specified sound file.</returns>
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)
/// <summary>Creates a new AudioLoader that can read the specified soundstream.</summary>
/// <summary>Creates a new AudioReader that can read the specified soundstream.</summary>
/// <param name="s">The System.IO.Stream to read from.</param>
/// <returns>A new OpenTK.Audio.AudioLoader, which can be used to read from the specified sound stream.</returns>
public AudioLoader(Stream s)
/// <returns>A new OpenTK.Audio.AudioReader, which can be used to read from the specified sound stream.</returns>
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
/// <summary>Closes the underlying Stream and disposes of the AudioLoader resources.</summary>
/// <summary>Closes the underlying Stream and disposes of the AudioReader resources.</summary>
public virtual void Dispose()
{
this.Dispose(true);
@ -217,7 +217,7 @@ namespace OpenTK.Audio
}
}
~AudioLoader()
~AudioReader()
{
this.Dispose(false);
}

View file

@ -12,13 +12,13 @@ using System.Text;
namespace OpenTK.Audio
{
/// <summary>Represents exceptions related to OpenTK.Audio.AudioLoader objects.</summary>
public class AudioLoaderException : AudioException
/// <summary>Represents exceptions related to OpenTK.Audio.AudioReader objects.</summary>
public class AudioReaderException : AudioException
{
/// <summary>Constructs a new AudioLoaderException.</summary>
public AudioLoaderException() : base() { }
/// <summary>Constructs a new AudioLoaderException with the specified error message.</summary>
/// <param name="message">The error message of the AudioLoaderException.</param>
public AudioLoaderException(string message) : base(message) { }
/// <summary>Constructs a new AudioReaderException.</summary>
public AudioReaderException() : base() { }
/// <summary>Constructs a new AudioReaderException with the specified error message.</summary>
/// <param name="message">The error message of the AudioReaderException.</param>
public AudioReaderException(string message) : base(message) { }
}
}

View file

@ -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()));