diff --git a/talk/examples/call/console.cc b/talk/examples/call/console.cc index 9ad8bc754..992d0562c 100644 --- a/talk/examples/call/console.cc +++ b/talk/examples/call/console.cc @@ -48,28 +48,29 @@ static void DoNothing(int unused) {} Console::Console(talk_base::Thread *thread, CallClient *client) : client_(client), client_thread_(thread), - console_thread_(new talk_base::Thread()) {} + stopped_(false) {} Console::~Console() { Stop(); } void Console::Start() { - if (!console_thread_) { + if (stopped_) { // stdin was closed in Stop(), so we can't restart. LOG(LS_ERROR) << "Cannot re-start"; return; } - if (console_thread_->started()) { + if (console_thread_) { LOG(LS_WARNING) << "Already started"; return; } + console_thread_.reset(new talk_base::Thread()); console_thread_->Start(); console_thread_->Post(this, MSG_START); } void Console::Stop() { - if (console_thread_ && console_thread_->started()) { + if (console_thread_) { #ifdef WIN32 CloseHandle(GetStdHandle(STD_INPUT_HANDLE)); #else @@ -80,6 +81,7 @@ void Console::Stop() { #endif console_thread_->Stop(); console_thread_.reset(); + stopped_ = true; } } @@ -165,3 +167,5 @@ void Console::OnMessage(talk_base::Message *msg) { break; } } + +} diff --git a/talk/examples/call/console.h b/talk/examples/call/console.h index 589603896..f0f36e346 100644 --- a/talk/examples/call/console.h +++ b/talk/examples/call/console.h @@ -64,6 +64,7 @@ class Console : public talk_base::MessageHandler { CallClient *client_; talk_base::Thread *client_thread_; talk_base::scoped_ptr console_thread_; + bool stopped_; }; #endif // TALK_EXAMPLES_CALL_CONSOLE_H_