source/Sources/AirPlayReceiverSession.c
static void	_GeneralAudioTrackLosses( AirPlayReceiverSessionRef inSession, AirTunesBufferNode *inNode )
{
	Boolean			updateLast;
	uint16_t		seqCurr;
	uint16_t		seqNext;
	uint16_t		seqLoss;
	
	updateLast = true;
	seqCurr = inNode->rtp->header.seq;
	if( inSession->source.receiveCount > 0 )
	{
		seqNext = inSession->lastRTPSeq + 1;
		if( seqCurr == seqNext )
		{
			// Expected case of the receiving the next packet in the sequence so nothing special needs to be done.
		}
		else if( Mod16_GT( seqCurr, seqNext ) )
		{
			seqLoss = seqCurr - seqNext;
			gAirPlayAudioStats.lostPackets += seqLoss;
			if( seqLoss > inSession->source.maxBurstLoss ) inSession->source.maxBurstLoss = seqLoss;
			if( seqLoss <= inSession->source.retransmitMaxLoss )
			{
				atr_stats_ulog( kLogLevelNotice, "### Lost packets %u-%u (+%u, %u total)\n", 
					seqNext, seqCurr, seqLoss, gAirPlayAudioStats.lostPackets );
				if( !inSession->source.rtcpRTDisable ) _RetransmitsSchedule( inSession, seqNext, seqLoss );
			}
			else
			{
				atr_ulog( kLogLevelNotice, "### Burst packet loss %u-%u (+%u, %u total)\n", 
					seqNext, seqCurr, seqLoss, gAirPlayAudioStats.lostPackets );
				++inSession->source.bigLossCount;
				_RetransmitsAbortAll( inSession, "BURST" );
			}
		}
		else if( seqCurr == inSession->lastRTPSeq )
		{
			dlogassert( "Duplicate sequence number not caught earlier? seq %u", seqCurr );
			updateLast = false;
		}
		else if( inSession->redundantAudio )
		{
			updateLast = false; // Don't track misorders since they are intentional in redundant mode.
		}
		else
		{
			atr_ulog( kLogLevelNotice, "### Misordered packet seq %u -> %u\n", inSession->lastRTPSeq, seqCurr );
			updateLast = false;
		}
	}
	if( updateLast )
	{
		inSession->lastRTPSeq = seqCurr;
		inSession->lastRTPTS  = inNode->rtp->header.ts;
	}
}
//===========================================================================================================================
//	_GeneralAudioTrackLosses
//
//	Warning: Assumes the AirTunes lock is held.
//===========================================================================================================================
_GeneralAudioTrackLosses
Warning: Assumes the AirTunes lock is held.
_GeneralAudioTrackLosses Warning : Assumes the AirTunes lock is held .
static void	_GeneralAudioTrackLosses( AirPlayReceiverSessionRef inSession, AirTunesBufferNode *inNode )
{
	Boolean			updateLast;
	uint16_t		seqCurr;
	uint16_t		seqNext;
	uint16_t		seqLoss;
	updateLast = true;
	seqCurr = inNode->rtp->header.seq;
	if( inSession->source.receiveCount > 0 )
	{
		seqNext = inSession->lastRTPSeq + 1;
		if( seqCurr == seqNext )
		{
		}
		else if( Mod16_GT( seqCurr, seqNext ) )
		{
			seqLoss = seqCurr - seqNext;
			gAirPlayAudioStats.lostPackets += seqLoss;
			if( seqLoss > inSession->source.maxBurstLoss ) inSession->source.maxBurstLoss = seqLoss;
			if( seqLoss <= inSession->source.retransmitMaxLoss )
			{
				atr_stats_ulog( kLogLevelNotice, "### Lost packets %u-%u (+%u, %u total)\n", 
					seqNext, seqCurr, seqLoss, gAirPlayAudioStats.lostPackets );
				if( !inSession->source.rtcpRTDisable ) _RetransmitsSchedule( inSession, seqNext, seqLoss );
			}
			else
			{
				atr_ulog( kLogLevelNotice, "### Burst packet loss %u-%u (+%u, %u total)\n", 
					seqNext, seqCurr, seqLoss, gAirPlayAudioStats.lostPackets );
				++inSession->source.bigLossCount;
				_RetransmitsAbortAll( inSession, "BURST" );
			}
		}
		else if( seqCurr == inSession->lastRTPSeq )
		{
			dlogassert( "Duplicate sequence number not caught earlier? seq %u", seqCurr );
			updateLast = false;
		}
		else if( inSession->redundantAudio )
		{
			updateLast = false; 
		}
		else
		{
			atr_ulog( kLogLevelNotice, "### Misordered packet seq %u -> %u\n", inSession->lastRTPSeq, seqCurr );
			updateLast = false;
		}
	}
	if( updateLast )
	{
		inSession->lastRTPSeq = seqCurr;
		inSession->lastRTPTS  = inNode->rtp->header.ts;
	}
}
static void _GeneralAudioTrackLosses ( AirPlayReceiverSessionRef inSession , AirTunesBufferNode * inNode ) { Boolean updateLast ; uint16_t seqCurr ; uint16_t seqNext ; uint16_t seqLoss ; updateLast = true ; seqCurr = inNode -> rtp -> header . seq ; if ( inSession -> source . receiveCount > 0 ) { seqNext = inSession -> lastRTPSeq + 1 ; if ( seqCurr == seqNext ) { } else if ( Mod16_GT ( seqCurr , seqNext ) ) { seqLoss = seqCurr - seqNext ; gAirPlayAudioStats . lostPackets += seqLoss ; if ( seqLoss > inSession -> source . maxBurstLoss ) inSession -> source . maxBurstLoss = seqLoss ; if ( seqLoss <= inSession -> source . retransmitMaxLoss ) { atr_stats_ulog ( kLogLevelNotice , " \n " , seqNext , seqCurr , seqLoss , gAirPlayAudioStats . lostPackets ) ; if ( ! inSession -> source . rtcpRTDisable ) _RetransmitsSchedule ( inSession , seqNext , seqLoss ) ; } else { atr_ulog ( kLogLevelNotice , " \n " , seqNext , seqCurr , seqLoss , gAirPlayAudioStats . lostPackets ) ; ++ inSession -> source . bigLossCount ; _RetransmitsAbortAll ( inSession , " " ) ; } } else if ( seqCurr == inSession -> lastRTPSeq ) { dlogassert ( " " , seqCurr ) ; updateLast = false ; } else if ( inSession -> redundantAudio ) { updateLast = false ; } else { atr_ulog ( kLogLevelNotice , " \n " , inSession -> lastRTPSeq , seqCurr ) ; updateLast = false ; } } if ( updateLast ) { inSession -> lastRTPSeq = seqCurr ; inSession -> lastRTPTS = inNode -> rtp -> header . ts ; } }
_GeneralAudioTrackLosses
Warning: Assumes the AirTunes lock is held.
_GeneralAudioTrackLosses Warning : Assumes the AirTunes lock is held .
// Expected case of the receiving the next packet in the sequence so nothing special needs to be done. // Don't track misorders since they are intentional in redundant mode.