//
// sub_1004F9B0C from 0x1004f9b0c to 0x1004f9bd0 (196 bytes)
//
// 2 xrefs:
// > sub_1004F9324 @ 0x1004f94d8
// > sub_1004F9C84 @ 0x1004f9c84
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall sub_1004F9B0C(__int64 a1, __int64 a2, AudioQueueBuffer *a3)
{
UInt32 v3; // w9
__int64 result; // x0
UInt32 v7; // w8
UInt32 ioNumPackets; // [xsp+8h] [xbp-18h] BYREF
UInt32 ioNumBytes; // [xsp+Ch] [xbp-14h] BYREF
v3 = *(_DWORD *)(a1 + 464);
ioNumPackets = 1;
ioNumBytes = v3;
if ( *(_BYTE *)(a1 + 504) )
return 0;
if ( !AudioFileReadPacketData(
*(AudioFileID *)(a1 + 408),
0,
&ioNumBytes,
a3->mPacketDescriptions,
*(unsigned int *)(a1 + 508),
&ioNumPackets,
a3->mAudioData) )
{
v7 = ioNumPackets;
if ( ioNumPackets )
{
a3->mAudioDataByteSize = ioNumBytes;
a3->mPacketDescriptionCount = v7;
result = AudioQueueEnqueueBuffer(*(AudioQueueRef *)(a1 + 480), a3, 0, nullptr);
if ( !(_DWORD)result )
{
*(_DWORD *)(a1 + 508) += ioNumPackets;
return result;
}
}
else
{
result = AudioQueueFlush(*(AudioQueueRef *)(a1 + 480));
if ( !(_DWORD)result )
{
*(_BYTE *)(a1 + 504) = 1;
return result;
}
}
}
return 28;
}