changeset 608:d7f3dfe6f9a4

* solaris build fixes
author Chris Cannam
date Thu, 10 Sep 2009 18:44:45 +0000
parents a67651386253
children 1a30913e26bc
files data/fileio/FileSource.cpp data/midi/MIDIInput.cpp data/model/FFTModel.cpp data/model/ImageModel.h data/model/IntervalModel.h data/model/PowerOfSqrtTwoZoomConstraint.cpp data/model/RegionModel.h data/model/SparseModel.h data/model/TextModel.h data/model/WaveFileModel.cpp data/osc/OSCQueue.cpp plugin/DSSIPluginInstance.cpp plugin/FeatureExtractionPluginFactory.cpp plugin/RealTimePluginFactory.cpp plugin/api/dssi_alsa_compat.c system/System.cpp
diffstat 16 files changed, 109 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/fileio/FileSource.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -30,6 +30,8 @@
 #include <iostream>
 #include <cstdlib>
 
+#include <unistd.h>
+
 //#define DEBUG_FILE_SOURCE 1
 
 int
--- a/data/midi/MIDIInput.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/midi/MIDIInput.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -17,6 +17,8 @@
 
 #include "rtmidi/RtMidi.h"
 
+#include <unistd.h>
+
 MIDIInput::MIDIInput(QString name, FrameTimer *timer) :
     m_rtmidi(),
     m_frameTimer(timer),
--- a/data/model/FFTModel.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/model/FFTModel.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -24,6 +24,10 @@
 
 #include <cassert>
 
+#ifndef __GNUC__
+#include <alloca.h>
+#endif
+
 FFTModel::FFTModel(const DenseTimeValueModel *model,
                    int channel,
                    WindowType windowType,
@@ -172,7 +176,11 @@
     size_t h = getHeight();
     result.reserve(h);
 
+#ifdef __GNUC__
     float magnitudes[h];
+#else
+    float *magnitudes = (float *)alloca(h * sizeof(float));
+#endif
 
     if (m_server->getMagnitudesAt(x << m_xshift, magnitudes)) {
 
@@ -256,7 +264,11 @@
         int maxbin = ymax;
         if (maxbin < getHeight() - 1) maxbin = maxbin + 1;
         const int n = maxbin - minbin + 1;
+#ifdef __GNUC__
         float values[n];
+#else
+        float *values = (float *)alloca(n * sizeof(float));
+#endif
         getMagnitudesAt(x, values, minbin, maxbin - minbin + 1);
         for (size_t bin = ymin; bin <= ymax; ++bin) {
             if (bin == minbin || bin == maxbin) continue;
--- a/data/model/ImageModel.h	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/model/ImageModel.h	Thu Sep 10 18:44:45 2009 +0000
@@ -164,7 +164,7 @@
                 (row, column, role);
         }
 
-        PointListIterator i = getPointListIteratorForRow(row);
+        PointListConstIterator i = getPointListIteratorForRow(row);
         if (i == m_points.end()) return QVariant();
 
         switch (column) {
--- a/data/model/IntervalModel.h	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/model/IntervalModel.h	Thu Sep 10 18:44:45 2009 +0000
@@ -134,14 +134,14 @@
 
     PointType endPoint(end);
     
-    typename I::PointListIterator endItr = I::m_points.upper_bound(endPoint);
+    typename I::PointListConstIterator endItr = I::m_points.upper_bound(endPoint);
 
     if (endItr != I::m_points.end()) ++endItr;
     if (endItr != I::m_points.end()) ++endItr;
 
     typename I::PointList rv;
 
-    for (typename I::PointListIterator i = endItr; i != I::m_points.begin(); ) {
+    for (typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) {
         --i;
         if (i->frame < start) {
             if (i->frame + long(i->duration) >= start) {
@@ -171,11 +171,11 @@
 
     PointType endPoint(end);
     
-    typename I::PointListIterator endItr = I::m_points.upper_bound(endPoint);
+    typename I::PointListConstIterator endItr = I::m_points.upper_bound(endPoint);
 
     typename I::PointList rv;
 
-    for (typename I::PointListIterator i = endItr; i != I::m_points.begin(); ) {
+    for (typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) {
         --i;
         if (i->frame < start) {
             if (i->frame + long(i->duration) >= start) {
--- a/data/model/PowerOfSqrtTwoZoomConstraint.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/model/PowerOfSqrtTwoZoomConstraint.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -44,7 +44,7 @@
 	float val = 1.0, prevVal = 1.0;
 	while (val + 0.01 < blockSize) {
 	    prevVal = val;
-	    val *= sqrt(2);
+	    val *= sqrt(2.f);
 	}
 	size_t rval;
 	if (dir == RoundUp) rval = size_t(val + 0.01);
@@ -70,7 +70,7 @@
 	if (type == 0) {
 	    base = (1 << power);
 	} else {
-	    base = (((unsigned int)((1 << minCachePower) * sqrt(2) + 0.01))
+	    base = (((unsigned int)((1 << minCachePower) * sqrt(2.) + 0.01))
 		    << (power - minCachePower));
 	}
 
--- a/data/model/RegionModel.h	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/model/RegionModel.h	Thu Sep 10 18:44:45 2009 +0000
@@ -163,7 +163,7 @@
             return IntervalModel<RegionRec>::getData(row, column, role);
         }
 
-        PointListIterator i = getPointListIteratorForRow(row);
+        PointListConstIterator i = getPointListIteratorForRow(row);
         if (i == m_points.end()) return QVariant();
 
         switch (column) {
--- a/data/model/SparseModel.h	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/model/SparseModel.h	Thu Sep 10 18:44:45 2009 +0000
@@ -26,6 +26,7 @@
 #include <set>
 #include <vector>
 #include <algorithm>
+#include <iterator>
 
 #include <cmath>
 
@@ -287,7 +288,12 @@
         if (m_rows.empty()) rebuildRowVector();
         std::vector<long>::iterator i =
             std::lower_bound(m_rows.begin(), m_rows.end(), frame);
+#if defined(__SUNPRO_CC) && defined(__STD_RW_ITERATOR__)
+        int row = 0;
+        std::distance(m_rows.begin(), i, row);
+#else
         int row = std::distance(m_rows.begin(), i);
+#endif
         if (i != m_rows.begin() && (i == m_rows.end() || *i != frame)) {
             --row;
         }
@@ -368,7 +374,10 @@
 
     void getPointIterators(long frame,
                            PointListIterator &startItr,
-                           PointListIterator &endItr) const;
+                           PointListIterator &endItr);
+    void getPointIterators(long frame,
+                           PointListConstIterator &startItr,
+                           PointListConstIterator &endItr) const;
 
     // This is only used if the model is called on to act in
     // TabularModel mode
@@ -376,12 +385,12 @@
     void rebuildRowVector() const
     {
         m_rows.clear();
-        for (PointListIterator i = m_points.begin(); i != m_points.end(); ++i) {
+        for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) {
             m_rows.push_back(i->frame);
         }
     }
 
-    PointListIterator getPointListIteratorForRow(int row) const
+    PointListIterator getPointListIteratorForRow(int row)
     {
         if (m_rows.empty()) rebuildRowVector();
         if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end();
@@ -406,6 +415,32 @@
         }
         return i;
     }
+
+    PointListConstIterator getPointListIteratorForRow(int row) const
+    {
+        if (m_rows.empty()) rebuildRowVector();
+        if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end();
+
+        size_t frame = m_rows[row];
+        int indexAtFrame = 0;
+        int ri = row;
+        while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; }
+        int initialIndexAtFrame = indexAtFrame;
+
+        PointListConstIterator i0, i1;
+        getPointIterators(frame, i0, i1);
+        PointListConstIterator i = i0;
+
+        for (i = i0; i != i1; ++i) {
+            if (indexAtFrame > 0) { --indexAtFrame; continue; }
+            return i;
+        }
+
+        if (indexAtFrame > 0) {
+            std::cerr << "WARNING: SparseModel::getPointListIteratorForRow: No iterator available for row " << row << " (frame = " << frame << ", index at frame = " << initialIndexAtFrame << ", leftover index " << indexAtFrame << ")" << std::endl;
+        }
+        return i;
+    }
 };
 
 
@@ -443,7 +478,7 @@
     QMutexLocker locker(&m_mutex);
     size_t f = 0;
     if (!m_points.empty()) {
-	PointListIterator i(m_points.end());
+	PointListConstIterator i(m_points.end());
 	f = (--i)->frame;
     }
     return f;
@@ -493,8 +528,8 @@
 
     PointType startPoint(start), endPoint(end);
     
-    PointListIterator startItr = m_points.lower_bound(startPoint);
-    PointListIterator   endItr = m_points.upper_bound(endPoint);
+    PointListConstIterator startItr = m_points.lower_bound(startPoint);
+    PointListConstIterator   endItr = m_points.upper_bound(endPoint);
 
     if (startItr != m_points.begin()) --startItr;
     if (startItr != m_points.begin()) --startItr;
@@ -503,7 +538,7 @@
 
     PointList rv;
 
-    for (PointListIterator i = startItr; i != endItr; ++i) {
+    for (PointListConstIterator i = startItr; i != endItr; ++i) {
 	rv.insert(*i);
     }
 
@@ -514,12 +549,12 @@
 typename SparseModel<PointType>::PointList
 SparseModel<PointType>::getPoints(long frame) const
 {
-    PointListIterator startItr, endItr;
+    PointListConstIterator startItr, endItr;
     getPointIterators(frame, startItr, endItr);
 
     PointList rv;
 
-    for (PointListIterator i = startItr; i != endItr; ++i) {
+    for (PointListConstIterator i = startItr; i != endItr; ++i) {
 	rv.insert(*i);
     }
 
@@ -530,7 +565,30 @@
 void
 SparseModel<PointType>::getPointIterators(long frame,
                                           PointListIterator &startItr,
-                                          PointListIterator &endItr) const
+                                          PointListIterator &endItr)
+{
+    QMutexLocker locker(&m_mutex);
+
+    if (m_resolution == 0) {
+        startItr = m_points.end();
+        endItr = m_points.end();
+        return;
+    }
+
+    long start = (frame / m_resolution) * m_resolution;
+    long end = start + m_resolution;
+
+    PointType startPoint(start), endPoint(end);
+    
+    startItr = m_points.lower_bound(startPoint);
+      endItr = m_points.upper_bound(endPoint);
+}
+
+template <typename PointType>
+void
+SparseModel<PointType>::getPointIterators(long frame,
+                                          PointListConstIterator &startItr,
+                                          PointListConstIterator &endItr) const
 {
     QMutexLocker locker(&m_mutex);
 
@@ -558,7 +616,7 @@
     PointType lookupPoint(originFrame);
     PointList rv;
 
-    PointListIterator i = m_points.lower_bound(lookupPoint);
+    PointListConstIterator i = m_points.lower_bound(lookupPoint);
     if (i == m_points.begin()) return rv;
 
     --i;
@@ -581,7 +639,7 @@
     PointType lookupPoint(originFrame);
     PointList rv;
 
-    PointListIterator i = m_points.upper_bound(lookupPoint);
+    PointListConstIterator i = m_points.upper_bound(lookupPoint);
     if (i == m_points.end()) return rv;
 
     long frame = i->frame;
@@ -738,7 +796,7 @@
 	.arg(getObjectExportId(&m_points))
 	.arg(PointType(0).getDimensions());
 
-    for (PointListIterator i = m_points.begin(); i != m_points.end(); ++i) {
+    for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) {
         i->toXml(out, indent + "  ");
     }
 
--- a/data/model/TextModel.h	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/model/TextModel.h	Thu Sep 10 18:44:45 2009 +0000
@@ -129,7 +129,7 @@
                 (row, column, role);
         }
 
-        PointListIterator i = getPointListIteratorForRow(row);
+        PointListConstIterator i = getPointListIteratorForRow(row);
         if (i == m_points.end()) return QVariant();
 
         switch (column) {
--- a/data/model/WaveFileModel.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/model/WaveFileModel.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -494,8 +494,8 @@
 	    cacheBlock = (1 << m_zoomConstraint.getMinCachePower());
             div = (1 << power) / cacheBlock;
 	} else {
-	    cacheBlock = ((unsigned int)((1 << m_zoomConstraint.getMinCachePower()) * sqrt(2) + 0.01));
-            div = ((unsigned int)((1 << power) * sqrt(2) + 0.01)) / cacheBlock;
+	    cacheBlock = ((unsigned int)((1 << m_zoomConstraint.getMinCachePower()) * sqrt(2.) + 0.01));
+            div = ((unsigned int)((1 << power) * sqrt(2.) + 0.01)) / cacheBlock;
 	}
 
 	size_t startIndex = start / cacheBlock;
@@ -656,7 +656,7 @@
     size_t cacheBlockSize[2];
     cacheBlockSize[0] = (1 << m_model.m_zoomConstraint.getMinCachePower());
     cacheBlockSize[1] = ((unsigned int)((1 << m_model.m_zoomConstraint.getMinCachePower()) *
-                                        sqrt(2) + 0.01));
+                                        sqrt(2.) + 0.01));
     
     size_t frame = 0;
     int readBlockSize = 16384;
--- a/data/osc/OSCQueue.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/data/osc/OSCQueue.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -23,6 +23,7 @@
 #include "base/Profiler.h"
 
 #include <iostream>
+#include <unistd.h>
 
 #define OSC_MESSAGE_QUEUE_SIZE 1023
 
--- a/plugin/DSSIPluginInstance.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/plugin/DSSIPluginInstance.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -27,6 +27,8 @@
 
 #include <cstdlib>
 
+#include <alloca.h>
+
 //#define DEBUG_DSSI 1
 //#define DEBUG_DSSI_PROCESS 1
 
--- a/plugin/FeatureExtractionPluginFactory.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -102,7 +102,8 @@
     }
 
     // Plugins can change the locale, revert it to default.
-    setlocale(LC_ALL, "C");
+    RestoreStartupLocale();
+
     return rv;
 }
 
--- a/plugin/RealTimePluginFactory.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/plugin/RealTimePluginFactory.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -129,6 +129,6 @@
     if (factory) factory->enumeratePlugins(list);
     
     // Plugins can change the locale, revert it to default.
-    setlocale(LC_ALL, "C");
+    RestoreStartupLocale();
 }
 
--- a/plugin/api/dssi_alsa_compat.c	Thu Sep 10 14:31:49 2009 +0000
+++ b/plugin/api/dssi_alsa_compat.c	Thu Sep 10 18:44:45 2009 +0000
@@ -25,6 +25,7 @@
 #define FIXED_EV(x)	(_SND_SEQ_TYPE(SND_SEQ_EVFLG_FIXED) | _SND_SEQ_TYPE(x))
 
 /** Event types conversion array */
+/*
 const unsigned int snd_seq_event_types[256] = {
 	[SND_SEQ_EVENT_SYSTEM ... SND_SEQ_EVENT_RESULT]
 	= FIXED_EV(SND_SEQ_EVFLG_RESULT),
@@ -63,7 +64,7 @@
 	[SND_SEQ_EVENT_NONE]
 	= FIXED_EV(SND_SEQ_EVFLG_NONE),
 };
-
+*/
 /**
  * \file seq/seq_midi_event.c
  * \brief MIDI byte <-> sequencer event coder
--- a/system/System.cpp	Thu Sep 10 14:31:49 2009 +0000
+++ b/system/System.cpp	Thu Sep 10 18:44:45 2009 +0000
@@ -23,6 +23,8 @@
 #ifndef _WIN32
 #include <signal.h>
 #include <sys/statvfs.h>
+#include <locale.h>
+#include <unistd.h>
 #endif
 
 #ifdef __APPLE__