|
@@ -1,6 +1,7 @@
|
|
|
package hxd.snd.openal;
|
|
|
|
|
|
import hxd.snd.openal.AudioTypes;
|
|
|
+import hxd.snd.Driver.DriverFeature;
|
|
|
|
|
|
#if hlopenal
|
|
|
import openal.AL;
|
|
@@ -35,6 +36,12 @@ class Driver implements hxd.snd.Driver {
|
|
|
throw "could not init openAL Driver";
|
|
|
}
|
|
|
|
|
|
+ public function hasFeature( f : DriverFeature ) {
|
|
|
+ return switch( f ) {
|
|
|
+ case MasterVolume: true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function getTmpBytes(size) {
|
|
|
if (tmpBytes.length < size) tmpBytes = haxe.io.Bytes.alloc(size);
|
|
|
return tmpBytes;
|
|
@@ -110,7 +117,7 @@ class Driver implements hxd.snd.Driver {
|
|
|
bytes.setInt32(0, buffer.inst.toInt());
|
|
|
AL.deleteBuffers(1, bytes);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function setBufferData(buffer : BufferHandle, data : haxe.io.Bytes, size : Int, format : Data.SampleFormat, channelCount : Int, samplingRate : Int) : Void {
|
|
|
var alFormat = switch (format) {
|
|
|
case UI8 : channelCount == 1 ? AL.FORMAT_MONO8 : AL.FORMAT_STEREO8;
|
|
@@ -126,7 +133,7 @@ class Driver implements hxd.snd.Driver {
|
|
|
|
|
|
public function getPlayedSampleCount(source : SourceHandle) : Int {
|
|
|
var v = source.sampleOffset + AL.getSourcei(source.inst, AL.SAMPLE_OFFSET);
|
|
|
- if (v < 0)
|
|
|
+ if (v < 0)
|
|
|
v = 0;
|
|
|
return v;
|
|
|
}
|
|
@@ -134,7 +141,7 @@ class Driver implements hxd.snd.Driver {
|
|
|
public function getProcessedBuffers(source : SourceHandle) : Int {
|
|
|
return AL.getSourcei(source.inst, AL.BUFFERS_PROCESSED);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function queueBuffer(source : SourceHandle, buffer : BufferHandle, sampleStart : Int, endOfStream : Bool) : Void {
|
|
|
var bytes = getTmpBytes(4);
|
|
|
bytes.setInt32(0, buffer.inst.toInt());
|
|
@@ -150,12 +157,12 @@ class Driver implements hxd.snd.Driver {
|
|
|
} else {
|
|
|
source.sampleOffset = 0;
|
|
|
}
|
|
|
- if (source.playing)
|
|
|
+ if (source.playing)
|
|
|
AL.sourcePlay(source.inst);
|
|
|
}
|
|
|
buffer.isEnd = endOfStream;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function unqueueBuffer(source : SourceHandle, buffer : BufferHandle) : Void {
|
|
|
var bytes = getTmpBytes(4);
|
|
|
bytes.setInt32(0, buffer.inst.toInt());
|
|
@@ -168,10 +175,10 @@ class Driver implements hxd.snd.Driver {
|
|
|
if (buffer.isEnd) source.sampleOffset = 0;
|
|
|
else source.sampleOffset += samples;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function update() : Void {
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function dispose() : Void {
|
|
|
ALC.makeContextCurrent(null);
|
|
|
ALC.destroyContext(context);
|