Skip to content

A branch in MilesAudioManager::killAudioEventImmediately can never enter #2775

@xezon

Description

@xezon

A branch in MilesAudioManager::killAudioEventImmediately can never enter.

AR_Play handle check is always false

For AR_Play requests, m_handleToInteractOn is initialised to AHSV_Error (0) in the AudioRequest constructor and is never written for play requests, so req->m_handleToInteractOn == audioEvent can never be true. The PR correctly updated isCurrentlyPlaying to use req->m_pendingEvent->getPlayingHandle() == handle, but killAudioEventImmediately was not updated correspondingly. As a result, a deferred restart request created by startNextLoop (or any other pending play request) will never be cancelled by killAudioEventImmediately, so the sound can start playing again even after an explicit kill call.

Greptile fix suggestion:

		if( req->m_request == AR_Play && req->m_pendingEvent && req->m_pendingEvent->getPlayingHandle() == audioEvent )
//-------------------------------------------------------------------------------------------------
void MilesAudioManager::killAudioEventImmediately( AudioHandle audioEvent )
{
	//First look for it in the request list.
	transferDeferredAudioRequests();

	std::list<AudioRequest*>::iterator ait;
	for( ait = m_audioRequests.begin(); ait != m_audioRequests.end(); ait++ )
	{
		AudioRequest *req = (*ait);
		if( req->m_request == AR_Play && req->m_handleToInteractOn == audioEvent ) // <--- this condition will never be true
		{
			deleteInstance(req);
			ait = m_audioRequests.erase(ait);
			return;
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvestigateMinorSeverity: Minor < Major < Critical < Blocker

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions