mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 15:45:34 +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.DeleteSource(source);
|
||||
AL.DeleteBuffer(buffer);
|
||||
|
||||
sound.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Examples.OpenAL
|
|||
public class StreamingPlayback
|
||||
{
|
||||
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();
|
||||
|
||||
|
@ -39,12 +39,16 @@ namespace Examples.OpenAL
|
|||
|
||||
SoundStreamer streamer = new SoundStreamer(sound, source, buffers);
|
||||
streamer.Start();
|
||||
lock (openal_lock)
|
||||
{
|
||||
AL.SourcePlay(source);
|
||||
}
|
||||
|
||||
// Query the source to find out when it stops playing.
|
||||
do
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
Console.Write(".");
|
||||
//Thread.Sleep(100);
|
||||
//Console.Write(".");
|
||||
lock (openal_lock)
|
||||
{
|
||||
AL.GetSource(source, ALGetSourcei.SourceState, out state);
|
||||
|
@ -52,13 +56,15 @@ namespace Examples.OpenAL
|
|||
}
|
||||
while ((ALSourceState)state == ALSourceState.Playing);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("asd");
|
||||
|
||||
lock (openal_lock)
|
||||
{
|
||||
AL.SourceStop(source);
|
||||
AL.DeleteSource(source);
|
||||
AL.DeleteBuffers(buffers);
|
||||
}
|
||||
|
||||
sound.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,6 +73,7 @@ namespace Examples.OpenAL
|
|||
SoundReader reader;
|
||||
int source;
|
||||
int[] buffers;
|
||||
Thread thread;
|
||||
|
||||
public SoundStreamer(SoundReader sound, int source, int[] buffers)
|
||||
{
|
||||
|
@ -85,7 +92,8 @@ namespace Examples.OpenAL
|
|||
|
||||
public void Start()
|
||||
{
|
||||
new Thread(new ThreadStart(StartStreaming)).Start();
|
||||
thread = new Thread(new ThreadStart(StartStreaming));
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
void StartStreaming()
|
||||
|
@ -106,6 +114,7 @@ namespace Examples.OpenAL
|
|||
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
Console.WriteLine("booh");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace OpenTK.Audio
|
|||
/// <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>
|
||||
public SoundReader(string filename)
|
||||
: this(new FileStream(filename, FileMode.Open))
|
||||
: this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
@ -170,13 +170,18 @@ namespace OpenTK.Audio
|
|||
|
||||
#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
|
||||
|
|
|
@ -44,9 +44,11 @@ namespace OpenTK.Audio
|
|||
|
||||
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);
|
||||
if (!ReadHeaders(reader))
|
||||
throw new NotSupportedException("The specified stream is not supported by this decoder.");
|
||||
this.Stream = s;
|
||||
}
|
||||
|
||||
#if false
|
||||
|
@ -163,7 +165,7 @@ namespace OpenTK.Audio
|
|||
decoded_data = new SoundData(new SoundFormat(channels, bits_per_sample, sample_rate),
|
||||
reader.ReadBytes((int)samples));
|
||||
|
||||
throw new NotImplementedException();
|
||||
return decoded_data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue