Merge windows+cc branch into cairocanvas branch. Not finished, need to now merge...
[ardour.git] / libs / ardour / session_events.cc
index df47cd5baf25752a156285c4891ac2737a99f7f4..19034da24767b79f36748f567690d4d7aa0928de 100644 (file)
 #include <cmath>
 #include <unistd.h>
 
-#include "ardour/timestamps.h"
-
 #include "pbd/error.h"
 #include "pbd/enumwriter.h"
 #include "pbd/stacktrace.h"
+#include "pbd/pthread_utils.h"
 
-#include "ardour/ardour.h"
-#include "ardour/audio_diskstream.h"
-#include "ardour/butler.h"
 #include "ardour/debug.h"
 #include "ardour/session_event.h"
 
@@ -57,32 +53,37 @@ SessionEvent::create_per_thread_pool (const std::string& name, uint32_t nitems)
 }
 
 void *
-SessionEvent::operator new (size_t) 
+SessionEvent::operator new (size_t)
 {
        CrossThreadPool* p = pool->per_thread_pool ();
        SessionEvent* ev = static_cast<SessionEvent*> (p->alloc ());
-       DEBUG_TRACE (DEBUG::SessionEvents, string_compose ("%1 Allocating SessionEvent from %2 ev @ %3\n", pthread_self(), p->name(), ev));
+       DEBUG_TRACE (DEBUG::SessionEvents, string_compose ("%1 Allocating SessionEvent from %2 ev @ %3\n", pthread_name(), p->name(), ev));
+#ifndef NDEBUG
+       if (DEBUG::SessionEvents & PBD::debug_bits) {
+               stacktrace (cerr, 40);
+       }
+#endif
        ev->own_pool = p;
        return ev;
 }
-    
-void 
-SessionEvent::operator delete (void *ptr, size_t /*size*/) 
+
+void
+SessionEvent::operator delete (void *ptr, size_t /*size*/)
 {
        Pool* p = pool->per_thread_pool ();
        SessionEvent* ev = static_cast<SessionEvent*> (ptr);
 
-        DEBUG_TRACE (DEBUG::SessionEvents, string_compose (
-                            "%1 Deleting SessionEvent @ %2 ev thread pool = %3 ev pool = %4\n",
-                            pthread_self(), ev, p->name(), ev->own_pool->name()
-                            ));
+       DEBUG_TRACE (DEBUG::SessionEvents, string_compose (
+                            "%1 Deleting SessionEvent @ %2 ev thread pool = %3 ev pool = %4\n",
+                            pthread_name(), ev, p->name(), ev->own_pool->name()
+                            ));
 
-#ifdef NDEBUG
+#ifndef NDEBUG
        if (DEBUG::SessionEvents & PBD::debug_bits) {
-               stacktrace (cerr, 20);
+               stacktrace (cerr, 40);
        }
 #endif
-       
+
        if (p == ev->own_pool) {
                p->release (ptr);
        } else {
@@ -128,7 +129,7 @@ SessionEventManager::dump_events () const
        }
        cerr << "Next event: ";
 
-        if ((Events::const_iterator) next_event == events.end()) {
+       if ((Events::const_iterator) next_event == events.end()) {
                cerr << "none" << endl;
        } else {
                cerr << "at " << (*next_event)->action_frame << ' '
@@ -173,6 +174,7 @@ SessionEventManager::merge_event (SessionEvent* ev)
 
        switch (ev->type) {
        case SessionEvent::AutoLoop:
+       case SessionEvent::AutoLoopDeclick:
        case SessionEvent::StopOnce:
                _clear_event_type (ev->type);
                break;