Use sys::basename instead of PBD::basename_nosuffix in Session::import_audiofile
[ardour.git] / libs / ardour / osc.cc
index 5aaf9d5591fad410a1ab5159cb5c52eddfe047a4..8903c3781a01334325a6d6fa166cef0b7a1f041b 100644 (file)
@@ -15,7 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *  
- * $Id$
  */
 
 #include <iostream>
@@ -28,6 +27,8 @@
 #include <unistd.h>
 #include <fcntl.h>
 
+#include <pbd/pthread_utils.h>
+
 #include <ardour/osc.h>
 #include <ardour/session.h>
 #include <ardour/route.h>
@@ -59,6 +60,11 @@ int
 OSC::start ()
 {
        char tmpstr[255];
+
+       if (_osc_server) {
+               /* already started */
+               return 0;
+       }
        
        for (int j=0; j < 20; ++j) {
                snprintf(tmpstr, sizeof(tmpstr), "%d", _port);
@@ -109,16 +115,22 @@ OSC::start ()
 int
 OSC::stop ()
 {      
+       if (_osc_server == 0) {
+               /* already stopped */
+               return 0;
+       }
+
+       // stop server thread
+       terminate_osc_thread();
+
        lo_server_free (_osc_server);
+       _osc_server = 0;
        
        if (!_osc_unix_socket_path.empty()) {
                // unlink it
                unlink(_osc_unix_socket_path.c_str());
        }
        
-       // stop server thread
-       terminate_osc_thread();
-
        return 0;
 }
 
@@ -199,10 +211,15 @@ OSC::init_osc_thread ()
                return false;
        }
        
-       pthread_create (&_osc_thread, NULL, &OSC::_osc_receiver, this);
+       pthread_attr_t attr;
+       pthread_attr_init(&attr);
+       pthread_attr_setstacksize(&attr, 500000);
+
+       pthread_create (&_osc_thread, &attr, &OSC::_osc_receiver, this);
        if (!_osc_thread) {
                return false;
        }
+       pthread_attr_destroy(&attr);
 
        //pthread_detach (_osc_thread);
        return true;
@@ -266,6 +283,8 @@ OSC::get_unix_server_url()
 void *
 OSC::_osc_receiver(void * arg)
 {
+       PBD::ThreadCreated (pthread_self(), X_("OSC"));
+
        static_cast<OSC*> (arg)->osc_receiver();
        return 0;
 }
@@ -365,7 +384,7 @@ void
 OSC::set_session (Session& s)
 {
        session = &s;
-       session->going_away.connect (mem_fun (*this, &OSC::session_going_away));
+       session->GoingAway.connect (mem_fun (*this, &OSC::session_going_away));
 }
 
 void