diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-11-06 22:18:27 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-11-06 22:18:27 +0000 |
commit | 99aad0d4df5de53f71b7b43bd69e8affe615c971 (patch) | |
tree | 72811037315c3be00d9d49df6393a878123a7872 /libs | |
parent | d410d82ad893dbe02d2ea131c55706dec65dc256 (diff) |
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
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/analyser.cc | 2 | ||||
-rw-r--r-- | libs/ardour/audioengine.cc | 2 | ||||
-rw-r--r-- | libs/ardour/osc.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_butler.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_midi.cc | 2 | ||||
-rw-r--r-- | libs/ardour/source_factory.cc | 2 | ||||
-rw-r--r-- | libs/pbd/pbd/abstract_ui.cc | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/pthread_utils.h | 8 | ||||
-rw-r--r-- | libs/pbd/pthread_utils.cc | 18 | ||||
-rw-r--r-- | libs/surfaces/control_protocol/basic_ui.cc | 3 | ||||
-rw-r--r-- | libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc | 2 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol_poll.cc | 3 | ||||
-rw-r--r-- | libs/surfaces/tranzport/init.cc | 2 |
13 files changed, 32 insertions, 17 deletions
diff --git a/libs/ardour/analyser.cc b/libs/ardour/analyser.cc index 2e14c74b86..28eeeb190c 100644 --- a/libs/ardour/analyser.cc +++ b/libs/ardour/analyser.cc @@ -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 (); diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 8ea76f5844..787ed2346b 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -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 diff --git a/libs/ardour/osc.cc b/libs/ardour/osc.cc index 101e4cbd93..04090d35a1 100644 --- a/libs/ardour/osc.cc +++ b/libs/ardour/osc.cc @@ -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; } diff --git a/libs/ardour/session_butler.cc b/libs/ardour/session_butler.cc index 92ebc50580..9d4ee5678b 100644 --- a/libs/ardour/session_butler.cc +++ b/libs/ardour/session_butler.cc @@ -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; } diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 2f090ec4eb..ffd30fb42c 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -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 */ diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 7942bfa5e0..9064faa56d 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -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) { diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc index 7b21390764..bc33fc9a39 100644 --- a/libs/pbd/pbd/abstract_ui.cc +++ b/libs/pbd/pbd/abstract_ui.cc @@ -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)); } diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h index 157dab6c12..dd91e0a2b1 100644 --- a/libs/pbd/pbd/pthread_utils.h +++ b/libs/pbd/pbd/pthread_utils.h @@ -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__ */ diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index 0c9d574e73..c63f988af3 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -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) { diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index 7c032524f9..cda5497700 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -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 ) { diff --git a/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc b/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc index c874a05de5..5b413273ea 100644 --- a/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc +++ b/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc @@ -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 (); diff --git a/libs/surfaces/mackie/mackie_control_protocol_poll.cc b/libs/surfaces/mackie/mackie_control_protocol_poll.cc index b760b05aee..1b087222cd 100644 --- a/libs/surfaces/mackie/mackie_control_protocol_poll.cc +++ b/libs/surfaces/mackie/mackie_control_protocol_poll.cc @@ -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); diff --git a/libs/surfaces/tranzport/init.cc b/libs/surfaces/tranzport/init.cc index 94f85bdc56..726cb60d49 100644 --- a/libs/surfaces/tranzport/init.cc +++ b/libs/surfaces/tranzport/init.cc @@ -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(); |