diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 12782f33e6..25fdd1f7f4 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -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) */ diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index 2daec610bd..9bc4b7b3ba 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -864,7 +864,7 @@ Editor::finish_bringing_in_audio (boost::shared_ptr 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 (); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index b4cb4c688c..9c0c896b14 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -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(arg)->freeze_thread (); } diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index 8caa808979..c1e1403ca2 100644 --- a/gtk2_ardour/editor_timefx.cc +++ b/gtk2_ardour/editor_timefx.cc @@ -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(arg); diff --git a/gtk2_ardour/export_region_dialog.cc b/gtk2_ardour/export_region_dialog.cc index cb3804c11b..1241d2bf90 100644 --- a/gtk2_ardour/export_region_dialog.cc +++ b/gtk2_ardour/export_region_dialog.cc @@ -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(arg)->export_region (); return 0; diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 8492ae1e05..e1481a19fc 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -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(arg)->freesound_search_thread (); 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 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 (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 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 > 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::AbstractUI (string name, bool with_signal_pipes) throw failed_constructor(); } - PBD::ThreadCreated.connect (mem_fun (*this, &AbstractUI::register_thread)); PBD::ThreadLeaving.connect (mem_fun (*this, &AbstractUI::unregister_thread)); PBD::ThreadCreatedWithRequestSize.connect (mem_fun (*this, &AbstractUI::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 ThreadCreated; - extern sigc::signal ThreadLeaving; - extern sigc::signal 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 ThreadLeaving; + extern sigc::signal 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 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 ThreadCreated; sigc::signal ThreadLeaving; sigc::signal 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();