demux: adaptative: fix uninitialized thread_t (fix #1346983)

Sets dumb initializer, and adds member to avoid joining invalid
thread reference.
This commit is contained in:
Francois Cartegnie 2015-12-31 15:58:24 +01:00
parent efe5041cc3
commit d64372c7c3
2 changed files with 8 additions and 2 deletions

View File

@ -29,15 +29,19 @@ Downloader::Downloader()
vlc_mutex_init(&lock);
vlc_cond_init(&waitcond);
killed = false;
thread_handle = { 0 };
thread_handle_valid = false;
}
bool Downloader::start()
{
if(vlc_clone(&thread_handle, downloaderThread,
if(!thread_handle_valid &&
vlc_clone(&thread_handle, downloaderThread,
reinterpret_cast<void *>(this), VLC_THREAD_PRIORITY_INPUT))
{
return false;
}
thread_handle_valid = true;
return true;
}
@ -45,7 +49,8 @@ Downloader::~Downloader()
{
killed = true;
vlc_cond_signal(&waitcond);
vlc_join(thread_handle, NULL);
if(thread_handle_valid)
vlc_join(thread_handle, NULL);
vlc_mutex_destroy(&lock);
vlc_cond_destroy(&waitcond);
}

View File

@ -52,6 +52,7 @@ namespace adaptative
vlc_mutex_t lock;
vlc_cond_t waitcond;
vlc_mutex_t processlock;
bool thread_handle_valid;
bool killed;
std::list<HTTPChunkBufferedSource *> chunks;
};