mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 04:25:33 +00:00
Fixed SoundReader prermissions.
Fixed a problem with SoundReader.EndOfFile. Removed a Dispose() call i Playback.cs (was not necessecary). Streaming code updates.
This commit is contained in:
parent
98ded8fd9e
commit
2fa1330f3b
|
@ -50,8 +50,6 @@ namespace Examples
|
||||||
AL.SourceStop(source);
|
AL.SourceStop(source);
|
||||||
AL.DeleteSource(source);
|
AL.DeleteSource(source);
|
||||||
AL.DeleteBuffer(buffer);
|
AL.DeleteBuffer(buffer);
|
||||||
|
|
||||||
sound.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Examples.OpenAL
|
||||||
public class StreamingPlayback
|
public class StreamingPlayback
|
||||||
{
|
{
|
||||||
const string filename = "Data\\Audio\\the_ring_that_fell.wav";
|
const string filename = "Data\\Audio\\the_ring_that_fell.wav";
|
||||||
const int buffer_size = 8096;
|
const int buffer_size = 18096;
|
||||||
|
|
||||||
static object openal_lock = new object();
|
static object openal_lock = new object();
|
||||||
|
|
||||||
|
@ -39,12 +39,16 @@ namespace Examples.OpenAL
|
||||||
|
|
||||||
SoundStreamer streamer = new SoundStreamer(sound, source, buffers);
|
SoundStreamer streamer = new SoundStreamer(sound, source, buffers);
|
||||||
streamer.Start();
|
streamer.Start();
|
||||||
|
lock (openal_lock)
|
||||||
|
{
|
||||||
|
AL.SourcePlay(source);
|
||||||
|
}
|
||||||
|
|
||||||
// Query the source to find out when it stops playing.
|
// Query the source to find out when it stops playing.
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
//Thread.Sleep(100);
|
||||||
Console.Write(".");
|
//Console.Write(".");
|
||||||
lock (openal_lock)
|
lock (openal_lock)
|
||||||
{
|
{
|
||||||
AL.GetSource(source, ALGetSourcei.SourceState, out state);
|
AL.GetSource(source, ALGetSourcei.SourceState, out state);
|
||||||
|
@ -52,13 +56,15 @@ namespace Examples.OpenAL
|
||||||
}
|
}
|
||||||
while ((ALSourceState)state == ALSourceState.Playing);
|
while ((ALSourceState)state == ALSourceState.Playing);
|
||||||
|
|
||||||
Console.WriteLine();
|
Console.WriteLine("asd");
|
||||||
|
|
||||||
|
lock (openal_lock)
|
||||||
|
{
|
||||||
AL.SourceStop(source);
|
AL.SourceStop(source);
|
||||||
AL.DeleteSource(source);
|
AL.DeleteSource(source);
|
||||||
AL.DeleteBuffers(buffers);
|
AL.DeleteBuffers(buffers);
|
||||||
|
}
|
||||||
|
|
||||||
sound.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +73,7 @@ namespace Examples.OpenAL
|
||||||
SoundReader reader;
|
SoundReader reader;
|
||||||
int source;
|
int source;
|
||||||
int[] buffers;
|
int[] buffers;
|
||||||
|
Thread thread;
|
||||||
|
|
||||||
public SoundStreamer(SoundReader sound, int source, int[] buffers)
|
public SoundStreamer(SoundReader sound, int source, int[] buffers)
|
||||||
{
|
{
|
||||||
|
@ -85,7 +92,8 @@ namespace Examples.OpenAL
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
new Thread(new ThreadStart(StartStreaming)).Start();
|
thread = new Thread(new ThreadStart(StartStreaming));
|
||||||
|
thread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartStreaming()
|
void StartStreaming()
|
||||||
|
@ -106,6 +114,7 @@ namespace Examples.OpenAL
|
||||||
|
|
||||||
Thread.Sleep(5);
|
Thread.Sleep(5);
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("booh");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace OpenTK.Audio
|
||||||
/// <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.SoundReader, which can be used to read from the specified sound file.</returns>
|
/// <returns>A new OpenTK.Audio.SoundReader, which can be used to read from the specified sound file.</returns>
|
||||||
public SoundReader(string filename)
|
public SoundReader(string filename)
|
||||||
: this(new FileStream(filename, FileMode.Open))
|
: this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -170,13 +170,18 @@ namespace OpenTK.Audio
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public bool EndOfFile
|
#region public virtual bool EndOfFile
|
||||||
|
|
||||||
public bool EndOfFile
|
public virtual bool EndOfFile
|
||||||
{
|
{
|
||||||
get { return stream.Position >= stream.Length; }
|
get
|
||||||
}
|
{
|
||||||
|
if (implementation != null)
|
||||||
|
return implementation.EndOfFile;
|
||||||
|
|
||||||
|
return this.Stream.Position >= this.Stream.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -44,9 +44,11 @@ namespace OpenTK.Audio
|
||||||
|
|
||||||
internal WaveReader(Stream s)
|
internal WaveReader(Stream s)
|
||||||
{
|
{
|
||||||
|
if (s == null) throw new ArgumentNullException();
|
||||||
|
if (!s.CanRead) throw new ArgumentException("Cannot read from specified Stream.");
|
||||||
|
|
||||||
reader = new BinaryReader(s);
|
reader = new BinaryReader(s);
|
||||||
if (!ReadHeaders(reader))
|
this.Stream = s;
|
||||||
throw new NotSupportedException("The specified stream is not supported by this decoder.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if false
|
#if false
|
||||||
|
@ -163,7 +165,7 @@ namespace OpenTK.Audio
|
||||||
decoded_data = new SoundData(new SoundFormat(channels, bits_per_sample, sample_rate),
|
decoded_data = new SoundData(new SoundFormat(channels, bits_per_sample, sample_rate),
|
||||||
reader.ReadBytes((int)samples));
|
reader.ReadBytes((int)samples));
|
||||||
|
|
||||||
throw new NotImplementedException();
|
return decoded_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue