Fix FlxSound not completing correctly, & callbacks

This commit is contained in:
Ralty
2025-07-15 01:22:53 +07:00
parent a708c204e7
commit 7f3d976ac6
3 changed files with 70 additions and 63 deletions
+4 -20
View File
@@ -672,26 +672,10 @@ class Sound extends EventDispatcher
#if (js && html5 && howlerjs)
return __buffer.src.duration() * 1000;
#else
if (__buffer.data != null)
{
// var samples = (__buffer.data.length * 8) / (__buffer.channels * __buffer.bitsPerSample);
// return Std.int(samples / __buffer.sampleRate * 1000);
var samples = (Int64.make(0, __buffer.data.length) * Int64.ofInt(8)) / Int64.ofInt(__buffer.channels * __buffer.bitsPerSample);
var div = Int64.divMod(samples * Int64.ofInt(1000), Int64.ofInt(__buffer.sampleRate));
var value = (div.quotient + (div.modulus / __buffer.sampleRate));
return Int64.toInt(value);
}
else if (__buffer.__srcVorbisFile != null)
{
//var samples = Int64.toInt(__buffer.__srcVorbisFile.pcmTotal());
//return Std.int(samples / __buffer.sampleRate * 1000);
var samples = __buffer.__srcVorbisFile.pcmTotal();
var value = Int64.fromFloat(__buffer.__srcVorbisFile.timeTotal()) * 1000;
return Int64.toInt(value);
}
else
{
return 0;
if (__buffer.data != null) return (__buffer.data.length >> 0) / __buffer.channels / (__buffer.bitsPerSample >> 3) / __buffer.sampleRate * 1000;
else if (__buffer.__srcVorbisFile != null) {
var x = __buffer.__srcVorbisFile.pcmTotal();
return (x.high * 4294967296. + (x.low >> 0)) / __buffer.sampleRate * 1000;
}
#end
}