Fixed thread exit problems

This commit is contained in:
Robert Osfield
2009-03-08 16:48:48 +00:00
parent 7473b06275
commit 73c2615d17
7 changed files with 48 additions and 5 deletions

View File

@@ -37,7 +37,11 @@ FFmpegDecoderAudio::~FFmpegDecoderAudio()
if (isRunning())
{
m_exit = true;
#if 0
while(isRunning()) { OpenThreads::YieldCurrentThread(); }
#else
join();
#endif
}
}
@@ -85,6 +89,16 @@ void FFmpegDecoderAudio::open(AVStream * const stream)
}
void FFmpegDecoderAudio::close(bool waitForThreadToExit)
{
m_exit = true;
if (isRunning() && waitForThreadToExit)
{
while(isRunning()) { OpenThreads::Thread::YieldCurrentThread(); }
}
}
void FFmpegDecoderAudio::run()
{
@@ -105,7 +119,6 @@ void FFmpegDecoderAudio::run()
}
void FFmpegDecoderAudio::setAudioSink(osg::ref_ptr<osg::AudioSink> audio_sink)
{
// The FFmpegDecoderAudio object takes the responsability of destroying the audio_sink.