diff options
Diffstat (limited to 'libs')
67 files changed, 441 insertions, 497 deletions
diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index 4f46451907..45f62fc7b9 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -72,7 +72,7 @@ class AudioSource : virtual public Source, sframes_t start, nframes_t cnt, double samples_per_visual_peak) const; int build_peaks (); - bool peaks_ready (boost::function<void()> callWhenReady, PBD::Connection& connection_created_if_not_ready) const; + bool peaks_ready (boost::function<void()> callWhenReady, PBD::Connection& connection_created_if_not_ready, PBD::EventLoop* event_loop) const; mutable PBD::Signal0<void> PeaksReady; mutable PBD::Signal2<void,nframes_t,nframes_t> PeakRangeReady; diff --git a/libs/ardour/ardour/midi_ui.h b/libs/ardour/ardour/midi_ui.h index c21182f4e2..819b70df43 100644 --- a/libs/ardour/ardour/midi_ui.h +++ b/libs/ardour/ardour/midi_ui.h @@ -30,6 +30,8 @@ class MidiControlUI : public AbstractUI<MidiUIRequest> public: MidiControlUI (Session& s); ~MidiControlUI (); + + static MidiControlUI* instance() { return _instance; } static BaseUI::RequestType PortChange; @@ -48,6 +50,8 @@ class MidiControlUI : public AbstractUI<MidiUIRequest> bool midi_input_handler (Glib::IOCondition, MIDI::Port*); void reset_ports (); void clear_ports (); + + static MidiControlUI* _instance; }; } diff --git a/libs/ardour/ardour/session_event.h b/libs/ardour/ardour/session_event.h index 66c8720186..2ce2d5225a 100644 --- a/libs/ardour/ardour/session_event.h +++ b/libs/ardour/ardour/session_event.h @@ -7,7 +7,7 @@ #include "pbd/pool.h" #include "pbd/ringbuffer.h" -#include "pbd/ui_callback.h" +#include "pbd/event_loop.h" #include "ardour/types.h" @@ -73,7 +73,7 @@ struct SessionEvent { boost::shared_ptr<RouteList> routes; /* apply to */ boost::function<void (void)> rt_slot; /* what to call in RT context */ RTeventCallback rt_return; /* called after rt_slot, with this event as an argument */ - PBD::UICallback* ui; + PBD::EventLoop* event_loop; std::list<AudioRange> audio_range; std::list<MusicRange> music_range; @@ -88,7 +88,7 @@ struct SessionEvent { , speed (spd) , yes_or_no (yn) , second_yes_or_no (yn2) - , ui (0) {} + , event_loop (0) {} void set_ptr (void* p) { ptr = p; diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index f60d16391f..f8dc553ae0 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -44,6 +44,7 @@ #include "ardour/audio_port.h" #include "ardour/audioengine.h" #include "ardour/audiofilesource.h" + #include "ardour/audioplaylist.h" #include "ardour/audioregion.h" #include "ardour/butler.h" @@ -1504,7 +1505,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca continue; /* XXX is this OK? */ } - region->GoingAway.connect (*this, boost::bind (&Diskstream::remove_region_from_last_capture, this, boost::weak_ptr<Region>(region))); + region->GoingAway.connect_same_thread (*this, boost::bind (&Diskstream::remove_region_from_last_capture, this, boost::weak_ptr<Region>(region))); _last_capture_regions.push_back (region); diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index 85c3ffe1b2..3379868d60 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -528,8 +528,8 @@ AudioPlaylist::add_crossfade (boost::shared_ptr<Crossfade> xfade) } else { _crossfades.push_back (xfade); - xfade->Invalidated.connect (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1)); - xfade->StateChanged.connect (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1)); + xfade->Invalidated.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1)); + xfade->StateChanged.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1)); notify_crossfade_added (xfade); } @@ -584,8 +584,8 @@ AudioPlaylist::set_state (const XMLNode& node, int version) try { boost::shared_ptr<Crossfade> xfade = boost::shared_ptr<Crossfade> (new Crossfade (*((const Playlist *)this), *child)); _crossfades.push_back (xfade); - xfade->Invalidated.connect (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1)); - xfade->StateChanged.connect (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1)); + xfade->Invalidated.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1)); + xfade->StateChanged.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1)); NewCrossfade(xfade); } diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index 19b5bd7be5..502c3a7220 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -182,7 +182,7 @@ AudioTrack::set_diskstream (boost::shared_ptr<AudioDiskstream> ds, void * /*src* if (audio_diskstream()->deprecated_io_node) { if (!IO::connecting_legal) { - IO::ConnectingLegal.connect (*this, boost::bind (&AudioTrack::deprecated_use_diskstream_connections, this)); + IO::ConnectingLegal.connect_same_thread (*this, boost::bind (&AudioTrack::deprecated_use_diskstream_connections, this)); } else { deprecated_use_diskstream_connections (); } @@ -304,7 +304,7 @@ AudioTrack::_set_state (const XMLNode& node, int version, bool call_base) pending_state = const_cast<XMLNode*> (&node); if (_session.state_of_the_state() & Session::Loading) { - _session.StateReady.connect (*this, boost::bind (&AudioTrack::set_state_part_two, this)); + _session.StateReady.connect_same_thread (*this, boost::bind (&AudioTrack::set_state_part_two, this)); } else { set_state_part_two (); } diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index cce7869072..24febdd86a 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -96,7 +96,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n { boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src); if (afs) { - afs->HeaderPositionOffsetChanged.connect (*this, boost::bind (&AudioRegion::source_offset_changed, this)); + afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this)); } init (); @@ -113,7 +113,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n { boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src); if (afs) { - afs->HeaderPositionOffsetChanged.connect (*this, boost::bind (&AudioRegion::source_offset_changed, this)); + afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this)); } init (); @@ -205,7 +205,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, const Sour boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> ((*i)); if (afs) { - afs->HeaderPositionOffsetChanged.connect (*this, boost::bind (&AudioRegion::source_offset_changed, this)); + afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this)); } } @@ -229,7 +229,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, const XMLNode& nod { boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src); if (afs) { - afs->HeaderPositionOffsetChanged.connect (*this, boost::bind (&AudioRegion::source_offset_changed, this)); + afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this)); } init (); @@ -270,7 +270,7 @@ void AudioRegion::connect_to_analysis_changed () { for (SourceList::const_iterator i = _sources.begin(); i != _sources.end(); ++i) { - (*i)->AnalysisChanged.connect (*this, boost::bind (&AudioRegion::invalidate_transients, this)); + (*i)->AnalysisChanged.connect_same_thread (*this, boost::bind (&AudioRegion::invalidate_transients, this)); } } @@ -285,7 +285,7 @@ AudioRegion::connect_to_header_position_offset_changed () unique_srcs.insert (*i); boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (*i); if (afs) { - afs->HeaderPositionOffsetChanged.connect (*this, boost::bind (&AudioRegion::source_offset_changed, this)); + afs->HeaderPositionOffsetChanged.connect_same_thread (*this, boost::bind (&AudioRegion::source_offset_changed, this)); } } } @@ -294,9 +294,9 @@ AudioRegion::connect_to_header_position_offset_changed () void AudioRegion::listen_to_my_curves () { - _envelope->StateChanged.connect (*this, boost::bind (&AudioRegion::envelope_changed, this)); - _fade_in->StateChanged.connect (*this, boost::bind (&AudioRegion::fade_in_changed, this)); - _fade_out->StateChanged.connect (*this, boost::bind (&AudioRegion::fade_out_changed, this)); + _envelope->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::envelope_changed, this)); + _fade_in->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::fade_in_changed, this)); + _fade_out->StateChanged.connect_same_thread (*this, boost::bind (&AudioRegion::fade_out_changed, this)); } void diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 5fcabb0c77..0c820eed4d 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -149,7 +149,7 @@ AudioSource::update_length (sframes_t pos, sframes_t cnt) ***********************************************************************/ bool -AudioSource::peaks_ready (boost::function<void()> doThisWhenReady, Connection& connect_here_if_not) const +AudioSource::peaks_ready (boost::function<void()> doThisWhenReady, Connection& connect_here_if_not, EventLoop* event_loop) const { bool ret; Glib::Mutex::Lock lm (_peaks_ready_lock); @@ -159,7 +159,7 @@ AudioSource::peaks_ready (boost::function<void()> doThisWhenReady, Connection& c */ if (!(ret = _peaks_built)) { - PeaksReady.connect (connect_here_if_not, doThisWhenReady); + PeaksReady.connect (connect_here_if_not, doThisWhenReady, event_loop); } return ret; diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 1e28ebc8b4..82ec91cafd 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -72,7 +72,7 @@ Auditioner::Auditioner (Session& s) _main_outs->allow_pan_reset (); _main_outs->reset_panner (); - _output->changed.connect (*this, boost::bind (&Auditioner::output_changed, this, _1, _2)); + _output->changed.connect_same_thread (*this, boost::bind (&Auditioner::output_changed, this, _1, _2)); the_region.reset ((AudioRegion*) 0); g_atomic_int_set (&_active, 0); diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc index 1438f93722..902dbc9705 100644 --- a/libs/ardour/delivery.cc +++ b/libs/ardour/delivery.cc @@ -64,10 +64,10 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Mute _display_to_user = false; if (_output) { - _output->changed.connect (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); + _output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); } - CycleStart.connect (*this, boost::bind (&Delivery::cycle_start, this, _1)); + CycleStart.connect_same_thread (*this, boost::bind (&Delivery::cycle_start, this, _1)); } /* deliver to a new IO object */ @@ -88,10 +88,10 @@ Delivery::Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const string& _display_to_user = false; if (_output) { - _output->changed.connect (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); + _output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); } - CycleStart.connect (*this, boost::bind (&Delivery::cycle_start, this, _1)); + CycleStart.connect_same_thread (*this, boost::bind (&Delivery::cycle_start, this, _1)); } /* deliver to a new IO object, reconstruct from XML */ @@ -116,10 +116,10 @@ Delivery::Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const XMLNode& } if (_output) { - _output->changed.connect (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); + _output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); } - CycleStart.connect (*this, boost::bind (&Delivery::cycle_start, this, _1)); + CycleStart.connect_same_thread (*this, boost::bind (&Delivery::cycle_start, this, _1)); } /* deliver to an existing IO object, reconstruct from XML */ @@ -144,10 +144,10 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> out, boost::shared_ptr<Mut } if (_output) { - _output->changed.connect (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); + _output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); } - CycleStart.connect (*this, boost::bind (&Delivery::cycle_start, this, _1)); + CycleStart.connect_same_thread (*this, boost::bind (&Delivery::cycle_start, this, _1)); } std::string @@ -419,7 +419,7 @@ Delivery::reset_panner () } } else { panner_legal_c.disconnect (); - PannersLegal.connect (panner_legal_c, boost::bind (&Delivery::panners_became_legal, this)); + PannersLegal.connect_same_thread (panner_legal_c, boost::bind (&Delivery::panners_became_legal, this)); } } diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index 8af85a553c..a37323de84 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -142,13 +142,13 @@ Diskstream::set_route (Route& r) _io = _route->input(); ic_connection.disconnect(); - _io->changed.connect (ic_connection, boost::bind (&Diskstream::handle_input_change, this, _1, _2)); + _io->changed.connect_same_thread (ic_connection, boost::bind (&Diskstream::handle_input_change, this, _1, _2)); input_change_pending = ConfigurationChanged; non_realtime_input_change (); set_align_style_from_io (); - _route->GoingAway.connect (*this, boost::bind (&Diskstream::route_going_away, this)); + _route->GoingAway.connect_same_thread (*this, boost::bind (&Diskstream::route_going_away, this)); } void @@ -339,9 +339,9 @@ Diskstream::use_playlist (boost::shared_ptr<Playlist> playlist) reset_write_sources (false); } - _playlist->Modified.connect (playlist_connections, boost::bind (&Diskstream::playlist_modified, this)); - _playlist->GoingAway.connect (playlist_connections, boost::bind (&Diskstream::playlist_deleted, this, boost::weak_ptr<Playlist>(_playlist))); - _playlist->RangesMoved.connect (playlist_connections, boost::bind (&Diskstream::playlist_ranges_moved, this, _1)); + _playlist->Modified.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_modified, this)); + _playlist->GoingAway.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_deleted, this, boost::weak_ptr<Playlist>(_playlist))); + _playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_ranges_moved, this, _1)); } /* don't do this if we've already asked for it *or* if we are setting up diff --git a/libs/ardour/export_channel.cc b/libs/ardour/export_channel.cc index dfe038734b..80e672038e 100644 --- a/libs/ardour/export_channel.cc +++ b/libs/ardour/export_channel.cc @@ -108,7 +108,7 @@ RegionExportChannelFactory::RegionExportChannelFactory (Session * session, Audio throw ExportFailed ("Unhandled type in ExportChannelFactory constructor"); } - session->ProcessExport.connect (export_connection, boost::bind (&RegionExportChannelFactory::new_cycle_started, this, _1)); + session->ProcessExport.connect_same_thread (export_connection, boost::bind (&RegionExportChannelFactory::new_cycle_started, this, _1)); buffers.set_count (ChanCount (DataType::AUDIO, n_channels)); buffers.ensure_buffers (DataType::AUDIO, n_channels, frames_per_cycle); diff --git a/libs/ardour/export_format_manager.cc b/libs/ardour/export_format_manager.cc index d25877c5bc..51c1771ae7 100644 --- a/libs/ardour/export_format_manager.cc +++ b/libs/ardour/export_format_manager.cc @@ -211,13 +211,13 @@ void ExportFormatManager::add_compatibility (CompatPtr ptr) { compatibilities.push_back (ptr); - ptr->SelectChanged.connect (*this, boost::bind (&ExportFormatManager::change_compatibility_selection, this, _1, WeakCompatPtr (ptr))); + ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_compatibility_selection, this, _1, WeakCompatPtr (ptr))); } void ExportFormatManager::add_quality (QualityPtr ptr) { - ptr->SelectChanged.connect (*this, boost::bind (&ExportFormatManager::change_quality_selection, this, _1, WeakQualityPtr (ptr))); + ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_quality_selection, this, _1, WeakQualityPtr (ptr))); qualities.push_back (ptr); } @@ -225,7 +225,7 @@ void ExportFormatManager::add_format (FormatPtr ptr) { formats.push_back (ptr); - ptr->SelectChanged.connect (*this, boost::bind (&ExportFormatManager::change_format_selection, this, _1, WeakFormatPtr (ptr))); + ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_format_selection, this, _1, WeakFormatPtr (ptr))); universal_set = universal_set->get_union (*ptr); /* Encoding options */ @@ -233,15 +233,15 @@ ExportFormatManager::add_format (FormatPtr ptr) boost::shared_ptr<HasSampleFormat> hsf; if (hsf = boost::dynamic_pointer_cast<HasSampleFormat> (ptr)) { - hsf->SampleFormatSelectChanged.connect (*this, boost::bind (&ExportFormatManager::change_sample_format_selection, this, _1, _2)); - hsf->DitherTypeSelectChanged.connect (*this, boost::bind (&ExportFormatManager::change_dither_type_selection, this, _1, _2)); + hsf->SampleFormatSelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_sample_format_selection, this, _1, _2)); + hsf->DitherTypeSelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_dither_type_selection, this, _1, _2)); } } void ExportFormatManager::add_sample_rate (SampleRatePtr ptr) { - ptr->SelectChanged.connect (*this, boost::bind (&ExportFormatManager::change_sample_rate_selection, this, _1, WeakSampleRatePtr (ptr))); + ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_sample_rate_selection, this, _1, WeakSampleRatePtr (ptr))); sample_rates.push_back (ptr); } diff --git a/libs/ardour/export_formats.cc b/libs/ardour/export_formats.cc index a7dd544d47..eb9be6183b 100644 --- a/libs/ardour/export_formats.cc +++ b/libs/ardour/export_formats.cc @@ -59,10 +59,10 @@ HasSampleFormat::add_sample_format (ExportFormatBase::SampleFormat format) SampleFormatPtr ptr (new SampleFormatState (format, get_sample_format_name (format))); sample_format_states.push_back (ptr); - ptr->SelectChanged.connect (*this, boost::bind (&HasSampleFormat::update_sample_format_selection, this, _1)); + ptr->SelectChanged.connect_same_thread (*this, boost::bind (&HasSampleFormat::update_sample_format_selection, this, _1)); // BOOST SIGNALS how to connect one signal to another - // ptr->SelectChanged.connect (*this, boost::bind (SampleFormatSelectChanged, _1, WeakSampleFormatPtr (ptr)); - // ptr->CompatibleChanged.connect (*this, boost::bind (SampleFormatCompatibleChanged, _1, WeakSampleFormatPtr (ptr)); + // ptr->SelectChanged.connect_same_thread (*this, boost::bind (SampleFormatSelectChanged, _1, WeakSampleFormatPtr (ptr)); + // ptr->CompatibleChanged.connect_same_thread (*this, boost::bind (SampleFormatCompatibleChanged, _1, WeakSampleFormatPtr (ptr)); } void @@ -70,10 +70,10 @@ HasSampleFormat::add_dither_type (ExportFormatBase::DitherType type, Glib::ustri { DitherTypePtr ptr (new DitherTypeState (type, name)); dither_type_states.push_back (ptr); - ptr->SelectChanged.connect (*this, boost::bind (&HasSampleFormat::update_dither_type_selection, this, _1)); + ptr->SelectChanged.connect_same_thread (*this, boost::bind (&HasSampleFormat::update_dither_type_selection, this, _1)); // BOOST SIGNALS how to connect one signal to another - // ptr->SelectChanged.connect (*this, boost::bind (DitherTypeSelectChanged, _1, WeakDitherTypePtr (ptr)); - // ptr->CompatibleChanged.connect (*this, boost::bind (DitherTypeCompatibleChanged, _1, WeakDitherTypePtr (ptr)); + // ptr->SelectChanged.connect_same_thread (*this, boost::bind (DitherTypeSelectChanged, _1, WeakDitherTypePtr (ptr)); + // ptr->CompatibleChanged.connect_same_thread (*this, boost::bind (DitherTypeCompatibleChanged, _1, WeakDitherTypePtr (ptr)); } HasSampleFormat::SampleFormatPtr diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index a85e41d40a..b78fc20f7e 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -106,7 +106,7 @@ ExportHandler::ExportHandler (Session & session) { processor.reset (new ExportProcessor (session)); - ExportProcessor::WritingFile.connect (files_written_connection, boost::bind (&ExportHandler::add_file, this, _1)); + ExportProcessor::WritingFile.connect_same_thread (files_written_connection, boost::bind (&ExportHandler::add_file, this, _1)); } ExportHandler::~ExportHandler () @@ -168,7 +168,7 @@ ExportHandler::do_export (bool rt) realtime = rt; - session.ExportReadFinished.connect (export_read_finished_connection, boost::bind (&ExportHandler::finish_timespan, this)); + session.ExportReadFinished.connect_same_thread (export_read_finished_connection, boost::bind (&ExportHandler::finish_timespan, this)); start_timespan (); } @@ -505,7 +505,7 @@ ExportHandler::start_timespan () /* connect stuff and start export */ - session.ProcessExport.connect (current_timespan->process_connection, boost::bind (&ExportTimespan::process, current_timespan, _1)); + session.ProcessExport.connect_same_thread (current_timespan->process_connection, boost::bind (&ExportTimespan::process, current_timespan, _1)); session.start_audio_export (current_timespan->get_start(), realtime); } @@ -566,7 +566,7 @@ ExportHandler::timespan_thread_finished () cc = current_map_it->second.channel_config; } - cc->FilesWritten.connect (channel_config_connection, boost::bind (&ExportHandler::timespan_thread_finished, this)); + cc->FilesWritten.connect_same_thread (channel_config_connection, boost::bind (&ExportHandler::timespan_thread_finished, this)); ++current_map_it; } else { /* All files are written from current timespan, reset timespan and start new */ diff --git a/libs/ardour/internal_return.cc b/libs/ardour/internal_return.cc index f42d3c4e80..279472e02d 100644 --- a/libs/ardour/internal_return.cc +++ b/libs/ardour/internal_return.cc @@ -33,14 +33,14 @@ InternalReturn::InternalReturn (Session& s) : Return (s, true) , user_count (0) { - CycleStart.connect (*this, boost::bind (&InternalReturn::cycle_start, this, _1)); + CycleStart.connect_same_thread (*this, boost::bind (&InternalReturn::cycle_start, this, _1)); } InternalReturn::InternalReturn (Session& s, const XMLNode& node) : Return (s, node, true) , user_count (0) { - CycleStart.connect (*this, boost::bind (&InternalReturn::cycle_start, this, _1)); + CycleStart.connect_same_thread (*this, boost::bind (&InternalReturn::cycle_start, this, _1)); } void diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc index 8e9010b148..368eff2be4 100644 --- a/libs/ardour/internal_send.cc +++ b/libs/ardour/internal_send.cc @@ -43,8 +43,8 @@ InternalSend::InternalSend (Session& s, boost::shared_ptr<MuteMaster> mm, boost: set_name (sendto->name()); - _send_to->GoingAway.connect (*this, boost::bind (&InternalSend::send_to_going_away, this)); - _send_to->NameChanged.connect (*this, boost::bind (&InternalSend::send_to_name_changed, this)); + _send_to->GoingAway.connect_same_thread (*this, boost::bind (&InternalSend::send_to_going_away, this)); + _send_to->NameChanged.connect_same_thread (*this, boost::bind (&InternalSend::send_to_name_changed, this)); } InternalSend::InternalSend (Session& s, boost::shared_ptr<MuteMaster> mm, const XMLNode& node) @@ -187,7 +187,7 @@ InternalSend::set_our_state (const XMLNode& node, int /*version*/) */ if (!IO::connecting_legal) { - IO::ConnectingLegal.connect (connect_c, boost::bind (&InternalSend::connect_when_legal, this)); + IO::ConnectingLegal.connect_same_thread (connect_c, boost::bind (&InternalSend::connect_when_legal, this)); } else { connect_when_legal (); } diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index f47e147a18..9066acac91 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -566,7 +566,7 @@ IO::set_state (const XMLNode& node, int version) pending_state_node = new XMLNode (node); pending_state_node_version = version; pending_state_node_in = false; - ConnectingLegal.connect (connection_legal_c, boost::bind (&IO::connecting_became_legal, this)); + ConnectingLegal.connect_same_thread (connection_legal_c, boost::bind (&IO::connecting_became_legal, this)); } @@ -619,7 +619,7 @@ IO::set_state_2X (const XMLNode& node, int version, bool in) pending_state_node = new XMLNode (node); pending_state_node_version = version; pending_state_node_in = in; - ConnectingLegal.connect (connection_legal_c, boost::bind (&IO::connecting_became_legal, this)); + ConnectingLegal.connect_same_thread (connection_legal_c, boost::bind (&IO::connecting_became_legal, this)); } return 0; @@ -1399,7 +1399,7 @@ IO::bundles_connected () IO::UserBundleInfo::UserBundleInfo (IO* io, boost::shared_ptr<UserBundle> b) { bundle = b; - b->Changed.connect (changed, boost::bind (&IO::bundle_changed, io, _1)); + b->Changed.connect_same_thread (changed, boost::bind (&IO::bundle_changed, io, _1)); } std::string diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc index 7303059207..3a43580d64 100644 --- a/libs/ardour/midi_clock_slave.cc +++ b/libs/ardour/midi_clock_slave.cc @@ -76,11 +76,11 @@ MIDIClock_Slave::rebind (MIDI::Port& p) std::cerr << "MIDIClock_Slave: connecting to port " << port->name() << std::endl; #endif - port->input()->timing.connect (port_connections, boost::bind (&MIDIClock_Slave::update_midi_clock, this, _1, _2)); - port->input()->start.connect (port_connections, boost::bind (&MIDIClock_Slave::start, this, _1, _2)); - port->input()->contineu.connect (port_connections, boost::bind (&MIDIClock_Slave::contineu, this, _1, _2)); - port->input()->stop.connect (port_connections, boost::bind (&MIDIClock_Slave::stop, this, _1, _2)); - port->input()->position.connect (port_connections, boost::bind (&MIDIClock_Slave::position, this, _1, _2, 3)); + port->input()->timing.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::update_midi_clock, this, _1, _2)); + port->input()->start.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::start, this, _1, _2)); + port->input()->contineu.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::contineu, this, _1, _2)); + port->input()->stop.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::stop, this, _1, _2)); + port->input()->position.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::position, this, _1, _2, 3)); } void diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 2320bd4be4..17c1404358 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -1024,7 +1024,7 @@ MidiDiskstream::transport_stopped (struct tm& /*when*/, time_t /*twhen*/, bool a continue; /* XXX is this OK? */ } - region->GoingAway.connect (*this, boost::bind (&Diskstream::remove_region_from_last_capture, this, boost::weak_ptr<Region>(region))); + region->GoingAway.connect_same_thread (*this, boost::bind (&Diskstream::remove_region_from_last_capture, this, boost::weak_ptr<Region>(region))); _last_capture_regions.push_back (region); diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index b477dbb2f9..7bb995337f 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -52,7 +52,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, nframes_t start, nfra : Region (src, start, length, PBD::basename_nosuffix(src->name()), DataType::MIDI, 0, Region::Flag(Region::DefaultFlags|Region::External)) { assert(_name.find("/") == string::npos); - midi_source(0)->Switched.connect (*this, boost::bind (&MidiRegion::switch_source, this, _1)); + midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1)); } /* Basic MidiRegion constructor (one channel) */ @@ -60,7 +60,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, nframes_t start, nfra : Region (src, start, length, name, DataType::MIDI, layer, flags) { assert(_name.find("/") == string::npos); - midi_source(0)->Switched.connect (*this, boost::bind (&MidiRegion::switch_source, this, _1)); + midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1)); } /* Basic MidiRegion constructor (many channels) */ @@ -68,7 +68,7 @@ MidiRegion::MidiRegion (const SourceList& srcs, nframes_t start, nframes_t lengt : Region (srcs, start, length, name, DataType::MIDI, layer, flags) { assert(_name.find("/") == string::npos); - midi_source(0)->Switched.connect (*this, boost::bind (&MidiRegion::switch_source, this, _1)); + midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1)); } @@ -77,14 +77,14 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, nframes_t off : Region (other, offset, length, name, layer, flags) { assert(_name.find("/") == string::npos); - midi_source(0)->Switched.connect (*this, boost::bind (&MidiRegion::switch_source, this, _1)); + midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1)); } MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other) : Region (other) { assert(_name.find("/") == string::npos); - midi_source(0)->Switched.connect (*this, boost::bind (&MidiRegion::switch_source, this, _1)); + midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1)); } MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, const XMLNode& node) @@ -94,7 +94,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<MidiSource> src, const XMLNode& node) throw failed_constructor(); } - midi_source(0)->Switched.connect (*this, boost::bind (&MidiRegion::switch_source, this, _1)); + midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1)); assert(_name.find("/") == string::npos); assert(_type == DataType::MIDI); } @@ -106,7 +106,7 @@ MidiRegion::MidiRegion (const SourceList& srcs, const XMLNode& node) throw failed_constructor(); } - midi_source(0)->Switched.connect (*this, boost::bind (&MidiRegion::switch_source, this, _1)); + midi_source(0)->Switched.connect_same_thread (*this, boost::bind (&MidiRegion::switch_source, this, _1)); assert(_name.find("/") == string::npos); assert(_type == DataType::MIDI); } diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index a6c64c3c30..2fe0616973 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -230,7 +230,7 @@ MidiTrack::_set_state (const XMLNode& node, int version, bool call_base) pending_state = const_cast<XMLNode*> (&node); if (_session.state_of_the_state() & Session::Loading) { - _session.StateReady.connect (*this, boost::bind (&MidiTrack::set_state_part_two, this)); + _session.StateReady.connect_same_thread (*this, boost::bind (&MidiTrack::set_state_part_two, this)); } else { set_state_part_two (); } diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc index 38f856b5a2..70be1f345d 100644 --- a/libs/ardour/midi_ui.cc +++ b/libs/ardour/midi_ui.cc @@ -39,6 +39,7 @@ using namespace Glib; #include "i18n.h" BaseUI::RequestType MidiControlUI::PortChange = BaseUI::new_request_type(); +MidiControlUI* MidiControlUI::_instance = 0; #include "pbd/abstract_ui.cc" /* instantiate the template */ @@ -46,12 +47,14 @@ MidiControlUI::MidiControlUI (Session& s) : AbstractUI<MidiUIRequest> (_("midiui")) , _session (s) { - MIDI::Manager::instance()->PortsChanged.connect (rebind_connection, boost::bind (&MidiControlUI::change_midi_ports, this)); + MIDI::Manager::instance()->PortsChanged.connect_same_thread (rebind_connection, boost::bind (&MidiControlUI::change_midi_ports, this)); + _instance = this; } MidiControlUI::~MidiControlUI () { clear_ports (); + _instance = 0; } void diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc index 91ac47c883..c713925475 100644 --- a/libs/ardour/mtc_slave.cc +++ b/libs/ardour/mtc_slave.cc @@ -92,9 +92,9 @@ MTC_Slave::rebind (MIDI::Port& p) port = &p; - port->input()->mtc_time.connect (port_connections, boost::bind (&MTC_Slave::update_mtc_time, this, _1, _2, _3)); - port->input()->mtc_qtr.connect (port_connections, boost::bind (&MTC_Slave::update_mtc_qtr, this, _1, _2, _3)); - port->input()->mtc_status.connect (port_connections, boost::bind (&MTC_Slave::update_mtc_status, this, _1)); + port->input()->mtc_time.connect_same_thread (port_connections, boost::bind (&MTC_Slave::update_mtc_time, this, _1, _2, _3)); + port->input()->mtc_qtr.connect_same_thread (port_connections, boost::bind (&MTC_Slave::update_mtc_qtr, this, _1, _2, _3)); + port->input()->mtc_status.connect_same_thread (port_connections, boost::bind (&MTC_Slave::update_mtc_status, this, _1)); } void diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 985cd6740a..e638a7a6b0 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -270,7 +270,7 @@ Playlist::init (bool hide) freeze_length = 0; _explicit_relayering = false; - Modified.connect (*this, boost::bind (&Playlist::mark_session_dirty, this)); + Modified.connect_same_thread (*this, boost::bind (&Playlist::mark_session_dirty, this)); } Playlist::~Playlist () @@ -605,7 +605,7 @@ Playlist::add_region_internal (boost::shared_ptr<Region> region, nframes_t posit } } - region->StateChanged.connect (region_state_changed_connections, boost::bind (&Playlist::region_changed_proxy, this, _1, boost::weak_ptr<Region> (region))); + region->StateChanged.connect_same_thread (region_state_changed_connections, boost::bind (&Playlist::region_changed_proxy, this, _1, boost::weak_ptr<Region> (region))); return true; } diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 731a7c04dd..d706421c39 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -109,7 +109,7 @@ Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length _sources.push_back (src); _master_sources.push_back (src); - src->GoingAway.connect (*this, boost::bind (&Region::source_deleted, this, boost::weak_ptr<Source>(src))); + src->GoingAway.connect_same_thread (*this, boost::bind (&Region::source_deleted, this, boost::weak_ptr<Source>(src))); assert(_sources.size() > 0); _positional_lock_style = AudioTime; @@ -1586,14 +1586,14 @@ Region::use_sources (SourceList const & s) for (SourceList::const_iterator i = s.begin (); i != s.end(); ++i) { _sources.push_back (*i); - (*i)->GoingAway.connect (*this, boost::bind (&Region::source_deleted, this, boost::weak_ptr<Source>(*i))); + (*i)->GoingAway.connect_same_thread (*this, boost::bind (&Region::source_deleted, this, boost::weak_ptr<Source>(*i))); unique_srcs.insert (*i); } for (SourceList::const_iterator i = s.begin (); i != s.end(); ++i) { _master_sources.push_back (*i); if (unique_srcs.find (*i) == unique_srcs.end()) { - (*i)->GoingAway.connect (*this, boost::bind (&Region::source_deleted, this, boost::weak_ptr<Source>(*i))); + (*i)->GoingAway.connect_same_thread (*this, boost::bind (&Region::source_deleted, this, boost::weak_ptr<Source>(*i))); } } } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index eeb8ae83c1..c652023e2c 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -93,7 +93,7 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type) /* now that we have _meter, its safe to connect to this */ - Metering::Meter.connect (*this, (boost::bind (&Route::meter, this))); + Metering::Meter.connect_same_thread (*this, (boost::bind (&Route::meter, this))); } Route::Route (Session& sess, const XMLNode& node, DataType default_type) @@ -109,7 +109,7 @@ Route::Route (Session& sess, const XMLNode& node, DataType default_type) /* now that we have _meter, its safe to connect to this */ - Metering::Meter.connect (*this, (boost::bind (&Route::meter, this))); + Metering::Meter.connect_same_thread (*this, (boost::bind (&Route::meter, this))); } void @@ -147,8 +147,8 @@ Route::init () _input.reset (new IO (_session, _name, IO::Input, _default_type)); _output.reset (new IO (_session, _name, IO::Output, _default_type)); - _input->changed.connect (*this, boost::bind (&Route::input_change_handler, this, _1, _2)); - _output->changed.connect (*this, boost::bind (&Route::output_change_handler, this, _1, _2)); + _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2)); + _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2)); /* add amp processor */ @@ -792,7 +792,7 @@ Route::add_processor (boost::shared_ptr<Processor> processor, ProcessorList::ite // XXX: do we want to emit the signal here ? change call order. processor->activate (); } - processor->ActiveChanged.connect (*this, boost::bind (&Session::update_latency_compensation, &_session, false, false)); + processor->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false, false)); _output->set_user_latency (0); } @@ -1047,7 +1047,7 @@ Route::add_processors (const ProcessorList& others, ProcessorList::iterator iter return -1; } - (*i)->ActiveChanged.connect (*this, boost::bind (&Session::update_latency_compensation, &_session, false, false)); + (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false, false)); } _output->set_user_latency (0); diff --git a/libs/ardour/route_group.cc b/libs/ardour/route_group.cc index 1da2eda678..2f946dd620 100644 --- a/libs/ardour/route_group.cc +++ b/libs/ardour/route_group.cc @@ -76,7 +76,7 @@ RouteGroup::add (boost::shared_ptr<Route> r) routes->push_back (r); r->join_route_group (this); - r->GoingAway.connect (*this, boost::bind (&RouteGroup::remove_when_going_away, this, boost::weak_ptr<Route> (r))); + r->GoingAway.connect_same_thread (*this, boost::bind (&RouteGroup::remove_when_going_away, this, boost::weak_ptr<Route> (r))); _session.set_dirty (); changed (); /* EMIT SIGNAL */ diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 8d707545fe..a062efee8d 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -190,8 +190,8 @@ Session::Session (AudioEngine &eng, _state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty); - Config->ParameterChanged.connect (*this, boost::bind (&Session::config_changed, this, _1, false)); - config.ParameterChanged.connect (*this, boost::bind (&Session::config_changed, this, _1, true)); + Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Session::config_changed, this, _1, false)); + config.ParameterChanged.connect_same_thread (*this, boost::bind (&Session::config_changed, this, _1, true)); if (was_dirty) { DirtyChanged (); /* EMIT SIGNAL */ @@ -327,7 +327,7 @@ Session::Session (AudioEngine &eng, _state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty); - Config->ParameterChanged.connect (*this, boost::bind (&Session::config_changed, this, _1, false)); + Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Session::config_changed, this, _1, false)); } Session::~Session () @@ -523,7 +523,7 @@ Session::when_engine_running () /* every time we reconnect, recompute worst case output latencies */ - _engine.Running.connect (*this, boost::bind (&Session::set_worst_io_latencies, this)); + _engine.Running.connect_same_thread (*this, boost::bind (&Session::set_worst_io_latencies, this)); if (synced_to_jack()) { _engine.transport_stop (); @@ -877,7 +877,7 @@ Session::diskstream_playlist_changed (boost::weak_ptr<Diskstream> wp) boost::shared_ptr<Playlist> playlist; if ((playlist = dstream->playlist()) != 0) { - playlist->LengthChanged.connect (*this, boost::bind (&Session::playlist_length_changed, this)); + playlist->LengthChanged.connect_same_thread (*this, boost::bind (&Session::playlist_length_changed, this)); } /* see comment in playlist_length_changed () */ @@ -1013,9 +1013,9 @@ Session::set_auto_punch_location (Location* location) punch_connections.drop_connections (); - location->start_changed.connect (punch_connections, boost::bind (&Session::auto_punch_start_changed, this, _1)); - location->end_changed.connect (punch_connections, boost::bind (&Session::auto_punch_end_changed, this, _1)); - location->changed.connect (punch_connections, boost::bind (&Session::auto_punch_changed, this, _1)); + location->start_changed.connect_same_thread (punch_connections, boost::bind (&Session::auto_punch_start_changed, this, _1)); + location->end_changed.connect_same_thread (punch_connections, boost::bind (&Session::auto_punch_end_changed, this, _1)); + location->changed.connect_same_thread (punch_connections, boost::bind (&Session::auto_punch_changed, this, _1)); location->set_auto_punch (true, this); @@ -1051,9 +1051,9 @@ Session::set_auto_loop_location (Location* location) loop_connections.drop_connections (); - location->start_changed.connect (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1)); - location->end_changed.connect (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1)); - location->changed.connect (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1)); + location->start_changed.connect_same_thread (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1)); + location->end_changed.connect_same_thread (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1)); + location->changed.connect_same_thread (loop_connections, boost::bind (&Session::auto_loop_changed, this, _1)); location->set_auto_loop (true, this); @@ -1647,7 +1647,7 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m route_group->add (track); } - track->DiskstreamChanged.connect (*this, boost::bind (&Session::resort_routes, this)); + track->DiskstreamChanged.connect_same_thread (*this, boost::bind (&Session::resort_routes, this)); //track->set_remote_control_id (control_id); new_routes.push_back (track); @@ -1822,7 +1822,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod track->audio_diskstream()->non_realtime_input_change(); - track->DiskstreamChanged.connect (*this, boost::bind (&Session::resort_routes, this)); + track->DiskstreamChanged.connect_same_thread (*this, boost::bind (&Session::resort_routes, this)); track->set_remote_control_id (control_id); ++control_id; @@ -2149,12 +2149,12 @@ Session::add_routes (RouteList& new_routes, bool save) boost::weak_ptr<Route> wpr (*x); - (*x)->listen_changed.connect (*this, boost::bind (&Session::route_listen_changed, this, _1, wpr)); - (*x)->solo_changed.connect (*this, boost::bind (&Session::route_solo_changed, this, _1, wpr)); - (*x)->mute_changed.connect (*this, boost::bind (&Session::route_mute_changed, this, _1)); - (*x)->output()->changed.connect (*this, boost::bind (&Session::set_worst_io_latencies_x, this, _1, _2)); - (*x)->processors_changed.connect (*this, boost::bind (&Session::route_processors_changed, this, _1)); - (*x)->route_group_changed.connect (*this, boost::bind (&Session::route_group_changed, this)); + (*x)->listen_changed.connect_same_thread (*this, boost::bind (&Session::route_listen_changed, this, _1, wpr)); + (*x)->solo_changed.connect_same_thread (*this, boost::bind (&Session::route_solo_changed, this, _1, wpr)); + (*x)->mute_changed.connect_same_thread (*this, boost::bind (&Session::route_mute_changed, this, _1)); + (*x)->output()->changed.connect_same_thread (*this, boost::bind (&Session::set_worst_io_latencies_x, this, _1, _2)); + (*x)->processors_changed.connect_same_thread (*this, boost::bind (&Session::route_processors_changed, this, _1)); + (*x)->route_group_changed.connect_same_thread (*this, boost::bind (&Session::route_group_changed, this)); if ((*x)->is_master()) { _master_out = (*x); @@ -2294,11 +2294,11 @@ Session::add_diskstream (boost::shared_ptr<Diskstream> dstream) /* writer goes out of scope, copies ds back to main */ } - dstream->PlaylistChanged.connect (*this, boost::bind (&Session::diskstream_playlist_changed, this, boost::weak_ptr<Diskstream> (dstream))); + dstream->PlaylistChanged.connect_same_thread (*this, boost::bind (&Session::diskstream_playlist_changed, this, boost::weak_ptr<Diskstream> (dstream))); /* this will connect to future changes, and check the current length */ diskstream_playlist_changed (boost::weak_ptr<Diskstream> (dstream)); - dstream->RecordEnableChanged.connect (*this, boost::bind (&Session::update_have_rec_enabled_diskstream, this)); + dstream->RecordEnableChanged.connect_same_thread (*this, boost::bind (&Session::update_have_rec_enabled_diskstream, this)); dstream->prepare (); @@ -2812,8 +2812,8 @@ Session::add_regions (vector<boost::shared_ptr<Region> >& new_regions) } } - region->StateChanged.connect (*this, boost::bind (&Session::region_changed, this, _1, boost::weak_ptr<Region>(region))); - region->GoingAway.connect (*this, boost::bind (&Session::remove_region, this, boost::weak_ptr<Region>(region))); + region->StateChanged.connect_same_thread (*this, boost::bind (&Session::region_changed, this, _1, boost::weak_ptr<Region>(region))); + region->GoingAway.connect_same_thread (*this, boost::bind (&Session::remove_region, this, boost::weak_ptr<Region>(region))); update_region_name_map (region); } @@ -3001,7 +3001,7 @@ Session::add_source (boost::shared_ptr<Source> source) } if (result.second) { - source->GoingAway.connect (*this, boost::bind (&Session::remove_source, this, boost::weak_ptr<Source> (source))); + source->GoingAway.connect_same_thread (*this, boost::bind (&Session::remove_source, this, boost::weak_ptr<Source> (source))); set_dirty(); } @@ -3392,7 +3392,7 @@ Session::add_playlist (boost::shared_ptr<Playlist> playlist, bool unused) bool existing = playlists->add (playlist); if (!existing) { - playlist->GoingAway.connect (*this, boost::bind (&Session::remove_playlist, this, boost::weak_ptr<Playlist>(playlist))); + playlist->GoingAway.connect_same_thread (*this, boost::bind (&Session::remove_playlist, this, boost::weak_ptr<Playlist>(playlist))); } if (unused) { @@ -3566,7 +3566,7 @@ Session::graph_reordered () void Session::add_processor (Processor* processor) { - processor->GoingAway.connect (*this, boost::bind (&Session::remove_processor, this, processor)); + processor->GoingAway.connect_same_thread (*this, boost::bind (&Session::remove_processor, this, processor)); set_dirty(); } diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index 1bd0c2e7c7..840c752bad 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -91,8 +91,8 @@ Session::pre_export () _exporting = true; export_status->running = true; - export_status->Aborting.connect (*this, boost::bind (&Session::stop_audio_export, this)); - export_status->Finished.connect (*this, boost::bind (&Session::finalize_audio_export, this)); + export_status->Aborting.connect_same_thread (*this, boost::bind (&Session::stop_audio_export, this)); + export_status->Finished.connect_same_thread (*this, boost::bind (&Session::finalize_audio_export, this)); return 0; } @@ -150,7 +150,7 @@ Session::start_audio_export (nframes_t position, bool realtime) last_process_function = process_function; process_function = &Session::process_export; } else { - _engine.Freewheel.connect (export_freewheel_connection, boost::bind (&Session::process_export_fw, this, _1)); + _engine.Freewheel.connect_same_thread (export_freewheel_connection, boost::bind (&Session::process_export_fw, this, _1)); return _engine.freewheel (true); } diff --git a/libs/ardour/session_handle.cc b/libs/ardour/session_handle.cc index f1f6147960..1cd78c8aac 100644 --- a/libs/ardour/session_handle.cc +++ b/libs/ardour/session_handle.cc @@ -32,7 +32,7 @@ SessionHandlePtr::SessionHandlePtr (Session* s) : _session (s) { if (_session) { - _session->GoingAway.connect (_session_connections, boost::bind (&SessionHandlePtr::session_going_away, this)); + _session->GoingAway.connect_same_thread (_session_connections, boost::bind (&SessionHandlePtr::session_going_away, this)); } } @@ -47,7 +47,7 @@ SessionHandlePtr::set_session (Session* s) if (s) { _session = s; - _session->GoingAway.connect (_session_connections, boost::bind (&SessionHandlePtr::session_going_away, this)); + _session->GoingAway.connect_same_thread (_session_connections, boost::bind (&SessionHandlePtr::session_going_away, this)); } } @@ -63,7 +63,7 @@ SessionHandlePtr::session_going_away () SessionHandleRef::SessionHandleRef (Session& s) : _session (s) { - _session.GoingAway.connect (*this, boost::bind (&SessionHandleRef::session_going_away, this)); + _session.GoingAway.connect_same_thread (*this, boost::bind (&SessionHandleRef::session_going_away, this)); } void diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index bd06fe78ee..d8859e07c0 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -208,26 +208,26 @@ Session::set_mmc_port (string port_tag) mmc->set_send_device_id (old_send_device_id); } - mmc->Play.connect (*this, boost::bind (&Session::mmc_deferred_play, this, _1)); - mmc->DeferredPlay.connect (*this, boost::bind (&Session::mmc_deferred_play, this, _1)); - mmc->Stop.connect (*this, boost::bind (&Session::mmc_stop, this, _1)); - mmc->FastForward.connect (*this, boost::bind (&Session::mmc_fast_forward, this, _1)); - mmc->Rewind.connect (*this, boost::bind (&Session::mmc_rewind, this, _1)); - mmc->Pause.connect (*this, boost::bind (&Session::mmc_pause, this, _1)); - mmc->RecordPause.connect (*this, boost::bind (&Session::mmc_record_pause, this, _1)); - mmc->RecordStrobe.connect (*this, boost::bind (&Session::mmc_record_strobe, this, _1)); - mmc->RecordExit.connect (*this, boost::bind (&Session::mmc_record_exit, this, _1)); - mmc->Locate.connect (*this, boost::bind (&Session::mmc_locate, this, _1, _2)); - mmc->Step.connect (*this, boost::bind (&Session::mmc_step, this, _1, _2)); - mmc->Shuttle.connect (*this, boost::bind (&Session::mmc_shuttle, this, _1, _2, _3)); - mmc->TrackRecordStatusChange.connect (*this, boost::bind (&Session::mmc_record_enable, this, _1, _2, _3)); + mmc->Play.connect_same_thread (*this, boost::bind (&Session::mmc_deferred_play, this, _1)); + mmc->DeferredPlay.connect_same_thread (*this, boost::bind (&Session::mmc_deferred_play, this, _1)); + mmc->Stop.connect_same_thread (*this, boost::bind (&Session::mmc_stop, this, _1)); + mmc->FastForward.connect_same_thread (*this, boost::bind (&Session::mmc_fast_forward, this, _1)); + mmc->Rewind.connect_same_thread (*this, boost::bind (&Session::mmc_rewind, this, _1)); + mmc->Pause.connect_same_thread (*this, boost::bind (&Session::mmc_pause, this, _1)); + mmc->RecordPause.connect_same_thread (*this, boost::bind (&Session::mmc_record_pause, this, _1)); + mmc->RecordStrobe.connect_same_thread (*this, boost::bind (&Session::mmc_record_strobe, this, _1)); + mmc->RecordExit.connect_same_thread (*this, boost::bind (&Session::mmc_record_exit, this, _1)); + mmc->Locate.connect_same_thread (*this, boost::bind (&Session::mmc_locate, this, _1, _2)); + mmc->Step.connect_same_thread (*this, boost::bind (&Session::mmc_step, this, _1, _2)); + mmc->Shuttle.connect_same_thread (*this, boost::bind (&Session::mmc_shuttle, this, _1, _2, _3)); + mmc->TrackRecordStatusChange.connect_same_thread (*this, boost::bind (&Session::mmc_record_enable, this, _1, _2, _3)); /* also handle MIDI SPP because its so common */ - _mmc_port->input()->start.connect (*this, boost::bind (&Session::spp_start, this, _1, _2)); - _mmc_port->input()->contineu.connect (*this, boost::bind (&Session::spp_continue, this, _1, _2)); - _mmc_port->input()->stop.connect (*this, boost::bind (&Session::spp_stop, this, _1, _2)); + _mmc_port->input()->start.connect_same_thread (*this, boost::bind (&Session::spp_start, this, _1, _2)); + _mmc_port->input()->contineu.connect_same_thread (*this, boost::bind (&Session::spp_continue, this, _1, _2)); + _mmc_port->input()->stop.connect_same_thread (*this, boost::bind (&Session::spp_stop, this, _1, _2)); Config->set_mmc_port_name (port_tag); diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index 0d32ea75d7..238bd72404 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -74,7 +74,7 @@ SessionPlaylists::add (boost::shared_ptr<Playlist> playlist) if (!existing) { playlists.insert (playlists.begin(), playlist); - playlist->InUse.connect (*this, boost::bind (&SessionPlaylists::track, this, _1, boost::weak_ptr<Playlist>(playlist))); + playlist->InUse.connect_same_thread (*this, boost::bind (&SessionPlaylists::track, this, _1, boost::weak_ptr<Playlist>(playlist))); } return existing; diff --git a/libs/ardour/session_rtevents.cc b/libs/ardour/session_rtevents.cc index 7bb27db808..5def97941f 100644 --- a/libs/ardour/session_rtevents.cc +++ b/libs/ardour/session_rtevents.cc @@ -39,7 +39,7 @@ Session::get_rt_event (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::R SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0); ev->rt_slot = boost::bind (method, this, rl, yn, group_override); ev->rt_return = after; - ev->ui = UICallback::get_ui_for_thread (); + ev->event_loop = EventLoop::get_event_loop_for_thread (); return ev; } @@ -162,8 +162,8 @@ Session::process_rtop (SessionEvent* ev) { ev->rt_slot (); - if (ev->ui) { - ev->ui->call_slot (boost::bind (ev->rt_return, ev)); + if (ev->event_loop) { + ev->event_loop->call_slot (boost::bind (ev->rt_return, ev)); } else { warning << string_compose ("programming error: %1", X_("Session RT event queued from thread without a UI - cleanup in RT thread!")) << endmsg; ev->rt_return (ev); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index bcd074a516..2248663478 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -164,7 +164,7 @@ Session::first_stage_init (string fullpath, string snapshot_name) _base_frame_rate = _current_frame_rate; _tempo_map = new TempoMap (_current_frame_rate); - _tempo_map->StateChanged.connect (*this, boost::bind (&Session::tempo_map_changed, this, _1)); + _tempo_map->StateChanged.connect_same_thread (*this, boost::bind (&Session::tempo_map_changed, this, _1)); _non_soloed_outs_muted = false; @@ -266,18 +266,18 @@ Session::first_stage_init (string fullpath, string snapshot_name) delta_accumulator_cnt = 0; _slave_state = Stopped; - _engine.GraphReordered.connect (*this, boost::bind (&Session::graph_reordered, this)); + _engine.GraphReordered.connect_same_thread (*this, boost::bind (&Session::graph_reordered, this)); /* These are all static "per-class" signals */ - RegionFactory::CheckNewRegion.connect (*this, boost::bind (&Session::add_region, this, _1)); - SourceFactory::SourceCreated.connect (*this, boost::bind (&Session::add_source, this, _1)); - PlaylistFactory::PlaylistCreated.connect (*this, boost::bind (&Session::add_playlist, this, _1, _2)); - Processor::ProcessorCreated.connect (*this, boost::bind (&Session::add_processor, this, _1)); - NamedSelection::NamedSelectionCreated.connect (*this, boost::bind (&Session::add_named_selection, this, _1)); - AutomationList::AutomationListCreated.connect (*this, boost::bind (&Session::add_automation_list, this, _1)); - Controllable::Destroyed.connect (*this, boost::bind (&Session::remove_controllable, this, _1)); - IO::PortCountChanged.connect (*this, boost::bind (&Session::ensure_buffers, this, _1)); + RegionFactory::CheckNewRegion.connect_same_thread (*this, boost::bind (&Session::add_region, this, _1)); + SourceFactory::SourceCreated.connect_same_thread (*this, boost::bind (&Session::add_source, this, _1)); + PlaylistFactory::PlaylistCreated.connect_same_thread (*this, boost::bind (&Session::add_playlist, this, _1, _2)); + Processor::ProcessorCreated.connect_same_thread (*this, boost::bind (&Session::add_processor, this, _1)); + NamedSelection::NamedSelectionCreated.connect_same_thread (*this, boost::bind (&Session::add_named_selection, this, _1)); + AutomationList::AutomationListCreated.connect_same_thread (*this, boost::bind (&Session::add_automation_list, this, _1)); + Controllable::Destroyed.connect_same_thread (*this, boost::bind (&Session::remove_controllable, this, _1)); + IO::PortCountChanged.connect_same_thread (*this, boost::bind (&Session::ensure_buffers, this, _1)); /* stop IO objects from doing stuff until we're ready for them */ @@ -329,15 +329,15 @@ Session::second_stage_init (bool new_session) _state_of_the_state = StateOfTheState (_state_of_the_state|CannotSave|Loading); - _locations.changed.connect (*this, boost::bind (&Session::locations_changed, this)); - _locations.added.connect (*this, boost::bind (&Session::locations_added, this, _1)); + _locations.changed.connect_same_thread (*this, boost::bind (&Session::locations_changed, this)); + _locations.added.connect_same_thread (*this, boost::bind (&Session::locations_added, this, _1)); setup_click_sounds (0); setup_midi_control (); /* Pay attention ... */ - _engine.Halted.connect (*this, boost::bind (&Session::engine_halted, this)); - _engine.Xrun.connect (*this, boost::bind (&Session::xrun_recovery, this)); + _engine.Halted.connect_same_thread (*this, boost::bind (&Session::engine_halted, this)); + _engine.Xrun.connect_same_thread (*this, boost::bind (&Session::xrun_recovery, this)); try { when_engine_running(); diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index 6805e5f6dd..185cb15e79 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -192,7 +192,7 @@ SndFileSource::init_sndfile () _timeline_position = header_position_offset; } - AudioFileSource::HeaderPositionOffsetChanged.connect (header_position_connection, boost::bind (&SndFileSource::handle_header_position_change, this)); + AudioFileSource::HeaderPositionOffsetChanged.connect_same_thread (header_position_connection, boost::bind (&SndFileSource::handle_header_position_change, this)); } int diff --git a/libs/ardour/ticker.cc b/libs/ardour/ticker.cc index f35f84e889..2ef5abe5d5 100644 --- a/libs/ardour/ticker.cc +++ b/libs/ardour/ticker.cc @@ -34,7 +34,7 @@ void Ticker::set_session (Session* s) SessionHandlePtr::set_session (s); if (_session) { - _session->tick.connect (_session_connections, boost::bind (&Ticker::tick, this, _1, _2, _3)); + _session->tick.connect_same_thread (_session_connections, boost::bind (&Ticker::tick, this, _1, _2, _3)); } } @@ -43,10 +43,10 @@ void MidiClockTicker::set_session (Session* s) Ticker::set_session (s); if (_session) { - _session->MIDIClock_PortChanged.connect (_session_connections, boost::bind (&MidiClockTicker::update_midi_clock_port, this)); - _session->TransportStateChange.connect (_session_connections, boost::bind (&MidiClockTicker::transport_state_changed, this)); - _session->PositionChanged.connect (_session_connections, boost::bind (&MidiClockTicker::position_changed, this, _1)); - _session->TransportLooped.connect (_session_connections, boost::bind (&MidiClockTicker::transport_looped, this)); + _session->MIDIClock_PortChanged.connect_same_thread (_session_connections, boost::bind (&MidiClockTicker::update_midi_clock_port, this)); + _session->TransportStateChange.connect_same_thread (_session_connections, boost::bind (&MidiClockTicker::transport_state_changed, this)); + _session->PositionChanged.connect_same_thread (_session_connections, boost::bind (&MidiClockTicker::position_changed, this, _1)); + _session->TransportLooped.connect_same_thread (_session_connections, boost::bind (&MidiClockTicker::transport_looped, this)); update_midi_clock_port(); } } diff --git a/libs/gtkmm2ext/binding_proxy.cc b/libs/gtkmm2ext/binding_proxy.cc index 08d215036d..f12c64cf68 100644 --- a/libs/gtkmm2ext/binding_proxy.cc +++ b/libs/gtkmm2ext/binding_proxy.cc @@ -88,7 +88,7 @@ BindingProxy::button_press_handler (GdkEventButton *ev) } prompter->set_text (prompt); prompter->touch (); // shows popup - controllable->LearningFinished.connect (learning_connection, boost::bind (&BindingProxy::learning_finished, this)); + controllable->LearningFinished.connect_same_thread (learning_connection, boost::bind (&BindingProxy::learning_finished, this)); } return true; } diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 3d86c6d103..38512d70f5 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -85,7 +85,7 @@ UI::UI (string namestr, int *argc, char ***argv) as for previous line. */ - set_ui_for_thread (this); + set_event_loop_for_thread (this); /* attach our request source to the default main context */ diff --git a/libs/midi++2/channel.cc b/libs/midi++2/channel.cc index bf71b0579c..2760e8ae51 100644 --- a/libs/midi++2/channel.cc +++ b/libs/midi++2/channel.cc @@ -35,30 +35,29 @@ Channel::Channel (byte channelnum, Port &p) : _port (p) void Channel::connect_input_signals () { - _port.input()->channel_pressure[_channel_number].connect (*this, boost::bind (&Channel::process_chanpress, this, _1, _2)); - _port.input()->channel_note_on[_channel_number].connect (*this, boost::bind (&Channel::process_note_on, this, _1, _2)); - _port.input()->channel_note_off[_channel_number].connect (*this, boost::bind (&Channel::process_note_off, this, _1, _2)); - _port.input()->channel_poly_pressure[_channel_number].connect (*this, boost::bind (&Channel::process_polypress, this, _1, _2)); - _port.input()->channel_program_change[_channel_number].connect (*this, boost::bind (&Channel::process_program_change, this, _1, _2)); - _port.input()->channel_controller[_channel_number].connect (*this, boost::bind (&Channel::process_controller, this, _1, _2)); - _port.input()->channel_pitchbend[_channel_number].connect (*this, boost::bind (&Channel::process_pitchbend, this, _1, _2)); - - _port.input()->reset.connect (*this, boost::bind (&Channel::process_reset, this, _1)); + _port.input()->channel_pressure[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_chanpress, this, _1, _2)); + _port.input()->channel_note_on[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_note_on, this, _1, _2)); + _port.input()->channel_note_off[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_note_off, this, _1, _2)); + _port.input()->channel_poly_pressure[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_polypress, this, _1, _2)); + _port.input()->channel_program_change[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_program_change, this, _1, _2)); + _port.input()->channel_controller[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_controller, this, _1, _2)); + _port.input()->channel_pitchbend[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_pitchbend, this, _1, _2)); + + _port.input()->reset.connect_same_thread (*this, boost::bind (&Channel::process_reset, this, _1)); } void Channel::connect_output_signals () - { - _port.output()->channel_pressure[_channel_number].connect (*this, boost::bind (&Channel::process_chanpress, this, _1, _2)); - _port.output()->channel_note_on[_channel_number].connect (*this, boost::bind (&Channel::process_note_on, this, _1, _2)); - _port.output()->channel_note_off[_channel_number].connect (*this, boost::bind (&Channel::process_note_off, this, _1, _2)); - _port.output()->channel_poly_pressure[_channel_number].connect (*this, boost::bind (&Channel::process_polypress, this, _1, _2)); - _port.output()->channel_program_change[_channel_number].connect (*this, boost::bind (&Channel::process_program_change, this, _1, _2)); - _port.output()->channel_controller[_channel_number].connect (*this, boost::bind (&Channel::process_controller, this, _1, _2)); - _port.output()->channel_pitchbend[_channel_number].connect (*this, boost::bind (&Channel::process_pitchbend, this, _1, _2)); - - _port.output()->reset.connect (*this, boost::bind (&Channel::process_reset, this, _1)); + _port.output()->channel_pressure[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_chanpress, this, _1, _2)); + _port.output()->channel_note_on[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_note_on, this, _1, _2)); + _port.output()->channel_note_off[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_note_off, this, _1, _2)); + _port.output()->channel_poly_pressure[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_polypress, this, _1, _2)); + _port.output()->channel_program_change[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_program_change, this, _1, _2)); + _port.output()->channel_controller[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_controller, this, _1, _2)); + _port.output()->channel_pitchbend[_channel_number].connect_same_thread (*this, boost::bind (&Channel::process_pitchbend, this, _1, _2)); + + _port.output()->reset.connect_same_thread (*this, boost::bind (&Channel::process_reset, this, _1)); } void diff --git a/libs/midi++2/midi++/fd_midiport.h b/libs/midi++2/midi++/fd_midiport.h index 986ff5f0e0..673037cc5d 100644 --- a/libs/midi++2/midi++/fd_midiport.h +++ b/libs/midi++2/midi++/fd_midiport.h @@ -67,13 +67,11 @@ class FD_MidiPort : public Port bytes_written += nwritten; if (output_parser) { - output_parser->raw_preparse - (*output_parser, msg, nwritten); + output_parser->raw_preparse (*output_parser, msg, nwritten); for (int i = 0; i < nwritten; i++) { output_parser->scanner (msg[i]); } - output_parser->raw_postparse - (*output_parser, msg, nwritten); + output_parser->raw_postparse (*output_parser, msg, nwritten); } } return nwritten; diff --git a/libs/midi++2/mmc.cc b/libs/midi++2/mmc.cc index eb1c6cb5b0..6030230108 100644 --- a/libs/midi++2/mmc.cc +++ b/libs/midi++2/mmc.cc @@ -206,7 +206,7 @@ MachineControl::MachineControl (Port &p, float /*version*/, _send_device_id = 0x7f; if ((parser = _port.input()) != 0) { - parser->mmc.connect (mmc_connection, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3)); + parser->mmc.connect_same_thread (mmc_connection, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3)); } else { warning << "MMC connected to a non-input port: useless!" << endmsg; diff --git a/libs/midi++2/parser.cc b/libs/midi++2/parser.cc index 2efa77ae0b..af9cfafaca 100644 --- a/libs/midi++2/parser.cc +++ b/libs/midi++2/parser.cc @@ -316,7 +316,7 @@ Parser::trace (bool onoff, ostream *o, const string &prefix) cerr << "enabling tracing for port " << _port.name() << endl; trace_stream = o; trace_prefix = prefix; - any.connect (trace_connection, boost::bind (&Parser::trace_event, this, _1, _2, _3)); + any.connect_same_thread (trace_connection, boost::bind (&Parser::trace_event, this, _1, _2, _3)); } else { trace_prefix = ""; trace_stream = 0; diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index ea7e469c74..5e856d1ca0 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -70,7 +70,7 @@ BaseUI::new_request_type () void BaseUI::main_thread () { - set_ui_for_thread (this); + set_event_loop_for_thread (this); thread_init (); _main_loop->run (); } diff --git a/libs/pbd/controllable.cc b/libs/pbd/controllable.cc index dd0dfd4445..d751c3c80b 100644 --- a/libs/pbd/controllable.cc +++ b/libs/pbd/controllable.cc @@ -62,7 +62,7 @@ Controllable::add (Controllable& ctl) /* Controllable::remove() is static - no need to manage this connection */ - ctl.GoingAway.connect (registry_connections, boost::bind (&Controllable::remove, ref (ctl))); + ctl.GoingAway.connect_same_thread (registry_connections, boost::bind (&Controllable::remove, ref (ctl))); } void diff --git a/libs/pbd/event_loop.cc b/libs/pbd/event_loop.cc new file mode 100644 index 0000000000..3bc4abcbdf --- /dev/null +++ b/libs/pbd/event_loop.cc @@ -0,0 +1,19 @@ +#include "pbd/event_loop.h" + +using namespace PBD; + +Glib::StaticPrivate<EventLoop> EventLoop::thread_event_loop; + +static void do_not_delete_the_loop_pointer (void*) { } + +EventLoop* +EventLoop::get_event_loop_for_thread() { + return thread_event_loop.get (); +} + +void +EventLoop::set_event_loop_for_thread (EventLoop* loop) +{ + thread_event_loop.set (loop, do_not_delete_the_loop_pointer); +} + diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h index 2bfaa11be0..9e88be60f2 100644 --- a/libs/pbd/pbd/base_ui.h +++ b/libs/pbd/pbd/base_ui.h @@ -30,9 +30,9 @@ #include <glibmm/main.h> #include "pbd/crossthread.h" -#include "pbd/ui_callback.h" +#include "pbd/event_loop.h" -class BaseUI : virtual public sigc::trackable, public PBD::UICallback +class BaseUI : virtual public sigc::trackable, public PBD::EventLoop { public: BaseUI (const std::string& name); diff --git a/libs/pbd/pbd/ui_callback.h b/libs/pbd/pbd/event_loop.h index 8574de0dec..be98fcd852 100644 --- a/libs/pbd/pbd/ui_callback.h +++ b/libs/pbd/pbd/event_loop.h @@ -17,8 +17,8 @@ */ -#ifndef __pbd_ui_callback_h__ -#define __pbd_ui_callback_h__ +#ifndef __pbd_event_loop_h__ +#define __pbd_event_loop_h__ #include <boost/function.hpp> #include <boost/bind.hpp> /* we don't need this here, but anything calling call_slot() probably will, so this is convenient */ @@ -27,22 +27,22 @@ namespace PBD { -class UICallback +class EventLoop { public: - UICallback() {} - virtual ~UICallback() {} + EventLoop() {} + virtual ~EventLoop() {} virtual void call_slot (const boost::function<void()>&) = 0; - static UICallback* get_ui_for_thread(); - static void set_ui_for_thread (UICallback* ui); + static EventLoop* get_event_loop_for_thread(); + static void set_event_loop_for_thread (EventLoop* ui); private: - static Glib::StaticPrivate<UICallback> thread_ui; + static Glib::StaticPrivate<EventLoop> thread_event_loop; }; } -#endif /* __pbd_ui_callback_h__ */ +#endif /* __pbd_event_loop_h__ */ diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h index b87f784334..a08d3bb717 100644 --- a/libs/pbd/pbd/memento_command.h +++ b/libs/pbd/pbd/memento_command.h @@ -42,7 +42,7 @@ public: : obj(a_object), before(a_before), after(a_after) { /* if the object dies, make sure that we die and that everyone knows about it */ - obj.GoingAway.connect (obj_death_connection, boost::bind (&MementoCommand::object_died, this)); + obj.GoingAway.connect_same_thread (obj_death_connection, boost::bind (&MementoCommand::object_died, this)); } ~MementoCommand () { diff --git a/libs/pbd/pbd/shiva.h b/libs/pbd/pbd/shiva.h deleted file mode 100644 index 90adad6250..0000000000 --- a/libs/pbd/pbd/shiva.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2000-2007 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef __pbd_shiva_h__ -#define __pbd_shiva_h__ - -#include <sigc++/sigc++.h> - -namespace PBD { - -/* named after the Hindu god Shiva, The Destroyer */ - -template<typename ObjectWithGoingAway, typename ObjectToBeDestroyed> -class Shiva : public sigc::trackable -{ - public: - Shiva (ObjectWithGoingAway& emitter, ObjectToBeDestroyed& receiver) { - - /* if the emitter goes away, destroy the receiver */ - - _connection = emitter.GoingAway.connect - (sigc::bind (sigc::mem_fun - (*this, &Shiva<ObjectWithGoingAway,ObjectToBeDestroyed>::destroy), - &receiver)); - } - - ~Shiva() { - forget (); - } - - private: - sigc::connection _connection; - - void destroy (ObjectToBeDestroyed* obj) { - delete obj; - forget (); - } - - void forget () { - _connection.disconnect (); - } - -}; - -template<typename ObjectWithGoingAway, typename ObjectToBeDestroyed> -class ProxyShiva : public sigc::trackable -{ - public: - ProxyShiva (ObjectWithGoingAway& emitter, ObjectToBeDestroyed& receiver, void (*callback)(ObjectToBeDestroyed*, ObjectWithGoingAway*)) { - - /* if the emitter goes away, destroy the receiver */ - - _callback = callback; - _callback_argument = &emitter; - - _connection = emitter.GoingAway.connect - (sigc::bind (sigc::mem_fun - (*this, &ProxyShiva<ObjectWithGoingAway,ObjectToBeDestroyed>::destroy), - &receiver)); - } - - ~ProxyShiva () { - forget (); - } - - private: - sigc::connection _connection; - void (*_callback) (ObjectToBeDestroyed*, ObjectWithGoingAway*); - ObjectWithGoingAway* _callback_argument; - - void destroy (ObjectToBeDestroyed* obj) { - /* callback must destroy obj if appropriate, not done here */ - _callback (obj, _callback_argument); - forget (); - } - - void forget () { - _connection.disconnect (); - } -}; - -template<typename ObjectWithGoingAway, typename ObjectToBeDestroyed> -class PairedShiva : public sigc::trackable -{ - public: - PairedShiva (ObjectWithGoingAway& emitter, ObjectToBeDestroyed& receiver) { - - /* if the emitter goes away, destroy the receiver */ - - _connection1 = emitter.GoingAway.connect - (sigc::bind (sigc::mem_fun - (*this, &PairedShiva<ObjectWithGoingAway,ObjectToBeDestroyed>::destroy), - &receiver)); - - /* if the receiver goes away, forget all this nonsense */ - - _connection2 = receiver.GoingAway.connect - (sigc::mem_fun (*this, &PairedShiva<ObjectWithGoingAway,ObjectToBeDestroyed>::forget)); - } - - ~PairedShiva() { - forget (); - } - - private: - sigc::connection _connection1; - sigc::connection _connection2; - - void destroy (ObjectToBeDestroyed* obj) { - delete obj; - forget (); - } - - void forget () { - _connection1.disconnect (); - _connection2.disconnect (); - } - -}; - -} - -#endif /* __pbd_shiva_h__ */ diff --git a/libs/pbd/pbd/signals.h b/libs/pbd/pbd/signals.h index 47e8d143bc..0b44ee8051 100644 --- a/libs/pbd/pbd/signals.h +++ b/libs/pbd/pbd/signals.h @@ -22,8 +22,13 @@ #include <list> #include <glibmm/thread.h> + #include <boost/signals2.hpp> #include <boost/noncopyable.hpp> +#include <boost/bind.hpp> +#include <boost/bind/protect.hpp> + +#include "pbd/event_loop.h" namespace PBD { @@ -40,10 +45,6 @@ class ScopedConnectionList : public boost::noncopyable void add_connection (const UnscopedConnection& c); void drop_connections (); - template<typename S> void scoped_connect (S& sig, const typename S::slot_function_type& sf) { - add_connection (sig.connect (sf)); - } - private: /* this class is not copyable */ ScopedConnectionList(const ScopedConnectionList&); @@ -76,14 +77,26 @@ public: Signal0 () {} typedef boost::signals2::signal<R()> SignalType; - void connect (ScopedConnectionList& clist, + void connect_same_thread (Connection& c, + const typename SignalType::slot_function_type& slot) { + c = _signal.connect (slot); + } + + void connect_same_thread (ScopedConnectionList& clist, const typename SignalType::slot_function_type& slot) { clist.add_connection (_signal.connect (slot)); } + + void connect (ScopedConnectionList& clist, + const typename SignalType::slot_function_type& slot, + PBD::EventLoop* event_loop) { + clist.add_connection (_signal.connect (boost::bind (&EventLoop::call_slot, event_loop, slot))); + } void connect (Connection& c, - const typename SignalType::slot_function_type& slot) { - c = _signal.connect (slot); + const typename SignalType::slot_function_type& slot, + PBD::EventLoop* event_loop) { + c = _signal.connect (boost::bind (&EventLoop::call_slot, event_loop, slot)); } typename SignalType::result_type operator()() { @@ -100,15 +113,32 @@ public: Signal1 () {} typedef boost::signals2::signal<R(A)> SignalType; - void connect (ScopedConnectionList& clist, + void connect_same_thread (ScopedConnectionList& clist, const typename SignalType::slot_function_type& slot) { clist.add_connection (_signal.connect (slot)); } - void connect (Connection& c, - const typename SignalType::slot_function_type& slot) { + void connect_same_thread (Connection& c, + const typename SignalType::slot_function_type& slot) { c = _signal.connect (slot); } + + static void compositor (typename boost::function<void(A)> f, EventLoop* event_loop, A arg) { + event_loop->call_slot (boost::bind (f, arg)); + } + + void connect (ScopedConnectionList& clist, + const typename SignalType::slot_function_type& slot, + PBD::EventLoop* event_loop) { + clist.add_connection (_signal.connect (boost::bind (&compositor, slot, event_loop, _1))); + } + + void connect (Connection& c, + const typename SignalType::slot_function_type& slot, + PBD::EventLoop* event_loop) { + c = _signal.connect (boost::bind (&compositor, slot, event_loop, _1)); + + } typename SignalType::result_type operator()(A arg1) { return _signal (arg1); @@ -124,16 +154,32 @@ public: Signal2 () {} typedef boost::signals2::signal<R(A1, A2)> SignalType; - void connect (ScopedConnectionList& clist, + void connect_same_thread (ScopedConnectionList& clist, const typename SignalType::slot_function_type& slot) { clist.add_connection (_signal.connect (slot)); } - - void connect (Connection& c, - const typename SignalType::slot_function_type& slot) { + + void connect_same_thread (Connection& c, + const typename SignalType::slot_function_type& slot) { c = _signal.connect (slot); } - + + static void compositor (typename boost::function<void(A1,A2)> f, PBD::EventLoop* event_loop, A1 arg1, A2 arg2) { + event_loop->call_slot (boost::bind (f, arg1, arg2)); + } + + void connect (ScopedConnectionList& clist, + const typename SignalType::slot_function_type& slot, + PBD::EventLoop* event_loop) { + clist.add_connection (_signal.connect (boost::bind (&compositor, slot, event_loop, _1, _2))); + } + + void connect (Connection& c, + const typename SignalType::slot_function_type& slot, + PBD::EventLoop* event_loop) { + c = _signal.connect (boost::bind (&compositor, slot, event_loop, _1, _2)); + } + typename SignalType::result_type operator()(A1 arg1, A2 arg2) { return _signal (arg1, arg2); } @@ -148,14 +194,30 @@ public: Signal3 () {} typedef boost::signals2::signal<R(A1,A2,A3)> SignalType; - void connect (ScopedConnectionList& clist, + void connect_same_thread (ScopedConnectionList& clist, const typename SignalType::slot_function_type& slot) { clist.add_connection (_signal.connect (slot)); } + + void connect_same_thread (Connection& c, + const typename SignalType::slot_function_type& slot) { + c = _signal.connect (slot); + } + + static void compositor (typename boost::function<void(A1,A2,A3)> f, PBD::EventLoop* event_loop, A1 arg1, A2 arg2, A3 arg3) { + event_loop->call_slot (boost::bind (f, arg1, arg2, arg3)); + } + + void connect (ScopedConnectionList& clist, + const typename SignalType::slot_function_type& slot, + PBD::EventLoop* event_loop) { + clist.add_connection (_signal.connect (boost::bind (&compositor, slot, event_loop, _1, _2, _3))); + } void connect (Connection& c, - const typename SignalType::slot_function_type& slot) { - c = _signal.connect (slot); + const typename SignalType::slot_function_type& slot, + PBD::EventLoop* event_loop) { + c = _signal.connect (_signal.connect (boost::bind (&compositor, slot, event_loop, _1, _2, _3))); } typename SignalType::result_type operator()(A1 arg1, A2 arg2, A3 arg3) { diff --git a/libs/pbd/ui_callback.cc b/libs/pbd/ui_callback.cc deleted file mode 100644 index 9a8feb3d2c..0000000000 --- a/libs/pbd/ui_callback.cc +++ /dev/null @@ -1,19 +0,0 @@ -#include "pbd/ui_callback.h" - -using namespace PBD; - -Glib::StaticPrivate<UICallback> UICallback::thread_ui; - -static void do_not_delete_the_ui_pointer (void*) { } - -UICallback* -UICallback::get_ui_for_thread() { - return thread_ui.get (); -} - -void -UICallback::set_ui_for_thread (UICallback* ui) -{ - thread_ui.set (ui, do_not_delete_the_ui_pointer); -} - diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc index 1a2574ae28..81e31f3a88 100644 --- a/libs/pbd/undo.cc +++ b/libs/pbd/undo.cc @@ -83,7 +83,7 @@ UndoTransaction::add_command (Command *const action) so there is no need to manage this connection. */ - action->GoingAway.connect (*this, boost::bind (&command_death, this, action)); + action->GoingAway.connect_same_thread (*this, boost::bind (&command_death, this, action)); actions.push_back (action); } @@ -186,7 +186,7 @@ UndoHistory::add (UndoTransaction* const ut) { uint32_t current_depth = UndoList.size(); - ut->GoingAway.connect (*this, boost::bind (&UndoHistory::remove, this, ut)); + ut->GoingAway.connect_same_thread (*this, boost::bind (&UndoHistory::remove, this, ut)); /* if the current undo history is larger than or equal to the currently requested depth, then pop off at least 1 element to make space diff --git a/libs/pbd/wscript b/libs/pbd/wscript index d7e456ada7..b25d8059ce 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -59,6 +59,7 @@ def build(bld): controllable.cc crossthread.cc enumwriter.cc + event_loop.cc dmalloc.cc error.cc filesystem.cc @@ -82,7 +83,6 @@ def build(bld): strsplit.cc textreceiver.cc transmitter.cc - ui_callback.cc undo.cc uuid.cc version.cc diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index d7f9d52efd..ff6de6b274 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -18,6 +18,8 @@ */ +#include "pbd/error.h" + #include "ardour/session.h" #include "ardour/route.h" #include "ardour/audio_track.h" @@ -27,19 +29,30 @@ using namespace ARDOUR; using namespace std; +using namespace PBD; -PBD::Signal0<void> ControlProtocol::ZoomToSession; -PBD::Signal0<void> ControlProtocol::ZoomOut; -PBD::Signal0<void> ControlProtocol::ZoomIn; -PBD::Signal0<void> ControlProtocol::Enter; -PBD::Signal1<void,float> ControlProtocol::ScrollTimeline; +Signal0<void> ControlProtocol::ZoomToSession; +Signal0<void> ControlProtocol::ZoomOut; +Signal0<void> ControlProtocol::ZoomIn; +Signal0<void> ControlProtocol::Enter; +Signal1<void,float> ControlProtocol::ScrollTimeline; -ControlProtocol::ControlProtocol (Session& s, string str) +ControlProtocol::ControlProtocol (Session& s, string str, EventLoop* evloop) : BasicUI (s), _name (str) { + if (evloop) { + _own_event_loop = false; + _event_loop = evloop; + } else { + _own_event_loop = true; + fatal << "programming error: cannot create control protocols without an existing event loop (yet)" << endmsg; + /*NOTREACHED*/ + } + _active = false; - session->RouteAdded.connect (*this, boost::bind (&ControlProtocol::add_strip, this, _1)); + + session->RouteAdded.connect (*this, boost::protect (boost::bind (&ControlProtocol::add_strip, this, _1)), _event_loop); } ControlProtocol::~ControlProtocol () @@ -47,7 +60,7 @@ ControlProtocol::~ControlProtocol () } void -ControlProtocol::add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >) +ControlProtocol::add_strip (ARDOUR::RouteList&) { route_list_changed(); } diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h index c80ba9b4b6..b3d44a15aa 100644 --- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h +++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h @@ -36,7 +36,7 @@ class Session; class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI { public: - ControlProtocol (Session&, std::string name); + ControlProtocol (Session&, std::string name, PBD::EventLoop* event_loop); virtual ~ControlProtocol(); std::string name() const { return _name; } @@ -99,11 +99,13 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu std::string route_get_name (uint32_t table_index); protected: + PBD::EventLoop* _event_loop; + bool _own_event_loop; std::vector<boost::shared_ptr<ARDOUR::Route> > route_table; std::string _name; bool _active; - void add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >); + void add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >&); void next_track (uint32_t initial_id); void prev_track (uint32_t initial_id); diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index e9f12638b6..c3d7aabfaf 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -30,6 +30,7 @@ #include "ardour/session.h" #include "ardour/route.h" +#include "ardour/midi_ui.h" #include "generic_midi_control_protocol.h" #include "midicontrollable.h" @@ -39,8 +40,11 @@ using namespace PBD; #include "i18n.h" +#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */ +#define ui_bind(x) boost::protect (boost::bind ((x))) + GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s) - : ControlProtocol (s, _("Generic MIDI")) + : ControlProtocol (s, _("Generic MIDI"), MidiControlUI::instance()) { MIDI::Manager* mm = MIDI::Manager::instance(); @@ -59,16 +63,14 @@ GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s) _feedback_interval = 10000; // microseconds last_feedback_time = 0; - auto_binding = FALSE; + /* XXX is it right to do all these in the same thread as whatever emits the signal? */ - Controllable::StartLearning.connect (*this, boost::bind (&GenericMidiControlProtocol::start_learning, this, _1)); - Controllable::StopLearning.connect (*this, boost::bind (&GenericMidiControlProtocol::stop_learning, this, _1)); - Controllable::CreateBinding.connect (*this, boost::bind (&GenericMidiControlProtocol::create_binding, this, _1, _2, _3)); - Controllable::DeleteBinding.connect (*this, boost::bind (&GenericMidiControlProtocol::delete_binding, this, _1)); + Controllable::StartLearning.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::start_learning, this, _1)); + Controllable::StopLearning.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::stop_learning, this, _1)); + Controllable::CreateBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::create_binding, this, _1, _2, _3)); + Controllable::DeleteBinding.connect_same_thread (*this, boost::bind (&GenericMidiControlProtocol::delete_binding, this, _1)); - Session::SendFeedback.connect (*this, boost::bind (&GenericMidiControlProtocol::send_feedback, this)); - Session::AutoBindingOn.connect (*this, boost::bind (&GenericMidiControlProtocol::auto_binding_on, this)); - Session::AutoBindingOff.connect (*this, boost::bind (&GenericMidiControlProtocol::auto_binding_off, this)); + Session::SendFeedback.connect (*this, boost::bind (&GenericMidiControlProtocol::send_feedback, this), midi_ui_context());; } GenericMidiControlProtocol::~GenericMidiControlProtocol () @@ -177,7 +179,7 @@ GenericMidiControlProtocol::start_learning (Controllable* c) MIDIPendingControllable* element = new MIDIPendingControllable; element->first = mc; - c->LearningFinished.connect (element->second, boost::bind (&GenericMidiControlProtocol::learning_stopped, this, mc)); + c->LearningFinished.connect_same_thread (element->second, boost::bind (&GenericMidiControlProtocol::learning_stopped, this, mc)); pending_controllables.push_back (element); } @@ -289,18 +291,6 @@ GenericMidiControlProtocol::create_binding (PBD::Controllable* control, int pos, } } -void -GenericMidiControlProtocol::auto_binding_on() -{ - auto_binding = TRUE; -} - -void -GenericMidiControlProtocol::auto_binding_off() -{ - auto_binding = FALSE; -} - XMLNode& GenericMidiControlProtocol::get_state () { @@ -345,46 +335,43 @@ GenericMidiControlProtocol::set_state (const XMLNode& node, int version) _feedback_interval = 10000; } - if ( !auto_binding ) { - - boost::shared_ptr<Controllable> c; - - { - Glib::Mutex::Lock lm (pending_lock); - for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) { - delete *i; - } - pending_controllables.clear (); - } - - Glib::Mutex::Lock lm2 (controllables_lock); - controllables.clear (); - nlist = node.children(); // "controls" - - if (nlist.empty()) { - return 0; + boost::shared_ptr<Controllable> c; + + { + Glib::Mutex::Lock lm (pending_lock); + for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) { + delete *i; } + pending_controllables.clear (); + } + + Glib::Mutex::Lock lm2 (controllables_lock); + controllables.clear (); + nlist = node.children(); // "controls" + + if (nlist.empty()) { + return 0; + } + + nlist = nlist.front()->children (); - nlist = nlist.front()->children (); + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { + if ((prop = (*niter)->property ("id")) != 0) { - if ((prop = (*niter)->property ("id")) != 0) { - - ID id = prop->value (); - c = session->controllable_by_id (id); - - if (c) { - MIDIControllable* mc = new MIDIControllable (*_port, *c); - if (mc->set_state (**niter, version) == 0) { - controllables.insert (mc); - } - - } else { - warning << string_compose ( - _("Generic MIDI control: controllable %1 not found in session (ignored)"), - id) << endmsg; + ID id = prop->value (); + c = session->controllable_by_id (id); + + if (c) { + MIDIControllable* mc = new MIDIControllable (*_port, *c); + if (mc->set_state (**niter, version) == 0) { + controllables.insert (mc); } + + } else { + warning << string_compose ( + _("Generic MIDI control: controllable %1 not found in session (ignored)"), + id) << endmsg; } } } diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.h b/libs/surfaces/generic_midi/generic_midi_control_protocol.h index c42d796e81..39958bcf26 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.h +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.h @@ -44,7 +44,6 @@ class GenericMidiControlProtocol : public ARDOUR::ControlProtocol { ARDOUR::microseconds_t last_feedback_time; bool do_feedback; - bool auto_binding; void _send_feedback (); void send_feedback (); @@ -64,10 +63,6 @@ class GenericMidiControlProtocol : public ARDOUR::ControlProtocol { void create_binding (PBD::Controllable*, int, int); void delete_binding (PBD::Controllable*); - - void auto_binding_on(); - void auto_binding_off(); - }; #endif /* ardour_generic_midi_control_protocol_h */ diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc index a1f5abf3b0..d6b4007194 100644 --- a/libs/surfaces/generic_midi/midicontrollable.cc +++ b/libs/surfaces/generic_midi/midicontrollable.cc @@ -19,10 +19,13 @@ #include <cstdio> /* for sprintf, sigh */ #include <climits> + #include "pbd/error.h" #include "pbd/xml++.h" + #include "midi++/port.h" #include "midi++/channel.h" + #include "ardour/automation_control.h" #include "midicontrollable.h" @@ -111,7 +114,7 @@ void MIDIControllable::learn_about_external_control () { drop_external_control (); - _port.input()->any.connect (midi_learn_connection, boost::bind (&MIDIControllable::midi_receiver, this, _1, _2, _3)); + _port.input()->any.connect_same_thread (midi_learn_connection, boost::bind (&MIDIControllable::midi_receiver, this, _1, _2, _3)); } void @@ -285,43 +288,43 @@ MIDIControllable::bind_midi (channel_t chn, eventType ev, MIDI::byte additional) int chn_i = chn; switch (ev) { case MIDI::off: - p.channel_note_off[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_note_off, this, _1, _2)); + p.channel_note_off[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_note_off, this, _1, _2)); /* if this is a bistate, connect to noteOn as well, and we'll toggle back and forth between the two. */ if (bistate) { - p.channel_note_on[chn_i].connect (midi_sense_connection[1], boost::bind (&MIDIControllable::midi_sense_note_on, this, _1, _2)); + p.channel_note_on[chn_i].connect_same_thread (midi_sense_connection[1], boost::bind (&MIDIControllable::midi_sense_note_on, this, _1, _2)); } _control_description = "MIDI control: NoteOff"; break; case MIDI::on: - p.channel_note_on[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_note_on, this, _1, _2)); + p.channel_note_on[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_note_on, this, _1, _2)); if (bistate) { - p.channel_note_off[chn_i].connect (midi_sense_connection[1], boost::bind (&MIDIControllable::midi_sense_note_off, this, _1, _2)); + p.channel_note_off[chn_i].connect_same_thread (midi_sense_connection[1], boost::bind (&MIDIControllable::midi_sense_note_off, this, _1, _2)); } _control_description = "MIDI control: NoteOn"; break; case MIDI::controller: - p.channel_controller[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_controller, this, _1, _2)); + p.channel_controller[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_controller, this, _1, _2)); snprintf (buf, sizeof (buf), "MIDI control: Controller %d", control_additional); _control_description = buf; break; case MIDI::program: if (!bistate) { - p.channel_program_change[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_program_change, this, _1, _2)); + p.channel_program_change[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_program_change, this, _1, _2)); _control_description = "MIDI control: ProgramChange"; } break; case MIDI::pitchbend: if (!bistate) { - p.channel_pitchbend[chn_i].connect (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_pitchbend, this, _1, _2)); + p.channel_pitchbend[chn_i].connect_same_thread (midi_sense_connection[0], boost::bind (&MIDIControllable::midi_sense_pitchbend, this, _1, _2)); _control_description = "MIDI control: Pitchbend"; } break; diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 9f4ffb10c0..48d074e117 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -43,6 +43,7 @@ #include "ardour/dB.h" #include "ardour/debug.h" #include "ardour/location.h" +#include "ardour/midi_ui.h" #include "ardour/panner.h" #include "ardour/route.h" #include "ardour/session.h" @@ -71,8 +72,11 @@ using boost::shared_ptr; MackieMidiBuilder builder; +#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */ +#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__)) + MackieControlProtocol::MackieControlProtocol (Session& session) - : ControlProtocol (session, X_("Mackie")) + : ControlProtocol (session, X_("Mackie"), MidiControlUI::instance()) , _current_initial_bank (0) , _surface (0) , _jog_wheel (*this) @@ -536,23 +540,23 @@ void MackieControlProtocol::connect_session_signals() { // receive routes added - session->RouteAdded.connect(session_connections, boost::bind (&MackieControlProtocol::notify_route_added, this, _1)); + session->RouteAdded.connect(session_connections, ui_bind (&MackieControlProtocol::notify_route_added, this, _1), midi_ui_context()); // receive record state toggled - session->RecordStateChanged.connect(session_connections, boost::bind (&MackieControlProtocol::notify_record_state_changed, this)); + session->RecordStateChanged.connect(session_connections, ui_bind (&MackieControlProtocol::notify_record_state_changed, this), midi_ui_context()); // receive transport state changed - session->TransportStateChange.connect(session_connections, boost::bind (&MackieControlProtocol::notify_transport_state_changed, this)); + session->TransportStateChange.connect(session_connections, ui_bind (&MackieControlProtocol::notify_transport_state_changed, this), midi_ui_context()); // receive punch-in and punch-out - Config->ParameterChanged.connect(session_connections, boost::bind (&MackieControlProtocol::notify_parameter_changed, this, _1)); - session->config.ParameterChanged.connect (session_connections, boost::bind (&MackieControlProtocol::notify_parameter_changed, this, _1)); + Config->ParameterChanged.connect(session_connections, ui_bind (&MackieControlProtocol::notify_parameter_changed, this, _1), midi_ui_context()); + session->config.ParameterChanged.connect (session_connections, ui_bind (&MackieControlProtocol::notify_parameter_changed, this, _1), midi_ui_context()); // receive rude solo changed - session->SoloActive.connect(session_connections, boost::bind (&MackieControlProtocol::notify_solo_active_changed, this, _1)); + session->SoloActive.connect(session_connections, ui_bind (&MackieControlProtocol::notify_solo_active_changed, this, _1), midi_ui_context()); // make sure remote id changed signals reach here // see also notify_route_added Sorted sorted = get_sorted_routes(); for (Sorted::iterator it = sorted.begin(); it != sorted.end(); ++it) { - ((*it)->RemoteControlIDChanged.connect (route_connections, boost::bind(&MackieControlProtocol::notify_remote_id_changed, this))); + (*it)->RemoteControlIDChanged.connect (route_connections, ui_bind(&MackieControlProtocol::notify_remote_id_changed, this), midi_ui_context()); } } @@ -569,9 +573,9 @@ MackieControlProtocol::add_port (MIDI::Port & midi_port, int number) MackiePort * sport = new MackiePort (*this, midi_port, number); _ports.push_back (sport); - sport->init_event.connect (port_connections, boost::bind (&MackieControlProtocol::handle_port_init, this, sport)); - sport->active_event.connect (port_connections, boost::bind (&MackieControlProtocol::handle_port_active, this, sport)); - sport->inactive_event.connect (port_connections, boost::bind (&MackieControlProtocol::handle_port_inactive, this, sport)); + sport->init_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_port_init, this, sport)); + sport->active_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_port_active, this, sport)); + sport->inactive_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_port_inactive, this, sport)); } } @@ -652,7 +656,7 @@ MackieControlProtocol::initialize_surface() // Connect events. Must be after route table otherwise there will be trouble for (MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it) { - (*it)->control_event.connect (port_connections, boost::bind (&MackieControlProtocol::handle_control_event, this, _1, _2, _3)); + (*it)->control_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_control_event, this, _1, _2, _3)); } } @@ -1409,7 +1413,7 @@ MackieControlProtocol::notify_route_added (ARDOUR::RouteList & rl) typedef ARDOUR::RouteList ARS; for (ARS::iterator it = rl.begin(); it != rl.end(); ++it) { - (*it)->RemoteControlIDChanged.connect (route_connections, boost::bind (&MackieControlProtocol::notify_remote_id_changed, this)); + (*it)->RemoteControlIDChanged.connect (route_connections, ui_bind (&MackieControlProtocol::notify_remote_id_changed, this), midi_ui_context()); } } diff --git a/libs/surfaces/mackie/mackie_port.cc b/libs/surfaces/mackie/mackie_port.cc index 069ad9abb4..476e6acb81 100644 --- a/libs/surfaces/mackie/mackie_port.cc +++ b/libs/surfaces/mackie/mackie_port.cc @@ -90,7 +90,7 @@ void MackiePort::open() { DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackiePort::open %1\n", *this)); - port().input()->sysex.connect (sysex_connection, boost::bind (&MackiePort::handle_midi_sysex, this, _1, _2, _3)); + port().input()->sysex.connect_same_thread (sysex_connection, boost::bind (&MackiePort::handle_midi_sysex, this, _1, _2, _3)); // make sure the device is connected init(); @@ -272,7 +272,7 @@ void MackiePort::finalise_init( bool yn ) void MackiePort::connect_any() { if (!any_connection.connected()) { - port().input()->any.connect (any_connection, boost::bind (&MackiePort::handle_midi_any, this, _1, _2, _3)); + port().input()->any.connect_same_thread (any_connection, boost::bind (&MackiePort::handle_midi_any, this, _1, _2, _3)); } } diff --git a/libs/surfaces/mackie/route_signal.cc b/libs/surfaces/mackie/route_signal.cc index 9a3dd41bf4..6dc8532db9 100644 --- a/libs/surfaces/mackie/route_signal.cc +++ b/libs/surfaces/mackie/route_signal.cc @@ -19,6 +19,7 @@ #include "ardour/route.h" #include "ardour/track.h" +#include "ardour/midi_ui.h" #include "ardour/panner.h" #include "mackie_control_protocol.h" @@ -29,38 +30,41 @@ using namespace ARDOUR; using namespace Mackie; using namespace std; +#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */ +#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__)) + void RouteSignal::connect() { if (_strip.has_solo()) { - _route->solo_control()->Changed.connect(connections, boost::bind (&MackieControlProtocol::notify_solo_changed, &_mcp, this)); + _route->solo_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_solo_changed, &_mcp, this), midi_ui_context()); } if (_strip.has_mute()) { - _route->mute_control()->Changed.connect(connections, boost::bind (&MackieControlProtocol::notify_mute_changed, &_mcp, this)); + _route->mute_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_mute_changed, &_mcp, this), midi_ui_context()); } if (_strip.has_gain()) { - _route->gain_control()->Changed.connect(connections, boost::bind (&MackieControlProtocol::notify_gain_changed, &_mcp, this, false)); + _route->gain_control()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_gain_changed, &_mcp, this, false), midi_ui_context()); } - _route->NameChanged.connect (connections, boost::bind (&MackieControlProtocol::notify_name_changed, &_mcp, this)); + _route->NameChanged.connect (connections, ui_bind (&MackieControlProtocol::notify_name_changed, &_mcp, this), midi_ui_context()); if (_route->panner()) { - _route->panner()->Changed.connect(connections, boost::bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false)); + _route->panner()->Changed.connect(connections, ui_bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false), midi_ui_context()); for ( unsigned int i = 0; i < _route->panner()->npanners(); ++i ) { - _route->panner()->streampanner(i).Changed.connect (connections, boost::bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false)); + _route->panner()->streampanner(i).Changed.connect (connections, ui_bind (&MackieControlProtocol::notify_panner_changed, &_mcp, this, false), midi_ui_context()); } } boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_route); if (trk) { - trk->rec_enable_control()->Changed .connect(connections, boost::bind (&MackieControlProtocol::notify_record_enable_changed, &_mcp, this)); + trk->rec_enable_control()->Changed .connect(connections, ui_bind (&MackieControlProtocol::notify_record_enable_changed, &_mcp, this), midi_ui_context()); } // TODO this works when a currently-banked route is made inactive, but not // when a route is activated which should be currently banked. - _route->active_changed.connect (connections, boost::bind (&MackieControlProtocol::notify_active_changed, &_mcp, this)); + _route->active_changed.connect (connections, ui_bind (&MackieControlProtocol::notify_active_changed, &_mcp, this), midi_ui_context()); // TODO // SelectedChanged diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index a076b161e7..6054d01334 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -51,9 +51,12 @@ using namespace ARDOUR; using namespace std; using namespace Glib; - #include "pbd/abstract_ui.cc" // instantiate template +#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__)) + +OSC* OSC::_instance = 0; + #ifdef DEBUG static void error_callback(int num, const char *m, const char *path) { @@ -67,10 +70,11 @@ static void error_callback(int, const char *, const char *) #endif OSC::OSC (Session& s, uint32_t port) - : ControlProtocol (s, "OSC") + : ControlProtocol (s, "OSC", this) , AbstractUI<OSCUIRequest> ("osc") , _port(port) { + _instance = this; _shutdown = false; _osc_server = 0; _osc_unix_server = 0; @@ -83,12 +87,13 @@ OSC::OSC (Session& s, uint32_t port) // "Application Hooks" session_loaded (s); - session->Exported.connect (*this, boost::bind (&OSC::session_exported, this, _1, _2)); + session->Exported.connect (*this, ui_bind (&OSC::session_exported, this, _1, _2), this); } OSC::~OSC() { stop (); + _instance = 0; } void @@ -573,7 +578,7 @@ OSC::listen_to_route (boost::shared_ptr<Route> route, lo_address addr) */ if (!route_exists) { - route->GoingAway.connect (*this, boost::bind (&OSC::drop_route, this, boost::weak_ptr<Route> (route))); + route->GoingAway.connect (*this, boost::bind (&OSC::drop_route, this, boost::weak_ptr<Route> (route)), this); } } diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h index 15914bfbbd..0c72671ae9 100644 --- a/libs/surfaces/osc/osc.h +++ b/libs/surfaces/osc/osc.h @@ -60,6 +60,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest> OSC (ARDOUR::Session&, uint32_t port); virtual ~OSC(); + static OSC* instance() { return _instance; } + XMLNode& get_state (); int set_state (const XMLNode&, int version); @@ -182,8 +184,10 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest> void drop_route (boost::weak_ptr<ARDOUR::Route>); typedef std::list<OSCControllable*> Controllables; - + Controllables controllables; + + static OSC* _instance; }; #endif // ardour_osc_h diff --git a/libs/surfaces/osc/osc_controllable.cc b/libs/surfaces/osc/osc_controllable.cc index f5deadd41d..baf888667e 100644 --- a/libs/surfaces/osc/osc_controllable.cc +++ b/libs/surfaces/osc/osc_controllable.cc @@ -24,6 +24,7 @@ #include "ardour/route.h" +#include "osc.h" #include "osc_controllable.h" using namespace sigc; @@ -35,7 +36,7 @@ OSCControllable::OSCControllable (lo_address a, const std::string& p, boost::sha , addr (a) , path (p) { - c->Changed.connect (changed_connection, mem_fun (*this, &OSCControllable::send_change)); + c->Changed.connect (changed_connection, boost::bind (&OSCControllable::send_change, this), OSC::instance()); } OSCControllable::~OSCControllable () diff --git a/libs/surfaces/osc/osc_controllable.h b/libs/surfaces/osc/osc_controllable.h index 67b8284460..55e2815d35 100644 --- a/libs/surfaces/osc/osc_controllable.h +++ b/libs/surfaces/osc/osc_controllable.h @@ -30,9 +30,7 @@ #include "ardour/types.h" namespace ARDOUR { - -class Route; - + class Route; } class OSCControllable : public PBD::Stateful diff --git a/libs/surfaces/powermate/powermate.cc b/libs/surfaces/powermate/powermate.cc index 31154ad879..a3b535c9e0 100644 --- a/libs/surfaces/powermate/powermate.cc +++ b/libs/surfaces/powermate/powermate.cc @@ -89,7 +89,7 @@ int find_powermate(int mode) } PowermateControlProtocol::PowermateControlProtocol (Session& s) - : ControlProtocol (s, "powermate") + : ControlProtocol (s, "powermate", 0 /* XXX need an event loop here */) { } |