Skip to content

Commit

Permalink
crackhead activity in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Jan 27, 2024
1 parent bfe6007 commit be0f865
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
29 changes: 19 additions & 10 deletions src/lime/_internal/backend/native/NativeAudioSource.hx
Original file line number Diff line number Diff line change
Expand Up @@ -378,21 +378,30 @@ class NativeAudioSource
}
else
{
var offset = AL.getSourcei(handle, AL.BYTE_OFFSET);
var ratio = (offset / dataLength);
var totalSeconds = samples / parent.buffer.sampleRate;
// var offset = AL.getSourcei(handle, AL.BYTE_OFFSET);
// var ratio = (offset / dataLength);
// var totalSeconds = samples / parent.buffer.sampleRate;

var sampleTime = AL.getSourcef(handle, AL.SAMPLE_OFFSET);
// var sampleTime = AL.getSourcef(handle, AL.SAMPLE_OFFSET);
// var time = (sampleTime / parent.buffer.sampleRate * 1000) - parent.offset;
// var time = Std.int(totalSeconds * ratio * 1000) - parent.offset;
// var time = Std.int (AL.getSourcef (handle, AL.SEC_OFFSET) * 1000) - parent.offset;
var value = AL.getSourcedvSOFT(handle, AL.SEC_OFFSET_CLOCK_SOFT);
var deviceOffset:Float = value[1];
var realOffset:Float = value[0];
var time = Std.int((deviceOffset - realOffset) * 1000) - parent.offset;
try
{
var value = AL.getSourcedvSOFT(handle, AL.SEC_OFFSET_LATENCY_SOFT);
var deviceOffset:Float = value[1];
var realOffset:Float = value[0];
var time:Float = ((realOffset - deviceOffset) * 1000) - parent.offset;

if (time < 0) return 0;
return Math.round(time);
}
catch (e:Dynamic)
{
trace(e.messsage);
trace(e.stack);
}

if (time < 0) return 0;
return Std.int(time);
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/lime/media/OpenALAudioContext.hx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class OpenALAudioContext
public var DEFAULT_ALL_DEVICES_SPECIFIER:Int = 0x1012;
public var ALL_DEVICES_SPECIFIER:Int = 0x1013;

public var DEVICE_CLOCK_SOFT:Int = 0x1600;
public var DEVICE_LATENCY_SOFT:Int = 0x1601;
public var DEVICE_CLOCK_LATENCY_SOFT:Int = 0x1602;

public var SEC_OFFSET_LATENCY_SOFT:Int = 0x1201;
public var SEC_OFFSET_CLOCK_SOFT:Int = 0x1203;

@:noCompletion private function new() {}
Expand Down
7 changes: 6 additions & 1 deletion src/lime/media/openal/AL.hx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ class AL
public static inline var FILTER_HIGHPASS:Int = 0x0002;
public static inline var FILTER_BANDPASS:Int = 0x0003;

public static inline var DEVICE_CLOCK_SOFT:Int = 0x1600;
public static inline var DEVICE_LATENCY_SOFT:Int = 0x1601;
public static inline var DEVICE_CLOCK_LATENCY_SOFT:Int = 0x1602;

public static inline var SEC_OFFSET_LATENCY_SOFT:Int = 0x1201;
public static inline var SEC_OFFSET_CLOCK_SOFT:Int = 0x1203;

public static function removeDirectFilter(source:ALSource)
Expand Down Expand Up @@ -969,7 +974,7 @@ class AL
#end
}

public static function getSourcedvSOFT(source:ALSource, param:Int, count:Int = 1):Array<Float>
public static function getSourcedvSOFT(source:ALSource, param:Int, count:Int = 2):Array<Float>
{
#if (lime_cffi && lime_openal && !macro)
var result = NativeCFFI.lime_al_get_sourcedv_SOFT(source, param, count);
Expand Down

0 comments on commit be0f865

Please sign in to comment.