• Advertisement
Sign in to follow this  

SDL_WaitThread invalid handle??

This topic is 3232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anyway to check and see if an SDL_Thread is still running? I'm writing a video player that uses threads. The stop() function uses SDL_WaitThread to make sure all the buffering threads and whatnot are stopped. The problem occurs if a person calls the stop() function twice in a row. Since no threads are running after the 1st call, the second call returns with an "An invalid handle was specified" error with the debugger pointing at the SDL_WaitThread line. Here's my stop method:
bool VideoPlayer::stop()
{
	isPlaying = false;
	isBuffering = false;
	SDL_WaitThread(bufferer, NULL);
	SDL_WaitThread(player, NULL);
	pCodec->seekTo(0);
	clearBuffer(&frontBuffer);
	clearBuffer(&backBuffer);
	pDisplay->clearScreen();
	return true;
}

Here is how I created my threads
bool VideoPlayer::play(video::PlayMode pMode)
{
	if (!isPlaying)
	{
		playMode = pMode;
		isBuffering = true;
		isPlaying = true;
		bufferer = SDL_CreateThread(buffer_thread, this);
		player = SDL_CreateThread(play_thread, this);
		return true;
	}
	return false;
}

Any ideas??

Share this post


Link to post
Share on other sites
Advertisement
The SDL Manual isn't very clear about this. But it seems that if you try to get the id of a thread that's already terminated , SDL_GetThreadID() will return 0. Use this to check whether they've terminated or not...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement