From: <st...@us...> - 2003-06-12 22:47:04
|
Update of /cvsroot/iaxclient/iaxclient/simpleclient/wx In directory sc8-pr-cvs1:/tmp/cvs-serv22630 Modified Files: wx.cc Log Message: try doing GUILock for callbacks.. but, only if we're not the main thread.. Index: wx.cc =================================================================== RCS file: /cvsroot/iaxclient/iaxclient/simpleclient/wx/wx.cc,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- wx.cc 12 Jun 2003 20:41:17 -0000 1.26 +++ wx.cc 12 Jun 2003 22:47:01 -0000 1.27 @@ -22,6 +22,8 @@ #define LEVEL_MIN -50 #define DEFAULT_SILENCE_THRESHOLD 1 // positive is "auto" +#define TRY_GUILOCK + class IAXClient : public wxApp { public: @@ -119,10 +121,12 @@ bool pttState; // is the PTT button pressed? bool silenceMode; // are we in silence suppression mode? +#ifndef TRY_GUILOCK // values set by callbacks int inputLevel; int outputLevel; wxString statusString; +#endif protected: DECLARE_EVENT_TABLE() @@ -136,12 +140,11 @@ void IAXFrame::OnNotify() { +#ifndef TRY_GUILOCK static wxString lastStatus; static int lastInputLevel = 0; static int lastOutputLevel = 0; - if(pttMode) CheckPTT(); - if(statusString != lastStatus) { SetStatusText(statusString); lastStatus = statusString; @@ -156,6 +159,9 @@ output->SetValue(outputLevel); lastOutputLevel = outputLevel; } +#endif + + if(pttMode) CheckPTT(); } void IAXTimer::Notify() @@ -174,9 +180,11 @@ wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *row3sizer = new wxBoxSizer(wxHORIZONTAL); pttMode = false; +#ifndef TRY_GUILOCK inputLevel = 0; outputLevel = 0; statusString = _T("Welcome to IAXClient"); +#endif @@ -409,8 +417,11 @@ IAXFrame::~IAXFrame() { #ifdef __WXGTK__ +#if 0 + // apparently, I'm not supposed to destroy this, cause it's a "root" window gdk_window_destroy(keyStateWindow); #endif +#endif iaxc_stop_processing_thread(); iaxc_shutdown(); } @@ -428,11 +439,11 @@ { if(p.Found(_T("d"))) { optNoDialPad = true; - fprintf(stderr, "-d option found\n"); + //fprintf(stderr, "-d option found\n"); } if(p.GetParamCount() >= 1) { optDestination=p.GetParam(0); - fprintf(stderr, "dest is %s\n", optDestination.c_str()); + //fprintf(stderr, "dest is %s\n", optDestination.c_str()); } return true; @@ -487,22 +498,57 @@ */ void status_callback(char *msg) { +#ifdef TRY_GUILOCK + static wxString lastStatus; + if(lastStatus == msg) return; + + if (!wxThread::IsMain()) wxMutexGuiEnter(); + theFrame->SetStatusText(msg); + lastStatus = msg; + if (!wxThread::IsMain()) wxMutexGuiLeave(); +#else theFrame->statusString = wxString(msg); +#endif + } int levels_callback(float input, float output) { + int inputLevel, outputLevel; if (input < LEVEL_MIN) input = LEVEL_MIN; else if (input > LEVEL_MAX) input = LEVEL_MAX; - theFrame->inputLevel = (int)input - (LEVEL_MIN); + inputLevel = (int)input - (LEVEL_MIN); if (output < LEVEL_MIN) output = LEVEL_MIN; else if (input > LEVEL_MAX) output = LEVEL_MAX; + outputLevel = (int)output - (LEVEL_MIN); + +#ifdef TRY_GUILOCK + static int lastInputLevel = 0; + static int lastOutputLevel = 0; + + if (!wxThread::IsMain()) wxMutexGuiEnter(); + + if(lastInputLevel != inputLevel) { + theFrame->input->SetValue(inputLevel); + lastInputLevel = inputLevel; + } + + if(lastOutputLevel != outputLevel) { + theFrame->output->SetValue(outputLevel); + lastOutputLevel = outputLevel; + } + + if (!wxThread::IsMain()) wxMutexGuiLeave(); +#else + theFrame->inputLevel = (int)input - (LEVEL_MIN); theFrame->outputLevel = (int)output - (LEVEL_MIN); +#endif + return 0; } } |