Skip to content

infinite loop in AudioSourceInstance::seek #392

Description

@klein-j

In the file soloud_audiosource.cpp we find the function:


result AudioSourceInstance::seek(double aSeconds, float *mScratch, unsigned int mScratchSize)
{

	...

	while (samples_to_discard)
	{
		int samples = mScratchSize / mChannels;
		if (samples > samples_to_discard)
			samples = samples_to_discard;
		getAudio(mScratch, samples, samples);
		samples_to_discard -= samples;
	}
	mStreamPosition = aSeconds;
	return SO_NO_ERROR;
}

I ran into an issue were this loop never terminates. Upon investigation I found, that mScratchSize was zero. This is some internal parameter, for which I do not understand how and when it is computed, but clearly it should never be 0 when this function is called.

For now I implemented a small fix, where the function simply returns if scratch size is zero, however I think the real error lies somewhere else. The code clearly relies on the assumption, that this situation can never occur, so either it should be fixed somewhere else, or, if an invalid state is reached caused by the user making invalid calls to the API, the error should be caught in this function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions