From 490311bc081b12d328e6e02cac8170538e96fb2f Mon Sep 17 00:00:00 2001 From: John Emmas Date: Sun, 4 Aug 2013 15:36:07 +0100 Subject: [PATCH] 'libs/ardour' - Main body of changes required for building with MSVC --- libs/ardour/ardour/audioplaylist.h | 1 - libs/ardour/ardour/lv2_plugin.h | 2 ++ libs/ardour/ardour/midi_playlist.h | 1 - libs/ardour/ardour/playlist.h | 2 +- libs/ardour/audiosource.cc | 4 ++-- libs/ardour/automation_watch.cc | 2 +- libs/ardour/diskstream.cc | 2 +- libs/ardour/export_format_base.cc | 2 +- libs/ardour/globals.cc | 6 ++++- libs/ardour/graph.cc | 4 +--- libs/ardour/ltc_slave.cc | 4 ++-- libs/ardour/lv2_evbuf.c | 2 +- libs/ardour/meter.cc | 2 +- libs/ardour/midi_clock_slave.cc | 6 ++--- libs/ardour/midi_track.cc | 4 ++-- libs/ardour/mix.cc | 16 +++++++------ libs/ardour/mtc_slave.cc | 6 +++-- libs/ardour/port_set.cc | 2 +- libs/ardour/rc_configuration.cc | 2 +- libs/ardour/session_ltc.cc | 1 - libs/ardour/session_midi.cc | 4 ++-- libs/ardour/template_utils.cc | 4 ++-- libs/ardour/vst_plugin.cc | 7 +++--- libs/ardour/worker.cc | 4 +++- libs/pbd/msvc/msvc_pbd.cc | 19 +++++++++++++++ libs/pbd/pbd/msvc_pbd.h | 1 + libs/pbd/pbd/semaphore.h | 3 +++ .../ardourext/float_cast.h.input | 23 +++++++++++++++++++ msvc_extra_headers/ardourext/misc.h.input | 17 +++++++++++--- .../ardourext/sys/targetsxs.h.input | 8 ++++--- 30 files changed, 114 insertions(+), 47 deletions(-) diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h index 478d4872cd..3c987c0aa0 100644 --- a/libs/ardour/ardour/audioplaylist.h +++ b/libs/ardour/ardour/audioplaylist.h @@ -29,7 +29,6 @@ namespace ARDOUR { class Session; -class Region; class AudioRegion; class Source; diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 4cd34b3026..5154cd4d3e 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -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 diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index 543e1b353f..99d0b98321 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -32,7 +32,6 @@ namespace ARDOUR { class Session; -class Region; class MidiRegion; class Source; template class MidiRingBuffer; diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 754e48cc25..fbe747b297 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -41,13 +41,13 @@ #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; diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 65540d4e3d..f6ced35186 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -180,7 +180,7 @@ AudioSource::peaks_ready (boost::function 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); diff --git a/libs/ardour/automation_watch.cc b/libs/ardour/automation_watch.cc index 4e5f64bd32..91fe4d38ed 100644 --- a/libs/ardour/automation_watch.cc +++ b/libs/ardour/automation_watch.cc @@ -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 (); } } diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index d931cfd432..e046d5a830 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -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) { diff --git a/libs/ardour/export_format_base.cc b/libs/ardour/export_format_base.cc index ed8bb9d5f8..1eda449915 100644 --- a/libs/ardour/export_format_base.cc +++ b/libs/ardour/export_format_base.cc @@ -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); \ diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index fe07332d85..c0fca7c7a0 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -20,6 +20,10 @@ #include "libardour-config.h" #endif +#ifdef interface +#undef interface +#endif + #include // Needed so that libraptor (included in lrdf) won't complain #include #include @@ -44,7 +48,7 @@ #include "ardour/audio_unit.h" #endif -#ifdef __SSE__ +#if defined(__SSE__) || defined(USE_XMMINTRIN) #include #endif diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index 12752c158e..fe76fd74ed 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -584,12 +584,10 @@ Graph::process_one_route (Route* route) bool Graph::in_process_thread () const { -#ifndef WIN32 for (list::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 } diff --git a/libs/ardour/ltc_slave.cc b/libs/ardour/ltc_slave.cc index e9be71d98e..ac93ccdb40 100644 --- a/libs/ardour/ltc_slave.cc +++ b/libs/ardour/ltc_slave.cc @@ -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%s%s%" PRIi64 "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); } diff --git a/libs/ardour/lv2_evbuf.c b/libs/ardour/lv2_evbuf.c index 8942d19a9b..fba7fd521d 100644 --- a/libs/ardour/lv2_evbuf.c +++ b/libs/ardour/lv2_evbuf.c @@ -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; } diff --git a/libs/ardour/meter.cc b/libs/ardour/meter.cc index a7857f5859..54cad1a956 100644 --- a/libs/ardour/meter.cc +++ b/libs/ardour/meter.cc @@ -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); } } } diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc index 8906ddb6c4..75f3c13f1c 100644 --- a/libs/ardour/midi_clock_slave.cc +++ b/libs/ardour/midi_clock_slave.cc @@ -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); diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 415ae6210f..6e193c3c09 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -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; diff --git a/libs/ardour/mix.cc b/libs/ardour/mix.cc index 3a873a8e50..220cd0660c 100644 --- a/libs/ardour/mix.cc +++ b/libs/ardour/mix.cc @@ -24,6 +24,8 @@ #include "ardour/runtime_functions.h" #include +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 diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc index db98664292..c41c6d6c94 100644 --- a/libs/ardour/mtc_slave.cc +++ b/libs/ardour/mtc_slave.cc @@ -31,6 +31,8 @@ #include "ardour/session.h" #include "ardour/audioengine.h" +#include + #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++; diff --git a/libs/ardour/port_set.cc b/libs/ardour/port_set.cc index 6096e356f5..c7f5e2e674 100644 --- a/libs/ardour/port_set.cc +++ b/libs/ardour/port_set.cc @@ -56,7 +56,7 @@ static bool sort_ports_by_name (boost::shared_ptr a, boost::shared_ptrmtc_output_port()->midimsg (mtc_msg, 2, out_stamp)) { diff --git a/libs/ardour/template_utils.cc b/libs/ardour/template_utils.cc index c57f2400ac..faecdc6e63 100644 --- a/libs/ardour/template_utils.cc +++ b/libs/ardour/template_utils.cc @@ -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; diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index b80a594495..5eafe7a612 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -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; } diff --git a/libs/ardour/worker.cc b/libs/ardour/worker.cc index b13398c69d..d5238adb60 100644 --- a/libs/ardour/worker.cc +++ b/libs/ardour/worker.cc @@ -23,6 +23,8 @@ #include "ardour/worker.h" #include "pbd/error.h" +#include + 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; } diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc index 45137da0f3..f6efe9cdad 100644 --- a/libs/pbd/msvc/msvc_pbd.cc +++ b/libs/pbd/msvc/msvc_pbd.cc @@ -29,6 +29,7 @@ CreateHardLinkA( LPCSTR lpFileName, #include #include #include +#include #include #include #include @@ -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 { //*************************************************************** diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h index 8d157731bd..736095d9e8 100644 --- a/libs/pbd/pbd/msvc_pbd.h +++ b/libs/pbd/pbd/msvc_pbd.h @@ -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 { diff --git a/libs/pbd/pbd/semaphore.h b/libs/pbd/pbd/semaphore.h index 5f0a2df2c0..caa5eb68c2 100644 --- a/libs/pbd/pbd/semaphore.h +++ b/libs/pbd/pbd/semaphore.h @@ -24,6 +24,9 @@ # include #elif defined(PLATFORM_WINDOWS) # include +#ifndef INFINITE +#define INFINITE 0xffffffffL +#endif #else # include # include diff --git a/msvc_extra_headers/ardourext/float_cast.h.input b/msvc_extra_headers/ardourext/float_cast.h.input index a5a82e3668..2ba3bbbe62 100644 --- a/msvc_extra_headers/ardourext/float_cast.h.input +++ b/msvc_extra_headers/ardourext/float_cast.h.input @@ -68,6 +68,29 @@ 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__ diff --git a/msvc_extra_headers/ardourext/misc.h.input b/msvc_extra_headers/ardourext/misc.h.input index 55eb529f24..dfe9e05336 100644 --- a/msvc_extra_headers/ardourext/misc.h.input +++ b/msvc_extra_headers/ardourext/misc.h.input @@ -36,10 +36,10 @@ #include // '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) diff --git a/msvc_extra_headers/ardourext/sys/targetsxs.h.input b/msvc_extra_headers/ardourext/sys/targetsxs.h.input index 2730c8cb8d..c81c8a3630 100644 --- a/msvc_extra_headers/ardourext/sys/targetsxs.h.input +++ b/msvc_extra_headers/ardourext/sys/targetsxs.h.input @@ -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