wrap PBD::Thread... signals in a mutex to avoid crashing as multiple threads call it simultaneously; increase FUDGE distance for GTK/X11 when sizing comboboxselectors in editor

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4099 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2008-11-06 22:18:27 +00:00
parent d410d82ad8
commit 99aad0d4df
19 changed files with 38 additions and 23 deletions

View file

@ -2789,7 +2789,7 @@ Editor::setup_toolbar ()
#ifdef GTKOSX
const guint32 FUDGE = 38; // Combo's are stupid - they steal space from the entry for the button
#else
const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
const guint32 FUDGE = 24; // Combo's are stupid - they steal space from the entry for the button
#endif
/* Mode Buttons (tool selection) */

View file

@ -864,7 +864,7 @@ Editor::finish_bringing_in_audio (boost::shared_ptr<AudioRegion> region, uint32_
void *
Editor::_import_thread (void *arg)
{
PBD::ThreadCreated (pthread_self(), X_("Import"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Import"));
Editor *ed = (Editor *) arg;
return ed->import_thread ();

View file

@ -3554,7 +3554,7 @@ Editor::unfreeze_route ()
void*
Editor::_freeze_thread (void* arg)
{
PBD::ThreadCreated (pthread_self(), X_("Freeze"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Freeze"));
return static_cast<Editor*>(arg)->freeze_thread ();
}

View file

@ -427,7 +427,7 @@ Editor::do_timefx (TimeFXDialog& dialog)
void*
Editor::timefx_thread (void *arg)
{
PBD::ThreadCreated (pthread_self(), X_("TimeFX"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("TimeFX"));
TimeFXDialog* tsd = static_cast<TimeFXDialog*>(arg);

View file

@ -62,7 +62,7 @@ ExportRegionDialog::export_audio_data()
void*
ExportRegionDialog::_export_region_thread (void *arg)
{
PBD::ThreadCreated (pthread_self(), X_("Export Region"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Export Region"));
static_cast<ExportRegionDialog*>(arg)->export_region ();
return 0;

View file

@ -714,7 +714,7 @@ SoundFileBrowser::found_search_clicked ()
void*
freesound_search_thread_entry (void* arg)
{
PBD::ThreadCreated (pthread_self(), X_("Freesound Search"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Freesound Search"));
static_cast<SoundFileBrowser*>(arg)->freesound_search_thread ();

View file

@ -75,7 +75,7 @@ Analyser::queue_source_for_analysis (boost::shared_ptr<Source> src, bool force)
void
Analyser::work ()
{
PBD::ThreadCreated (pthread_self(), string ("analyser-") + to_string (pthread_self(), std::dec));
PBD::notify_gui_about_thread_creation (pthread_self(), string ("analyser-") + to_string (pthread_self(), std::dec));
while (true) {
analysis_queue_lock.lock ();

View file

@ -100,7 +100,7 @@ _thread_init_callback (void *arg)
knows about it.
*/
PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("Audioengine"), 4096);
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Audioengine"), 4096);
}
int

View file

@ -302,7 +302,7 @@ OSC::get_unix_server_url()
void *
OSC::_osc_receiver(void * arg)
{
PBD::ThreadCreated (pthread_self(), X_("OSC"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("OSC"));
static_cast<OSC*> (arg)->osc_receiver();
return 0;
}

View file

@ -155,7 +155,7 @@ Session::wait_till_butler_finished ()
void *
Session::_butler_thread_work (void* arg)
{
PBD::ThreadCreated (pthread_self(), X_("Butler"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Butler"));
return ((Session *) arg)->butler_thread_work ();
return 0;
}

View file

@ -1155,7 +1155,7 @@ Session::midi_thread_work ()
bool restart;
vector<MIDI::Port*> ports;
PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("MIDI"), 2048);
PBD::notify_gui_about_thread_creation (pthread_self(), X_("MIDI"), 2048);
memset (&rtparam, 0, sizeof (rtparam));
rtparam.sched_priority = 9; /* XXX should be relative to audio (JACK) thread */

View file

@ -54,7 +54,7 @@ std::list<boost::weak_ptr<AudioSource> > SourceFactory::files_with_peaks;
static void
peak_thread_work ()
{
PBD::ThreadCreated (pthread_self(), string ("peakbuilder-") + to_string (pthread_self(), std::dec));
PBD::notify_gui_about_thread_creation (pthread_self(), string ("peakbuilder-") + to_string (pthread_self(), std::dec));
while (true) {

View file

@ -17,7 +17,6 @@ AbstractUI<RequestObject>::AbstractUI (string name, bool with_signal_pipes)
throw failed_constructor();
}
PBD::ThreadCreated.connect (mem_fun (*this, &AbstractUI<RequestObject>::register_thread));
PBD::ThreadLeaving.connect (mem_fun (*this, &AbstractUI<RequestObject>::unregister_thread));
PBD::ThreadCreatedWithRequestSize.connect (mem_fun (*this, &AbstractUI<RequestObject>::register_thread_with_request_count));
}

View file

@ -35,9 +35,11 @@ void pthread_exit_pbd (void* status);
std::string pthread_name ();
namespace PBD {
extern sigc::signal<void,pthread_t,std::string> ThreadCreated;
extern sigc::signal<void,pthread_t> ThreadLeaving;
extern sigc::signal<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize;
extern void notify_gui_about_thread_creation (pthread_t, std::string, int requests = 256);
extern void notify_gui_about_thread_exit (pthread_t);
extern sigc::signal<void,pthread_t> ThreadLeaving;
extern sigc::signal<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize;
}
#endif /* __pbd_pthread_utils__ */

View file

@ -30,15 +30,31 @@ using namespace std;
typedef std::map<string,pthread_t> ThreadMap;
static ThreadMap all_threads;
static pthread_mutex_t thread_map_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t gui_notify_lock = PTHREAD_MUTEX_INITIALIZER;
namespace PBD {
sigc::signal<void,pthread_t,std::string> ThreadCreated;
sigc::signal<void,pthread_t> ThreadLeaving;
sigc::signal<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize;
}
using namespace PBD;
void
PBD::notify_gui_about_thread_creation (pthread_t thread, std::string str, int request_count)
{
pthread_mutex_lock (&gui_notify_lock);
ThreadCreatedWithRequestSize (thread, str, request_count);
pthread_mutex_unlock (&gui_notify_lock);
}
void
PBD::notify_gui_about_thread_exit (pthread_t thread)
{
pthread_mutex_lock (&gui_notify_lock);
ThreadLeaving (thread);
pthread_mutex_unlock (&gui_notify_lock);
}
int
pthread_create_and_store (string name, pthread_t *thread, pthread_attr_t *attr, void * (*start_routine)(void *), void * arg)
{

View file

@ -49,10 +49,9 @@ BasicUI::~BasicUI ()
void
BasicUI::register_thread (std::string name)
{
PBD::ThreadCreated (pthread_self(), name);
PBD::notify_gui_about_thread_creation (pthread_self(), name);
}
void
BasicUI::access_action ( std::string action_path )
{

View file

@ -1029,7 +1029,7 @@ TranzportControlProtocol::monitor_work ()
uint8_t offline = 0;
PBD::ThreadCreated (pthread_self(), X_("Tranzport"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Tranzport"));
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
next_track ();

View file

@ -41,8 +41,7 @@ bool MackieControlProtocol::probe()
void * MackieControlProtocol::monitor_work()
{
// What does ThreadCreatedWithRequestSize do?
PBD::ThreadCreated (pthread_self(), X_("Mackie"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Mackie"));
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);

View file

@ -173,7 +173,7 @@ TranzportControlProtocol::monitor_work ()
bool first_time = true;
uint8_t offline = 0;
PBD::ThreadCreated (pthread_self(), X_("Tranzport"));
PBD::notify_gui_about_thread_creation (pthread_self(), X_("Tranzport"));
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
rtpriority_set();