From 10d0ece3cbf2d06e9e9736582f516e26fc046805 Mon Sep 17 00:00:00 2001 From: "bjorn.olievier" Date: Fri, 28 Mar 2008 18:48:53 +0000 Subject: [PATCH] Added mutex in ConsoleUI to lock while using cout. Makes debug output more readable. --- src/square/ConsoleUI.cpp | 4 ++++ src/square/ConsoleUI.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/square/ConsoleUI.cpp b/src/square/ConsoleUI.cpp index 61e737f24..793ca89e3 100644 --- a/src/square/ConsoleUI.cpp +++ b/src/square/ConsoleUI.cpp @@ -69,6 +69,8 @@ ConsoleUI::~ConsoleUI() void ConsoleUI::Print(std::tstring s) { + boost::mutex::scoped_lock lock(mutex); + tcout << "\n*******************************\n\n"; std::tcout << s; tcout << "\n*******************************\n" << endl; @@ -89,6 +91,8 @@ void ConsoleUI::Run() void ConsoleUI::PrintCommands() { + boost::mutex::scoped_lock lock(mutex); + tcout << "Commands:\n"; tcout << "\tp [file]: play file (enter full path)\n"; tcout << "\ts [n]: stop playing n-th file\n"; diff --git a/src/square/ConsoleUI.h b/src/square/ConsoleUI.h index 5d4d79d0c..52e3cf9f3 100644 --- a/src/square/ConsoleUI.h +++ b/src/square/ConsoleUI.h @@ -39,6 +39,8 @@ #include +#include + #include "Transport.h" #include "DummyAudioEventHandler.h" @@ -75,6 +77,8 @@ private: bool shouldQuit; private: Transport transport; private: DummyAudioEventHandler audioEventHandler; +private: boost::mutex mutex; + private: void ShutDown(); public: static DWORD WINAPI ThreadRun(LPVOID param); };