mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 23:45:47 +00:00
Renamed AudioLoader and WaveLoader to AudioReader and WaveReader.
This commit is contained in:
parent
0363d899d7
commit
a21dcfd659
|
@ -17,62 +17,62 @@ namespace OpenTK.Audio
|
||||||
/// Encapsulates a sound stream and provides decoding and streaming capabilities.
|
/// Encapsulates a sound stream and provides decoding and streaming capabilities.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="SampleType"></typeparam>
|
/// <typeparam name="SampleType"></typeparam>
|
||||||
public class AudioLoader : IDisposable
|
public class AudioReader : IDisposable
|
||||||
{
|
{
|
||||||
static object reader_lock = new object();
|
static object reader_lock = new object();
|
||||||
static List<AudioLoader> readers = new List<AudioLoader>();
|
static List<AudioReader> readers = new List<AudioReader>();
|
||||||
|
|
||||||
bool disposed;
|
bool disposed;
|
||||||
Stream stream;
|
Stream stream;
|
||||||
AudioLoader implementation;
|
AudioReader implementation;
|
||||||
|
|
||||||
#region --- Constructors ---
|
#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).
|
// TODO: Plugin architecture for sound formats. This is overkill now that we only have a WaveReader (future proofing).
|
||||||
readers.Add(new WaveLoader());
|
readers.Add(new WaveReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region protected AudioLoader()
|
#region protected AudioReader()
|
||||||
|
|
||||||
protected AudioLoader() { }
|
protected AudioReader() { }
|
||||||
|
|
||||||
#endregion
|
#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>
|
/// <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>
|
/// <returns>A new OpenTK.Audio.AudioReader, which can be used to read from the specified sound file.</returns>
|
||||||
public AudioLoader(string filename)
|
public AudioReader(string filename)
|
||||||
: this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
: this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
#endregion
|
#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>
|
/// <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>
|
/// <returns>A new OpenTK.Audio.AudioReader, which can be used to read from the specified sound stream.</returns>
|
||||||
public AudioLoader(Stream s)
|
public AudioReader(Stream s)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock (reader_lock)
|
lock (reader_lock)
|
||||||
{
|
{
|
||||||
foreach (AudioLoader reader in readers)
|
foreach (AudioReader reader in readers)
|
||||||
{
|
{
|
||||||
long pos = s.Position;
|
long pos = s.Position;
|
||||||
if (reader.Supports(s))
|
if (reader.Supports(s))
|
||||||
{
|
{
|
||||||
s.Position = pos;
|
s.Position = pos;
|
||||||
implementation = (AudioLoader)
|
implementation = (AudioReader)
|
||||||
reader.GetType().GetConstructor(
|
reader.GetType().GetConstructor(
|
||||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public |
|
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public |
|
||||||
System.Reflection.BindingFlags.Instance,
|
System.Reflection.BindingFlags.Instance,
|
||||||
|
@ -198,7 +198,7 @@ namespace OpenTK.Audio
|
||||||
|
|
||||||
#region IDisposable Members
|
#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()
|
public virtual void Dispose()
|
||||||
{
|
{
|
||||||
this.Dispose(true);
|
this.Dispose(true);
|
||||||
|
@ -217,7 +217,7 @@ namespace OpenTK.Audio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~AudioLoader()
|
~AudioReader()
|
||||||
{
|
{
|
||||||
this.Dispose(false);
|
this.Dispose(false);
|
||||||
}
|
}
|
|
@ -12,13 +12,13 @@ using System.Text;
|
||||||
|
|
||||||
namespace OpenTK.Audio
|
namespace OpenTK.Audio
|
||||||
{
|
{
|
||||||
/// <summary>Represents exceptions related to OpenTK.Audio.AudioLoader objects.</summary>
|
/// <summary>Represents exceptions related to OpenTK.Audio.AudioReader objects.</summary>
|
||||||
public class AudioLoaderException : AudioException
|
public class AudioReaderException : AudioException
|
||||||
{
|
{
|
||||||
/// <summary>Constructs a new AudioLoaderException.</summary>
|
/// <summary>Constructs a new AudioReaderException.</summary>
|
||||||
public AudioLoaderException() : base() { }
|
public AudioReaderException() : base() { }
|
||||||
/// <summary>Constructs a new AudioLoaderException with the specified error message.</summary>
|
/// <summary>Constructs a new AudioReaderException with the specified error message.</summary>
|
||||||
/// <param name="message">The error message of the AudioLoaderException.</param>
|
/// <param name="message">The error message of the AudioReaderException.</param>
|
||||||
public AudioLoaderException(string message) : base(message) { }
|
public AudioReaderException(string message) : base(message) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace OpenTK.Audio
|
namespace OpenTK.Audio
|
||||||
{
|
{
|
||||||
internal sealed class WaveLoader : AudioLoader
|
internal sealed class WaveReader : AudioReader
|
||||||
{
|
{
|
||||||
SoundData decoded_data;
|
SoundData decoded_data;
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ namespace OpenTK.Audio
|
||||||
|
|
||||||
BinaryReader reader;
|
BinaryReader reader;
|
||||||
|
|
||||||
internal WaveLoader() { }
|
internal WaveReader() { }
|
||||||
|
|
||||||
internal WaveLoader(Stream s)
|
internal WaveReader(Stream s)
|
||||||
{
|
{
|
||||||
if (s == null) throw new ArgumentNullException();
|
if (s == null) throw new ArgumentNullException();
|
||||||
if (!s.CanRead) throw new ArgumentException("Cannot read from specified Stream.");
|
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 new SoundData(decoded_data, new SoundFormat(channels, bits_per_sample, sample_rate));
|
||||||
return decoded_data;
|
return decoded_data;
|
||||||
}
|
}
|
||||||
catch (AudioLoaderException e)
|
catch (AudioReaderException e)
|
||||||
{
|
{
|
||||||
reader.Close();
|
reader.Close();
|
||||||
throw;
|
throw;
|
||||||
|
@ -211,7 +211,7 @@ namespace OpenTK.Audio
|
||||||
{
|
{
|
||||||
base.Stream = value;
|
base.Stream = value;
|
||||||
if (!ReadHeaders(reader))
|
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(),
|
Debug.Write(String.Format("Opened WAVE/RIFF file: ({0}, {1}, {2}, {3}) ", sample_rate.ToString(), bits_per_sample.ToString(),
|
||||||
channels.ToString(), audio_format.ToString()));
|
channels.ToString(), audio_format.ToString()));
|
Loading…
Reference in a new issue