Audio stops playing randomly

Hey guys, we recently found the bug in one of our internal projects.

It was introduced when we supported pausing individual sounds in addition to pausing the entire game. The cause of the bug is because sound sources objects are recycled and state needs to be cleared before reuse. Sound sources from a previous life which were paused are causing future sound sources to behave as if they’re paused.

The fix is simple, I’m trying to see if I can get approval for a hotfix, but in the meantime, if you need a quick patch, add the following code in AudioDevice.cpp (line 2911) after successfully initializing a sound source.

if (Source->IsPreparedToInit())
{
	// Init the source, this may result in failure
	bSuccess = Source->Init(WaveInstance);
		
	// If we succeeded then play and update the source
	if (bSuccess)
	{
		// PATCH BEGIN....
		// Clear pause state
		Source->bIsManuallyPaused = false;
		Source->bIsPausedByGame = false;
		// PATCH END...

		// Set the pause before updating it
		Source->SetPauseManually(Source->WaveInstance->bIsPaused);

In 4.15 we have a CommonInit function for sound sources which is called inside Init on all platforms so this will look a little different in 4.15+.