stop metering thread as we disconnect a session from audioengine; explicitly drop...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 31 Dec 2009 19:49:22 +0000 (19:49 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 31 Dec 2009 19:49:22 +0000 (19:49 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6425 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/audioengine.cc
libs/ardour/butler.cc
libs/ardour/route.cc
libs/pbd/controllable.cc
libs/pbd/pthread_utils.cc
libs/surfaces/generic_midi/midifunction.cc

index 322365fb9f6783fe5f117fc9287125a7e6be62e6..2035265c466fe1487f272e8c160fc00027819ac4 100644 (file)
@@ -134,9 +134,7 @@ _thread_init_callback (void * /*arg*/)
           knows about it.
        */
 
-       char* c = new char[12];
-       strcpy (c, X_("audioengine"));
-       pthread_set_name (c);
+       pthread_set_name (X_("audioengine"));
 
        PBD::notify_gui_about_thread_creation ("gui", pthread_self(), X_("Audioengine"), 4096);
        PBD::notify_gui_about_thread_creation ("midiui", pthread_self(), X_("Audioengine"), 128);
@@ -209,8 +207,6 @@ AudioEngine::start ()
                        // error << _("cannot activate JACK client") << endmsg;
                }
 
-               start_metering_thread();
-
                _raw_buffer_sizes[DataType::AUDIO] = blocksize * sizeof(float);
        }
 
@@ -550,6 +546,8 @@ AudioEngine::start_metering_thread ()
 void
 AudioEngine::meter_thread ()
 {
+       pthread_set_name (X_("meter"));
+
        while (true) {
                Glib::usleep (10000); /* 1/100th sec interval */
                if (g_atomic_int_get(&m_meter_exit)) {
@@ -567,6 +565,8 @@ AudioEngine::set_session (Session *s)
        SessionHandlePtr::set_session (s);
 
        if (_session) {
+
+               start_metering_thread ();
                
                nframes_t blocksize = jack_get_buffer_size (_jack);
                
@@ -602,6 +602,8 @@ AudioEngine::remove_session ()
 
        if (_running) {
 
+               stop_metering_thread ();
+
                if (_session) {
                        session_remove_pending = true;
                        session_removed.wait(_process_lock);
index 25d8d6c1481e1190292d82184c5871425b5af854..addf6ddf27f0e8b1333ab70c91d610aaf92f4a4f 100644 (file)
@@ -115,6 +115,7 @@ void *
 Butler::_thread_work (void* arg)
 {
        SessionEvent::create_per_thread_pool ("butler events", 64);
+       pthread_set_name (X_("butler"));
        return ((Butler *) arg)->thread_work ();
 }
 
index 69b37fb7c3f7ff79622902bafc92d23d45e80efb..29cc32bf24996bd44388d6878243fb67218c16f3 100644 (file)
@@ -165,8 +165,14 @@ Route::~Route ()
 {
        DEBUG_TRACE (DEBUG::Destruction, string_compose ("route %1 destructor\n", _name));
 
+       /* do this early so that we don't get incoming signals as we are going through destruction 
+        */
+
+       drop_connections ();
+
        /* don't use clear_processors here, as it depends on the session which may
-          be half-destroyed by now */
+          be half-destroyed by now 
+       */
 
        Glib::RWLock::WriterLock lm (_processor_lock);
        for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
index d5b81a73ed0eeebd13453f60eae65131e84f8253..38780bddbe4ea64d8612731085fb1de01c121344 100644 (file)
@@ -40,6 +40,7 @@ PBD::ScopedConnectionList registry_connections;
 Controllable::Controllable (const string& name, Flag f)
        : _name (name)
        , _flags (f)
+       , _touching (false)
 {
        add (*this);
 }
index 34ac6fd1afabba93e4b262da4f1b9fc60c68311d..d9e5ca40785f6c2aba4e76ad5876b68da8121338 100644 (file)
@@ -21,6 +21,7 @@
 #include <set>
 #include <iostream>
 #include <string>
+#include <cstring>
 #include <stdint.h>
 
 #include "pbd/pthread_utils.h"
@@ -59,9 +60,9 @@ PBD::notify_gui_about_thread_creation (std::string target_gui, pthread_t thread,
 struct ThreadStartWithName {
     void* (*thread_work)(void*);
     void* arg;
-    const char* name;
+    std::string name;
     
-    ThreadStartWithName (void* (*f)(void*), void* a, const char* s)
+    ThreadStartWithName (void* (*f)(void*), void* a, const std::string& s)
            : thread_work (f), arg (a), name (s) {}
 };
 
@@ -72,7 +73,7 @@ fake_thread_start (void* arg)
        void* (*thread_work)(void*) = ts->thread_work;
        void* thread_arg = ts->arg;
 
-       pthread_set_name (ts->name);
+       pthread_set_name (ts->name.c_str());
 
        delete ts;
        /* name will be deleted by the default handler for GStaticPrivate, when the thread exits */
@@ -90,10 +91,7 @@ pthread_create_and_store (string name, pthread_t  *thread, void * (*start_routin
        pthread_attr_init(&default_attr);
        pthread_attr_setstacksize(&default_attr, 500000);
 
-       char* cname = new char[name.length() + 1];
-       strcpy (cname, name.c_str());
-
-       ThreadStartWithName* ts = new ThreadStartWithName (start_routine, arg, cname);
+       ThreadStartWithName* ts = new ThreadStartWithName (start_routine, arg, name);
 
        if ((ret = thread_creator (thread, &default_attr, fake_thread_start, ts)) == 0) {
                pthread_mutex_lock (&thread_map_lock);
@@ -109,8 +107,9 @@ pthread_create_and_store (string name, pthread_t  *thread, void * (*start_routin
 void
 pthread_set_name (const char *str)
 {
-       /* str will be deleted when this thread exits */
-       thread_name.set (const_cast<char*>(str));
+       /* copy string and delete it when exiting */
+       
+       thread_name.set (strdup (str), free);
 }
 
 const char *
index d6cbdb9a6e7eb0c537aa11241dd6358343b30db1..3ce447b799c980df7195ba038a9169992ea20761 100644 (file)
@@ -34,7 +34,7 @@ MIDIFunction::MIDIFunction (MIDI::Port& p)
 
 MIDIFunction::~MIDIFunction ()
 {
-       delete sysex;
+       delete [] sysex;
 }
 
 int