//
// sub_84B4A8 from 0x84b4a8 to 0x84b6c6 (542 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:02:27 +0000
//
int __fastcall sub_84B4A8(int a1, int *a2, size_t *a3, _BYTE *a4)
{
void *v5; // r0
int *v6; // r6
char *v7; // r3
int v8; // r0
unsigned __int8 *v9; // r5
int v10; // r7
int v11; // r4
int v12; // r10
int *v13; // r9
int v14; // r8
int (__fastcall *v15)(unsigned __int8 *, int, int, _DWORD); // r6
int v16; // r11
int v17; // r0
int *v18; // r6
int v19; // r9
int v21; // r3
void *v22; // r0
int v23; // r4
v5 = (void *)a2[272];
v6 = a2;
if ( v5 )
{
v7 = (char *)sub_844F50(v5, a2[273] + *a3);
if ( !v7 )
{
v6[272] = 0;
v6[273] = 0;
return 27;
}
v8 = v6[273];
v6[272] = (int)v7;
memcpy(&v7[v8], *(const void **)(a1 + 172), *a3);
v9 = (unsigned __int8 *)v6[272];
v10 = v6[273] + *a3;
v6[273] = v10;
}
else
{
v9 = *(unsigned __int8 **)(a1 + 172);
v10 = *a3;
}
if ( v10 <= 0 )
goto LABEL_27;
if ( *v9 != 36 )
goto LABEL_24;
if ( v10 <= 4 || (v6[274] = v9[1], v11 = v9[3] | (v9[2] << 8), v10 <= v11 + 3) )
{
LABEL_22:
*a4 = 1;
v21 = *v9;
goto LABEL_23;
}
v12 = a1;
v13 = v6;
while ( 1 )
{
v14 = *v13;
v15 = *(int (__fastcall **)(unsigned __int8 *, int, int, _DWORD))(*v13 + 432);
if ( !v15 )
v15 = *(int (__fastcall **)(unsigned __int8 *, int, int, _DWORD))(v14 + 424);
v16 = v11 + 4;
v17 = v15(v9, 1, v11 + 4, *(_DWORD *)(v14 + 364));
if ( v17 == 268435457 )
{
v18 = v13;
v19 = v12;
sub_828178(v14, "Cannot pause RTP");
goto LABEL_14;
}
if ( v16 != v17 )
{
v18 = v13;
v19 = v12;
sub_828178(v14, "Failed writing RTP data");
LABEL_14:
sub_828178(v19, "Got an error writing an RTP packet");
*a4 = 0;
off_D200B0((void *)v18[272]);
v18[272] = 0;
v18[273] = 0;
return 23;
}
v9 += v16;
v10 += -4 - v11;
if ( *(_DWORD *)(v12 + 1224) == 11 )
break;
if ( v10 <= 0 )
goto LABEL_26;
LABEL_18:
if ( *v9 != 36 )
{
v6 = v13;
a1 = v12;
goto LABEL_24;
}
if ( v10 > 4 )
{
v13[274] = v9[1];
v11 = v9[3] | (v9[2] << 8);
if ( v11 + 3 < v10 )
continue;
}
v6 = v13;
a1 = v12;
goto LABEL_22;
}
*(_DWORD *)(v12 + 304) &= ~1u;
if ( v10 > 0 )
goto LABEL_18;
LABEL_26:
v6 = v13;
a1 = v12;
LABEL_27:
if ( !v10 )
goto LABEL_24;
v21 = *v9;
LABEL_23:
if ( v21 == 36 )
{
v22 = off_D200AC(v10);
v23 = (int)v22;
if ( v22 )
{
memcpy(v22, v9, v10);
off_D200B0((void *)v6[272]);
v6[272] = v23;
v6[273] = v10;
*a3 = 0;
return 0;
}
else
{
off_D200B0((void *)v6[272]);
v6[272] = 0;
v6[273] = 0;
return 27;
}
}
else
{
LABEL_24:
*(_DWORD *)(a1 + 172) += *a3 - v10;
*a3 = v10;
off_D200B0((void *)v6[272]);
v6[272] = 0;
v6[273] = 0;
return 0;
}
}