'libs/ardour' - Main body of changes required for building with MSVC
authorJohn Emmas <johne53@tiscali.co.uk>
Sun, 4 Aug 2013 14:36:07 +0000 (15:36 +0100)
committerJohn Emmas <johne53@tiscali.co.uk>
Sun, 4 Aug 2013 14:36:07 +0000 (15:36 +0100)
30 files changed:
libs/ardour/ardour/audioplaylist.h
libs/ardour/ardour/lv2_plugin.h
libs/ardour/ardour/midi_playlist.h
libs/ardour/ardour/playlist.h
libs/ardour/audiosource.cc
libs/ardour/automation_watch.cc
libs/ardour/diskstream.cc
libs/ardour/export_format_base.cc
libs/ardour/globals.cc
libs/ardour/graph.cc
libs/ardour/ltc_slave.cc
libs/ardour/lv2_evbuf.c
libs/ardour/meter.cc
libs/ardour/midi_clock_slave.cc
libs/ardour/midi_track.cc
libs/ardour/mix.cc
libs/ardour/mtc_slave.cc
libs/ardour/port_set.cc
libs/ardour/rc_configuration.cc
libs/ardour/session_ltc.cc
libs/ardour/session_midi.cc
libs/ardour/template_utils.cc
libs/ardour/vst_plugin.cc
libs/ardour/worker.cc
libs/pbd/msvc/msvc_pbd.cc
libs/pbd/pbd/msvc_pbd.h
libs/pbd/pbd/semaphore.h
msvc_extra_headers/ardourext/float_cast.h.input
msvc_extra_headers/ardourext/misc.h.input
msvc_extra_headers/ardourext/sys/targetsxs.h.input

index 478d4872cdfe02afdd56503e3babc7a83b6a1871..3c987c0aa0d2efdb53bef32097e41321d4dc6cd0 100644 (file)
@@ -29,7 +29,6 @@
 namespace ARDOUR  {
 
 class Session;
-class Region;
 class AudioRegion;
 class Source;
 
index 4cd34b30266ef6405c37a926c5089d5ec6480c81..5154cd4d3e710cc8148e3a3322f2c44ed9096ef0 100644 (file)
@@ -29,6 +29,8 @@
 #include "ardour/worker.h"
 #include "pbd/ringbuffer.h"
 
+typedef struct LV2_Evbuf_Impl LV2_Evbuf;
+
 namespace ARDOUR {
 
 // a callback function for lilv_state_new_from_instance(). friend of LV2Plugin
index 543e1b353f4b44e2bde000f457f83da22c3402cc..99d0b983216ed0c0597bce3e2f1e2702e0c468d7 100644 (file)
@@ -32,7 +32,6 @@ namespace ARDOUR
 {
 
 class Session;
-class Region;
 class MidiRegion;
 class Source;
 template<typename T> class MidiRingBuffer;
index 754e48cc25d1fbf71a2956c9e1250295b62bd71b..fbe747b29720818ccdbd108d0f7f85f7b8726f4c 100644 (file)
 #include "evoral/types.hpp"
 
 #include "ardour/ardour.h"
+#include "ardour/region.h"
 #include "ardour/session_object.h"
 #include "ardour/data_type.h"
 
 namespace ARDOUR  {
 
 class Session;
-class Region;
 class Playlist;
 class Crossfade;
 
index 65540d4e3dd153a8b00e9caa9068f36a143ea0bb..f6ced3518638639e7c58479a2f1f2d52a46b0d4b 100644 (file)
@@ -180,7 +180,7 @@ AudioSource::peaks_ready (boost::function<void()> doThisWhenReady, ScopedConnect
 void
 AudioSource::touch_peakfile ()
 {
-       struct stat statbuf;
+       GStatBuf statbuf;
 
        if (g_stat (peakpath.c_str(), &statbuf) != 0 || statbuf.st_size == 0) {
                return;
@@ -216,7 +216,7 @@ AudioSource::rename_peakfile (string newpath)
 int
 AudioSource::initialize_peakfile (string audio_path)
 {
-       struct stat statbuf;
+       GStatBuf statbuf;
 
        peakpath = peak_path (audio_path);
 
index 4e5f64bd32cff5336e42534720250260f7755ecb..91fe4d38edbcf727aa5830aa21dea432ee10adb0 100644 (file)
@@ -136,7 +136,7 @@ void
 AutomationWatch::thread ()
 {
        while (_run_thread) {
-               Glib::usleep ((useconds_t) floor (Config->get_automation_interval_msecs() * 1000));
+               Glib::usleep ((gulong) floor (Config->get_automation_interval_msecs() * 1000));
                timer ();
        }
 }
index d931cfd432ed1ca0a579cf8cd4cf26e2157b20a6..e046d5a830beda849f45ab7a77208f8de90a18ba 100644 (file)
@@ -600,7 +600,7 @@ Diskstream::check_record_status (framepos_t transport_frame, bool can_record)
        */
 
        rolling = _session.transport_speed() != 0.0f;
-       possibly_recording = (rolling << 2) | (record_enabled() << 1) | can_record;
+       possibly_recording = (rolling << 2) | ((int)record_enabled() << 1) | (int)can_record;
        change = possibly_recording ^ last_possibly_recording;
 
        if (possibly_recording == last_possibly_recording) {
index ed8bb9d5f875f934217e9cf039c566034ba228aa..1eda44991550f3e6267170c3f3718faef8c80fc7 100644 (file)
@@ -185,7 +185,7 @@ ExportFormatBase::nearest_sample_rate (framecnt_t sample_rate)
        SampleRate best_match = SR_None;
 
        #define DO_SR_COMPARISON(rate) \
-       diff = std::fabs((rate) - sample_rate); \
+       diff = std::fabs((double)((rate) - sample_rate)); \
        if(diff < smallest_diff) { \
                smallest_diff = diff; \
                best_match = (rate); \
index fe07332d855b6d9ebdc9d163015b80769c611d08..c0fca7c7a017d295b9926aa5126fe2cf3a99026e 100644 (file)
 #include "libardour-config.h"
 #endif
 
+#ifdef interface
+#undef interface
+#endif
+
 #include <cstdio> // Needed so that libraptor (included in lrdf) won't complain
 #include <cstdlib>
 #include <sys/stat.h>
@@ -44,7 +48,7 @@
 #include "ardour/audio_unit.h"
 #endif
 
-#ifdef __SSE__
+#if defined(__SSE__) || defined(USE_XMMINTRIN)
 #include <xmmintrin.h>
 #endif
 
index 12752c158e91e0b54cbc0ba1c4ae9a9d87365c1d..fe76fd74edf0bbe3c439d272ee3dcd96479334a2 100644 (file)
@@ -584,12 +584,10 @@ Graph::process_one_route (Route* route)
 bool
 Graph::in_process_thread () const
 {
-#ifndef WIN32
        for (list<pthread_t>::const_iterator i = _thread_list.begin (); i != _thread_list.end(); ++i) {
-               if (*i == pthread_self()) {
+               if (pthread_equal(*i, pthread_self())) {
                        return true;
                }
        }
        return false;
-#endif
 }
index e9be71d98e84e59860435d6a415687c6b81651ac..ac93ccdb4068e3fbca50789fcc7091d6c5c90264 100644 (file)
@@ -150,7 +150,7 @@ LTC_Slave::reset()
 }
 
 void
-LTC_Slave::parse_ltc(const jack_nframes_t nframes, const jack_default_audio_sample_t * const in, const framecnt_t posinfo)
+LTC_Slave::parse_ltc(const jack_nframes_t nframes, const jack_default_audio_sample_t * const in, const ARDOUR::framecnt_t posinfo)
 {
        jack_nframes_t i;
        unsigned char sound[8192];
@@ -591,7 +591,7 @@ LTC_Slave::approximate_current_delta() const
                snprintf(delta, sizeof(delta), _("flywheel"));
        } else {
                snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\" >%s%s%" PRIi64 "</span>sm",
-                               LEADINGZERO(abs(current_delta)), PLUSMINUS(-current_delta), abs(current_delta));
+                               LEADINGZERO(llabs(current_delta)), PLUSMINUS(-current_delta), llabs(current_delta));
        }
        return std::string(delta);
 }
index 8942d19a9b2b038cb2ad9599939508b051250375..fba7fd521ddc42dd7aa78f63121045e804877895 100644 (file)
@@ -219,7 +219,7 @@ lv2_evbuf_get(LV2_Evbuf_Iterator iter,
                *subframes = 0;
                *type      = aev->body.type;
                *size      = aev->body.size;
-               *data      = LV2_ATOM_BODY(&aev->body);
+               *data      = (uint8_t*)LV2_ATOM_BODY(&aev->body);
                break;
        }
 
index a7857f58596d3546a64a52979a9bfdbebaf8b2a9..54cad1a956d3ddf2c2672abeff2d2b6a50b79db1 100644 (file)
@@ -332,7 +332,7 @@ PeakMeter::meter ()
                } else {
                        // do falloff
                        new_peak = _visible_peak_power[n] - (audio_meter_falloff);
-                       _visible_peak_power[n] = std::max (new_peak, -INFINITY);
+                       _visible_peak_power[n] = std::max ((double)new_peak, -INFINITY);
                }
        }
 }
index 8906ddb6c4733da38000f3e38f66e14551fdaeeb..75f3c13f1c3d134752b6eed6493a0770e6ba39bf 100644 (file)
@@ -251,7 +251,7 @@ MIDIClock_Slave::stop (Parser& /*parser*/, framepos_t /*timestamp*/)
 }
 
 void
-MIDIClock_Slave::position (Parser& /*parser*/, byte* message, size_t size)
+MIDIClock_Slave::position (Parser& /*parser*/, MIDI::byte* message, size_t size)
 {
        // we are note supposed to get position messages while we are running
        // so lets be robust and ignore those
@@ -260,8 +260,8 @@ MIDIClock_Slave::position (Parser& /*parser*/, byte* message, size_t size)
        }
 
        assert(size == 3);
-       byte lsb = message[1];
-       byte msb = message[2];
+       MIDI::byte lsb = message[1];
+       MIDI::byte msb = message[2];
        assert((lsb <= 0x7f) && (msb <= 0x7f));
 
        uint16_t position_in_sixteenth_notes = (uint16_t(msb) << 7) | uint16_t(lsb);
index 415ae6210f01a354145326ba2bf463cd274d2080..6e193c3c099eb6aa56e1215d0fd024d9530e5356 100644 (file)
@@ -626,9 +626,9 @@ void
 MidiTrack::MidiControl::set_value(double val)
 {
        bool valid = false;
-       if (std::isinf(val)) {
+       if (isinf(val)) {
                cerr << "MIDIControl value is infinity" << endl;
-       } else if (std::isnan(val)) {
+       } else if (isnan(val)) {
                cerr << "MIDIControl value is NaN" << endl;
        } else if (val < _list->parameter().min()) {
                cerr << "MIDIControl value is < " << _list->parameter().min() << endl;
index 3a873a8e5049d9e091ef9cd43cfdc5cefdb6fe08..220cd0660c205c3a9889c8d9090dff0d9ab37222 100644 (file)
@@ -24,6 +24,8 @@
 #include "ardour/runtime_functions.h"
 #include <stdint.h>
 
+using std::min;
+using std::max;
 using namespace ARDOUR;
 
 #if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS)
@@ -93,22 +95,22 @@ default_compute_peak (const ARDOUR::Sample * buf, pframes_t nsamples, float curr
 }
 
 void
-default_find_peaks (const ARDOUR::Sample * buf, pframes_t nframes, float *min, float *max)
+default_find_peaks (const ARDOUR::Sample * buf, pframes_t nframes, float *minf, float *maxf)
 {
        pframes_t i;
        float a, b;
 
-       a = *max;
-       b = *min;
+       a = *maxf;
+       b = *minf;
 
        for (i = 0; i < nframes; i++)
        {
-               a = fmax (buf[i], a);
-               b = fmin (buf[i], b);
+               a = max (buf[i], a);
+               b = min (buf[i], b);
        }
 
-       *max = a;
-       *min = b;
+       *maxf = a;
+       *minf = b;
 }
 
 void
index db986642926cf550270b99acceb3060769f71705..c41c6d6c94a50c40310870ded6e2032f6be3edc8 100644 (file)
@@ -31,6 +31,8 @@
 #include "ardour/session.h"
 #include "ardour/audioengine.h"
 
+#include <glibmm/timer.h>
+
 #include "i18n.h"
 
 using namespace std;
@@ -233,7 +235,7 @@ MTC_Slave::read_current (SafeTime *st) const
        do {
                if (tries == 10) {
                        error << _("MTC Slave: atomic read of current time failed, sleeping!") << endmsg;
-                       usleep (20);
+                       Glib::usleep (20);
                        tries = 0;
                }
                *st = current;
@@ -297,7 +299,7 @@ MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr, framepos_t now)
  * when a full TC has been received
  * OR on locate */
 void
-MTC_Slave::update_mtc_time (const byte *msg, bool was_full, framepos_t now)
+MTC_Slave::update_mtc_time (const MIDI::byte *msg, bool was_full, framepos_t now)
 {
        busy_guard1++;
 
index 6096e356f5d69faf326977a3697a0ea54fe3ca23..c7f5e2e674e7557cc1ca7eb3ce33a38dc0ce6a3e 100644 (file)
@@ -56,7 +56,7 @@ static bool sort_ports_by_name (boost::shared_ptr<Port> a, boost::shared_ptr<Por
 
        // if some of the names don't have a number as posfix, compare as strings
 
-       if (last_digit_position_a == aname.size() or last_digit_position_b == bname.size()) {
+       if (last_digit_position_a == aname.size() || last_digit_position_b == bname.size()) {
                return aname < bname;
        }
 
index 81272679757f4374a08de7db9bf74355111bdc6d..47335876541c14213f1bec1a66c9d233493403ce 100644 (file)
@@ -77,7 +77,7 @@ int
 RCConfiguration::load_state ()
 {
        std::string rcfile;
-       struct stat statbuf;
+       GStatBuf statbuf;
 
        /* load system configuration first */
 
index f293970dd4087ba8e888ed80b5c722cc545966c8..daf7c2c78e921bf2611a507bd5ddecbbe3904dd9 100644 (file)
@@ -31,7 +31,6 @@
 
 using namespace std;
 using namespace ARDOUR;
-using namespace MIDI;
 using namespace PBD;
 using namespace Timecode;
 
index 3e2a76b8d80ef247730d4a1959d125f8a2b67c03..b211ef14e32f70ef61dfc3e40862be32f635eb72 100644 (file)
@@ -440,7 +440,7 @@ Session::send_full_time_code (framepos_t const t)
  * earlier already this cycle by send_full_time_code)
  */
 int
-Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_frame, pframes_t nframes)
+Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_frame, ARDOUR::pframes_t nframes)
 {
        if (_engine.freewheeling() || !_send_qf_mtc || transmitting_timecode_time.negative || (next_quarter_frame_to_send < 0)) {
                // cerr << "(MTC) Not sending MTC\n";
@@ -512,7 +512,7 @@ Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_f
                assert (msg_time < end_frame);
 
                /* convert from session frames back to JACK frames using the transport speed */
-               pframes_t const out_stamp = (msg_time - start_frame) / _transport_speed;
+               ARDOUR::pframes_t const out_stamp = (msg_time - start_frame) / _transport_speed;
                assert (out_stamp < nframes);
 
                if (MIDI::Manager::instance()->mtc_output_port()->midimsg (mtc_msg, 2, out_stamp)) {
index c57f2400ac561c8205d27e74a2191092264d39dd..faecdc6e6339bea1c9b17eeef93eb0dfb13c10e9 100644 (file)
@@ -70,7 +70,7 @@ user_route_template_directory ()
 }
 
 static bool
-template_filter (const string &str, void */*arg*/)
+template_filter (const string &str, void/*arg*/)
 {
        if (!Glib::file_test (str, Glib::FILE_TEST_IS_DIR)) {
                return false;
@@ -80,7 +80,7 @@ template_filter (const string &str, void */*arg*/)
 }
 
 static bool
-route_template_filter (const string &str, void */*arg*/)
+route_template_filter (const string &str, void/*arg*/)
 {
        if (str.find (template_suffix) == str.length() - strlen (template_suffix)) {
                return true;
index b80a594495d8c936125d3fff58853aeb1f77a35c..5eafe7a612664991ba3bf94639f0b4296e36fd3c 100644 (file)
@@ -528,8 +528,9 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
 {
        Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
 
-       float *ins[_plugin->numInputs];
-       float *outs[_plugin->numOutputs];
+       // VC++ doesn't support this C99 extension. Use alloca instead of dynamic array (rather than std::vector which allocs on the heap)
+       float** ins = (float**)alloca(_plugin->numInputs*sizeof(float*));
+       float** outs = (float**)alloca(_plugin->numInputs*sizeof(float*));
        int32_t i;
 
        const uint32_t nbufs = bufs.count().n_audio();
@@ -552,7 +553,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
        }
 
        /* we already know it can support processReplacing */
-       _plugin->processReplacing (_plugin, ins, outs, nframes);
+       _plugin->processReplacing (_plugin, &ins[0], &outs[0], nframes);
 
        return 0;
 }
index b13398c69d9aabab1d4839cd5178ff460242fcdd..d5238adb60e49377e95810c5b3e1451b28e688a6 100644 (file)
@@ -23,6 +23,8 @@
 #include "ardour/worker.h"
 #include "pbd/error.h"
 
+#include <glibmm/timer.h>
+
 namespace ARDOUR {
 
 Worker::Worker(Workee* workee, uint32_t ring_size)
@@ -128,7 +130,7 @@ Worker::run()
                        continue;
                }
                while (!verify_message_completeness(_requests)) {
-                       ::usleep(2000);
+                       Glib::usleep(2000);
                        if (_exit) {
                                return;
                        }
index 45137da0f3162e68fe9cb88489955eea162dac89..f6efe9cdad4e11f35dcad24a420cf844e90799da 100644 (file)
@@ -29,6 +29,7 @@ CreateHardLinkA( LPCSTR lpFileName,
 #include <algorithm>
 #include <string>
 #include <io.h>
+#include <math.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -222,6 +223,24 @@ ssize_t ret;
        return (ret);
 }
 
+//***************************************************************
+//
+//     round()
+//
+// Emulates round() using floor().
+//
+//     Returns:
+//
+//    On Success: The largest integer that is less than or
+//                equal to 'x'.
+//    On Failure: None
+//
+PBD_API double PBD_APICALLTYPE
+round(double x)
+{
+       return (floor(x));
+}
+
 namespace PBD {
 
 //***************************************************************
index 8d157731bdf4ff9fd184290d5c76040264f4cb00..736095d9e848abacf99d6f310d23b41707e528c6 100644 (file)
@@ -220,6 +220,7 @@ PBD_API int                         PBD_APICALLTYPE gettimeofday(struct timeval *__restrict tv, __tim
 PBD_API ssize_t                        PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset);
 PBD_API ssize_t                        PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset);
 PBD_API int                            PBD_APICALLTYPE poll(struct pollfd *fds, nfds_t nfds, int timeout);
+PBD_API double                 PBD_APICALLTYPE round(double x);
 
 namespace PBD {
 
index 5f0a2df2c0023a9304e39c97edfa371b6560b835..caa5eb68c29e983415a0ab43656209db87b2a9b2 100644 (file)
@@ -24,6 +24,9 @@
 #    include <mach/mach.h>
 #elif defined(PLATFORM_WINDOWS)
 #    include <windows.h>
+#ifndef INFINITE
+#define INFINITE 0xffffffffL
+#endif
 #else
 #    include <semaphore.h>
 #    include <errno.h>
index a5a82e3668cccf67764548b1d802714820017a97..2ba3bbbe62f2d0547d3b75d705bc20eee63c3cbe 100644 (file)
                return intgr ;
        }
 
+       __inline long long int 
+       llrint (double flt)
+       {       long long int intgr;
+
+               _asm
+               {       fld flt
+                       fistp intgr
+                       } ;
+                       
+               return intgr ;
+       } 
+       
+       __inline long long int 
+       llrintf (float flt)
+       {       long long int intgr;
+
+               _asm
+               {       fld flt
+                       fistp intgr
+                       } ;
+                       
+               return intgr ;
+       }
 #endif
 
 #endif  // __FLOAT_CAST_H__
index 55eb529f24b9579a47e97fe8120aebd6074db421..dfe9e053369c4d72e052e9e065beaf4ad2e5f4fc 100644 (file)
 #include <ardourext/float_cast.h>
 
 // 'std::isnan()' is not available in MSVC. Assume '_isnan(double)'
-#define isnan(val) (bool)_isnan((double)val)
+#define isnan(val)  _isnan((double)val)
 
 // 'std::isinf()' is not available in MSVC. Assume '!_finite(double)'
-#define isinf(val) !((bool)_finite((double)val))
+#define isinf(val) !_finite((double)val)
 
 // 'INFINITY' is not defined in MSVC. Assume 'HUGE_VAL'
 #ifndef INFINITY
@@ -179,7 +179,9 @@ typedef int register_t;
 // Fortunately, 'round to nearest' seems to be the default action
 // under Linux, so let's copy that until we find out otherwise.
 #define rint(value)  round(value)
-#define round(value) floor((value) + 0.5)
+#if !defined(PBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB)
+extern  double round(double x);
+#endif
 
 // System V compatibility
 typedef unsigned short ushort;
@@ -195,6 +197,15 @@ typedef _mode_t mode_t;
 #endif /* NO_OLDNAMES */
 #endif /* _MODE_T_ */
 
+// int64 abs()
+inline uint64_t abs(int64_t val)
+{
+       if (val < 0)
+               return val * (-1);
+       else
+               return val;
+}
+
 // fmin() and fmax()
 #define fmin(a, b) min((double)a, (double)b)
 #define fmax(a, b) max((double)a, (double)b)
index 2730c8cb8d920a1fa114ed25d5aee03905ddcf67..c81c8a363029218fe2e588510b1fd7d4a90f7d6f 100644 (file)
@@ -3,9 +3,11 @@
 
 #pragma warning( disable : 4996 )
 
-#ifndef HAVE_LV2
-#define HAVE_SUIL
-#define HAVE_LV2
+#ifndef LV2_SUPPORT
+#define LV2_SUPPORT   1
+#define HAVE_SUIL     1
+#define HAVE_LV2      1
+//#define HAVE_NEW_LV2  1
 /* Comment out the above lines to build Mixbus without LV2 support */
 #endif