From 23bec25bf525dfc1434fe8b95f6d81c9387ac9c5 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 11:34:37 -0400 Subject: Remove non-portable and unnused header includes --- gtk2_ardour/about.cc | 1 - libs/ardour/audio_diskstream.cc | 2 -- libs/ardour/audiosource.cc | 1 - libs/ardour/diskstream.cc | 1 - libs/ardour/midi_clock_slave.cc | 1 - libs/ardour/midi_diskstream.cc | 1 - libs/ardour/midi_source.cc | 1 - libs/ardour/mtc_slave.cc | 1 - libs/ardour/session_butler.cc | 10 ---------- libs/ardour/session_midi.cc | 2 -- libs/ardour/session_state.cc | 6 ------ libs/ardour/sndfilesource.cc | 2 -- libs/ardour/source.cc | 2 -- libs/pbd/sndfile_manager.cc | 1 - 14 files changed, 32 deletions(-) diff --git a/gtk2_ardour/about.cc b/gtk2_ardour/about.cc index 280f72a8dc..6255bfa108 100644 --- a/gtk2_ardour/about.cc +++ b/gtk2_ardour/about.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index c302e06681..7bfc9426cd 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -27,8 +27,6 @@ #include #include #include -#include -#include #include "pbd/error.h" #include "pbd/xml++.h" diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 74dd52d504..e11fe1c4fa 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index a359f228e8..6ef4327343 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -29,7 +29,6 @@ #include #include #include -#include #include diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc index 6f54d17d02..8906ddb6c4 100644 --- a/libs/ardour/midi_clock_slave.cc +++ b/libs/ardour/midi_clock_slave.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include #include "pbd/error.h" diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 9c11e818ac..a21f3fb6f4 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -28,7 +28,6 @@ #include #include // for ffs(3) #include -#include #include "pbd/error.h" #include "pbd/basename.h" diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index 124d3f7c9b..1887b74302 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc index 8ce0722d8b..14ca928905 100644 --- a/libs/ardour/mtc_slave.cc +++ b/libs/ardour/mtc_slave.cc @@ -19,7 +19,6 @@ */ #include #include -#include #include #include diff --git a/libs/ardour/session_butler.cc b/libs/ardour/session_butler.cc index 1d235b051a..3e7c2226cc 100644 --- a/libs/ardour/session_butler.cc +++ b/libs/ardour/session_butler.cc @@ -17,16 +17,6 @@ */ -#include -#include -#include -#include -#include -#include -#include - -#include - #include "pbd/error.h" #include "pbd/pthread_utils.h" #include "pbd/stacktrace.h" diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 50a7178f1b..9feaa1fb2b 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 49a0eed559..ff7da665ed 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -33,17 +33,11 @@ #include #include #include -#include -#include #include -#include #include #ifdef HAVE_SYS_VFS_H #include -#else -#include -#include #endif #ifdef HAVE_SYS_STATVFS_H diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index cf75cffba3..f29682aeaa 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -26,8 +26,6 @@ #include #include -#include -#include #include #include diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index 618dddc70b..03039fea5b 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -19,8 +19,6 @@ #include #include -#include -#include #include #include #include diff --git a/libs/pbd/sndfile_manager.cc b/libs/pbd/sndfile_manager.cc index d1dcd05256..c028bc11ba 100644 --- a/libs/pbd/sndfile_manager.cc +++ b/libs/pbd/sndfile_manager.cc @@ -22,7 +22,6 @@ */ #include -#include #include #include #include -- cgit v1.2.3 From 27eecdc88b8db2d89efcc1205dd437466d50f058 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 11:37:25 -0400 Subject: Use g_setenv and g_getenv for portability --- gtk2_ardour/main.cc | 36 ++++++++++++++++++------------------ libs/pbd/epa.cc | 8 +++++--- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 21e5343979..cd26a8cf8f 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -110,7 +110,7 @@ Please consider the possibilities, and perhaps (re)start JACK."), PROGRAM_NAME)) static void export_search_path (const string& base_dir, const char* varname, const char* dir) { string path; - const char * cstr = getenv (varname); + const char * cstr = g_getenv (varname); if (cstr) { path = cstr; @@ -121,7 +121,7 @@ static void export_search_path (const string& base_dir, const char* varname, con path += base_dir; path += dir; - setenv (varname, path.c_str(), 1); + g_setenv (varname, path.c_str(), 1); } #ifdef __APPLE__ @@ -134,7 +134,7 @@ extern void set_language_preference (); // cocoacarbon.mm void fixup_bundle_environment (int, char* []) { - if (!getenv ("ARDOUR_BUNDLED")) { + if (!g_getenv ("ARDOUR_BUNDLED")) { return; } @@ -184,12 +184,12 @@ fixup_bundle_environment (int, char* []) export_search_path (bundle_dir, "SUIL_MODULE_DIR", "/lib"); export_search_path (bundle_dir, "GTK_PATH", "/lib/gtkengines"); - setenv ("PATH", (bundle_dir + "/MacOS:" + std::string(getenv ("PATH"))).c_str(), 1); + g_setenv ("PATH", (bundle_dir + "/MacOS:" + std::string(getenv ("PATH"))).c_str(), 1); /* unset GTK_RC_FILES so that we only load the RC files that we define */ - unsetenv ("GTK_RC_FILES"); + g_unsetenv ("GTK_RC_FILES"); /* write a pango.rc file and tell pango to use it. we'd love to put this into the PROGRAM_NAME.app bundle and leave it there, @@ -214,13 +214,13 @@ fixup_bundle_environment (int, char* []) << endl; pangorc.close (); - setenv ("PANGO_RC_FILE", path.c_str(), 1); + g_setenv ("PANGO_RC_FILE", path.c_str(), 1); } } - setenv ("CHARSETALIASDIR", bundle_dir.c_str(), 1); - setenv ("FONTCONFIG_FILE", Glib::build_filename (bundle_dir, "Resources/fonts.conf").c_str(), 1); - setenv ("GDK_PIXBUF_MODULE_FILE", Glib::build_filename (bundle_dir, "Resources/gdk-pixbuf.loaders").c_str(), 1); + g_setenv ("CHARSETALIASDIR", bundle_dir.c_str(), 1); + g_setenv ("FONTCONFIG_FILE", Glib::build_filename (bundle_dir, "Resources/fonts.conf").c_str(), 1); + g_setenv ("GDK_PIXBUF_MODULE_FILE", Glib::build_filename (bundle_dir, "Resources/gdk-pixbuf.loaders").c_str(), 1); } static void load_custom_fonts() { @@ -258,7 +258,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) * acceptable to build paths directly using '/'. */ - if (!getenv ("ARDOUR_BUNDLED")) { + if (!g_getenv ("ARDOUR_BUNDLED")) { return; } @@ -294,20 +294,20 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) export_search_path (dir_path, "SUIL_MODULE_DIR", "/lib"); export_search_path (dir_path, "GTK_PATH", "/lib/gtkengines"); - setenv ("PATH", (dir_path + "/bin:" + std::string(getenv ("PATH"))).c_str(), 1); + g_setenv ("PATH", (dir_path + "/bin:" + std::string(getenv ("PATH"))).c_str(), 1); /* unset GTK_RC_FILES so that we only load the RC files that we define */ - unsetenv ("GTK_RC_FILES"); + g_unsetenv ("GTK_RC_FILES"); /* Tell fontconfig where to find fonts.conf. Use the system version if it exists, otherwise use the stuff we included in the bundle */ if (Glib::file_test ("/etc/fonts/fonts.conf", Glib::FILE_TEST_EXISTS)) { - setenv ("FONTCONFIG_FILE", "/etc/fonts/fonts.conf", 1); - setenv ("FONTCONFIG_PATH", "/etc/fonts", 1); + g_setenv ("FONTCONFIG_FILE", "/etc/fonts/fonts.conf", 1); + g_setenv ("FONTCONFIG_PATH", "/etc/fonts", 1); } else { error << _("No fontconfig file found on your system. Things may looked very odd or ugly") << endmsg; } @@ -336,19 +336,19 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) pangorc.close (); } - setenv ("PANGO_RC_FILE", path.c_str(), 1); + g_setenv ("PANGO_RC_FILE", path.c_str(), 1); /* similar for GDK pixbuf loaders, but there's no RC file required to specify where it lives. */ - setenv ("GDK_PIXBUF_MODULE_FILE", Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders").c_str(), 1); + g_setenv ("GDK_PIXBUF_MODULE_FILE", Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders").c_str(), 1); } /* this doesn't do much but setting it should prevent various parts of the GTK/GNU stack from looking outside the bundle to find the charset.alias file. */ - setenv ("CHARSETALIASDIR", dir_path.c_str(), 1); + g_setenv ("CHARSETALIASDIR", dir_path.c_str(), 1); } @@ -473,7 +473,7 @@ int main (int argc, char *argv[]) text_receiver.listen_to (warning); #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS - if (getenv ("BOOST_DEBUG")) { + if (g_getenv ("BOOST_DEBUG")) { boost_debug_shared_ptr_show_live_debugging (true); } #endif diff --git a/libs/pbd/epa.cc b/libs/pbd/epa.cc index 8b8a23491b..d8a3cd5a65 100644 --- a/libs/pbd/epa.cc +++ b/libs/pbd/epa.cc @@ -17,6 +17,8 @@ */ +#include + #include #include "pbd/epa.h" @@ -61,7 +63,7 @@ EnvironmentalProtectionAgency::save () /* fetch environment from named environment variable, rather than "environ" */ - const char* estr = getenv (_envname.c_str()); + const char* estr = g_getenv (_envname.c_str()); if (!estr) { return; @@ -117,7 +119,7 @@ EnvironmentalProtectionAgency::restore () const clear (); for (map::const_iterator i = e.begin(); i != e.end(); ++i) { - setenv (i->first.c_str(), i->second.c_str(), 1); + g_setenv (i->first.c_str(), i->second.c_str(), 1); } } @@ -137,6 +139,6 @@ EnvironmentalProtectionAgency::clear () const } string before = estring.substr (0, equal); - unsetenv(before.c_str()); + g_unsetenv(before.c_str()); } } -- cgit v1.2.3 From f47499f1579c47a15ebcdbcdc5f830748b05cc3c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 11:38:46 -0400 Subject: Use g_random_int instead of ::random for portability --- gtk2_ardour/ui_config.cc | 2 +- gtk2_ardour/utils.cc | 6 +++--- libs/ardour/broadcast_info.cc | 2 +- libs/ardour/test/midi_clock_slave_test.cc | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index 86f03bbd95..573e509ab9 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -278,7 +278,7 @@ UIConfiguration::color_by_name (const std::string& name) } // cerr << string_compose (_("Color %1 not found"), name) << endl; - return RGBA_TO_UINT (random()%256,random()%256,random()%256,0xff); + return RGBA_TO_UINT (g_random_int()%256,g_random_int()%256,g_random_int()%256,0xff); } void diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index d4bc460269..eb3f4ab55d 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -781,9 +781,9 @@ unique_random_color (list& used_colors) const int32_t max_saturation = 48000; // 65535 would open up the whole color wheel - newcolor.set_red (random() % max_saturation); - newcolor.set_blue (random() % max_saturation); - newcolor.set_green (random() % max_saturation); + newcolor.set_red (g_random_int() % max_saturation); + newcolor.set_blue (g_random_int() % max_saturation); + newcolor.set_green (g_random_int() % max_saturation); if (used_colors.size() == 0) { used_colors.push_back (newcolor); diff --git a/libs/ardour/broadcast_info.cc b/libs/ardour/broadcast_info.cc index a7fa41aaf9..78c6132f85 100644 --- a/libs/ardour/broadcast_info.cc +++ b/libs/ardour/broadcast_info.cc @@ -84,7 +84,7 @@ BroadcastInfo::set_originator_ref_from_session (Session const & /*session*/) /* random code is 9 digits */ - int random_code = random() % 999999999; + int random_code = g_random_int() % 999999999; /* Serial number is 12 chars */ diff --git a/libs/ardour/test/midi_clock_slave_test.cc b/libs/ardour/test/midi_clock_slave_test.cc index dcb159cb2c..4349df22eb 100644 --- a/libs/ardour/test/midi_clock_slave_test.cc +++ b/libs/ardour/test/midi_clock_slave_test.cc @@ -27,7 +27,7 @@ MIDIClock_SlaveTest::testStepResponse () for (framecnt_t i = 1; i<= 100 * period_size; i++) { // simulate jitter - framecnt_t input_delta = framecnt_t (one_ppqn_in_frames + 0.1 * (double(random()) / double (RAND_MAX)) * one_ppqn_in_frames); + framecnt_t input_delta = framecnt_t (one_ppqn_in_frames + 0.1 * (double(g_random_int()) / double (RAND_MAX)) * one_ppqn_in_frames); if (i % input_delta == 0) { update_midi_clock (*parser, start_time + i); -- cgit v1.2.3 From 117118e5f07da862a8a7901c60e880507c3be2d4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 11:40:59 -0400 Subject: Use pthread_equals in libpbd for portability --- libs/pbd/pthread_utils.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index e8b5e2690d..6bc02e0883 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -127,7 +127,7 @@ pthread_kill_all (int signum) { pthread_mutex_lock (&thread_map_lock); for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) { - if ((*i) != pthread_self()) { + if (!pthread_equal ((*i), pthread_self())) { pthread_kill ((*i), signum); } } @@ -140,7 +140,7 @@ pthread_cancel_all () { pthread_mutex_lock (&thread_map_lock); for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) { - if ((*i) != pthread_self()) { + if (!pthread_equal ((*i), pthread_self())) { pthread_cancel ((*i)); } } @@ -153,7 +153,7 @@ pthread_cancel_one (pthread_t thread) { pthread_mutex_lock (&thread_map_lock); for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) { - if ((*i) == thread) { + if (pthread_equal ((*i), thread)) { all_threads.erase (i); break; } @@ -170,7 +170,7 @@ pthread_exit_pbd (void* status) pthread_mutex_lock (&thread_map_lock); for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) { - if ((*i) == thread) { + if (pthread_equal ((*i), thread)) { all_threads.erase (i); break; } -- cgit v1.2.3 From 227cf470babb4d5be068f0e4e8aa7bc06125fc1a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 11:43:43 -0400 Subject: Use a std::list instead of std::set for the ThreadMap in libpbd pthread_t can't work with std::set using the pthread lib on windows as there is no operator< defined for the type --- libs/pbd/pthread_utils.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index 6bc02e0883..96cf99716f 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -30,7 +30,7 @@ using namespace std; -typedef std::set ThreadMap; +typedef std::list ThreadMap; static ThreadMap all_threads; static pthread_mutex_t thread_map_lock = PTHREAD_MUTEX_INITIALIZER; static Glib::Threads::Private thread_name (free); @@ -94,7 +94,7 @@ pthread_create_and_store (string name, pthread_t *thread, void * (*start_routin if ((ret = thread_creator (thread, &default_attr, fake_thread_start, ts)) == 0) { pthread_mutex_lock (&thread_map_lock); - all_threads.insert (*thread); + all_threads.push_back (*thread); pthread_mutex_unlock (&thread_map_lock); } -- cgit v1.2.3 From 157e21369e691bfb089e2a8c095ebbd50cd0da8e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 11:50:25 -0400 Subject: Use default constructor for pthread_t in InterthreadInfo ctor --- libs/ardour/ardour/interthread_info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/ardour/interthread_info.h b/libs/ardour/ardour/interthread_info.h index 01cacf437c..a06fc649ca 100644 --- a/libs/ardour/ardour/interthread_info.h +++ b/libs/ardour/ardour/interthread_info.h @@ -29,7 +29,7 @@ namespace ARDOUR { class InterThreadInfo { public: - InterThreadInfo () : done (false), cancel (false), progress (0), thread (0) {} + InterThreadInfo () : done (false), cancel (false), progress (0), thread () {} volatile bool done; volatile bool cancel; -- cgit v1.2.3 From 2048f766e9969277bb4747cafeefecca1e406b3e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 11:51:59 -0400 Subject: Use pthread_equal in libmidi++ for portability --- libs/midi++2/jack_midi_port.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/midi++2/jack_midi_port.cc b/libs/midi++2/jack_midi_port.cc index 05df3171fa..e1a68b6475 100644 --- a/libs/midi++2/jack_midi_port.cc +++ b/libs/midi++2/jack_midi_port.cc @@ -458,7 +458,7 @@ JackMIDIPort::set_process_thread (pthread_t thr) bool JackMIDIPort::is_process_thread() { - return (pthread_self() == _process_thread); + return (pthread_equal(pthread_self(), _process_thread)); } void -- cgit v1.2.3 From 1fad4714e37734017bd6e7633af2ff06bee2dc48 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 11:53:24 -0400 Subject: Use PBD::pthread_name in debug output for portability --- libs/pbd/pool.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc index 7b24625727..cdcd9abdd7 100644 --- a/libs/pbd/pool.cc +++ b/libs/pbd/pool.cc @@ -24,6 +24,7 @@ #include #include "pbd/pool.h" +#include "pbd/pthread_utils.h" #include "pbd/error.h" #include "pbd/debug.h" #include "pbd/compose.h" @@ -182,7 +183,7 @@ PerThreadPool::per_thread_pool () { CrossThreadPool* p = _key.get(); if (!p) { - fatal << "programming error: no per-thread pool \"" << _name << "\" for thread " << pthread_self() << endmsg; + fatal << "programming error: no per-thread pool \"" << _name << "\" for thread " << pthread_name() << endmsg; /*NOTREACHED*/ } return p; @@ -226,9 +227,9 @@ CrossThreadPool::alloc () { void* ptr; - DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 has %3 pending free entries waiting\n", pthread_self(), name(), pending.read_space())); + DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 has %3 pending free entries waiting\n", pthread_name(), name(), pending.read_space())); while (pending.read (&ptr, 1) == 1) { - DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 pushes back a pending free list entry before allocating\n", pthread_self(), name())); + DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 pushes back a pending free list entry before allocating\n", pthread_name(), name())); free_list.write (&ptr, 1); } return Pool::alloc (); -- cgit v1.2.3 From b9fa882c565e340e0e6f110274e0ac8809f3556d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:01:17 -0400 Subject: Use PBD::pthread_name in debug output instead of pthread_self --- libs/pbd/base_ui.cc | 2 +- libs/pbd/pbd/abstract_ui.cc | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index a7e148c839..69b156589f 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -73,7 +73,7 @@ BaseUI::new_request_type () void BaseUI::main_thread () { - DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", name(), pthread_self())); + DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", name(), pthread_name())); set_event_loop_for_thread (this); thread_init (); _main_loop->get_context()->signal_idle().connect (sigc::mem_fun (*this, &BaseUI::signal_running)); diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc index d43bc64f63..64fd718dbc 100644 --- a/libs/pbd/pbd/abstract_ui.cc +++ b/libs/pbd/pbd/abstract_ui.cc @@ -146,7 +146,7 @@ AbstractUI::get_request (RequestType rt) return 0; } - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1: allocated per-thread request of type %2, caller %3\n", name(), rt, pthread_self())); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1: allocated per-thread request of type %2, caller %3\n", name(), rt, pthread_name())); vec.buf[0]->type = rt; vec.buf[0]->valid = true; @@ -158,7 +158,7 @@ AbstractUI::get_request (RequestType rt) * are not at work. */ - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1: allocated normal heap request of type %2, caller %3\n", name(), rt, pthread_self())); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1: allocated normal heap request of type %2, caller %3\n", name(), rt, pthread_name())); RequestObject* req = new RequestObject; req->type = rt; @@ -213,7 +213,7 @@ AbstractUI::handle_ui_requests () for (i = request_buffers.begin(); i != request_buffers.end(); ) { if ((*i).second->dead) { DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 deleting dead per-thread request buffer for %3 @ %4\n", - name(), pthread_self(), i->first, i->second)); + name(), pthread_name(), i->second)); delete (*i).second; RequestBufferMapIterator tmp = i; ++tmp; @@ -241,7 +241,7 @@ AbstractUI::handle_ui_requests () request_buffer_map_lock.lock (); if (!req->valid) { - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 handling invalid heap request, type %3, deleting\n", name(), pthread_self(), req->type)); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 handling invalid heap request, type %3, deleting\n", name(), pthread_name(), req->type)); delete req; request_buffer_map_lock.unlock (); continue; @@ -253,7 +253,7 @@ AbstractUI::handle_ui_requests () */ if (req->invalidation) { - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 remove request from its invalidation list\n", name(), pthread_self())); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 remove request from its invalidation list\n", name(), pthread_name())); /* after this call, if the object referenced by the * invalidation record is deleted, it will no longer @@ -281,7 +281,7 @@ AbstractUI::handle_ui_requests () lm.release (); - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 execute request type %3\n", name(), pthread_self(), req->type)); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 execute request type %3\n", name(), pthread_name(), req->type)); /* and lets do it ... this is a virtual call so that each * specific type of UI can have its own set of requests without @@ -290,7 +290,7 @@ AbstractUI::handle_ui_requests () do_request (req); - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 delete heap request type %3\n", name(), pthread_self(), req->type)); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 delete heap request type %3\n", name(), pthread_name(), req->type)); delete req; /* re-acquire the list lock so that we check again */ @@ -315,7 +315,7 @@ AbstractUI::send_request (RequestObject *req) /* the thread that runs this UI's event loop is sending itself a request: we dispatch it immediately and inline. */ - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 direct dispatch of request type %3\n", name(), pthread_self(), req->type)); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 direct dispatch of request type %3\n", name(), pthread_name(), req->type)); do_request (req); } else { @@ -334,13 +334,13 @@ AbstractUI::send_request (RequestObject *req) RequestBuffer* rbuf = per_thread_request_buffer.get (); if (rbuf != 0) { - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 send per-thread request type %3\n", name(), pthread_self(), req->type)); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 send per-thread request type %3\n", name(), pthread_name(), req->type)); rbuf->increment_write_ptr (1); } else { /* no per-thread buffer, so just use a list with a lock so that it remains single-reader/single-writer semantics */ - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 send heap request type %3\n", name(), pthread_self(), req->type)); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 send heap request type %3\n", name(), pthread_name(), req->type)); Glib::Threads::Mutex::Lock lm (request_list_lock); request_list.push_back (req); } @@ -357,7 +357,7 @@ template void AbstractUI::call_slot (InvalidationRecord* invalidation, const boost::function& f) { if (caller_is_self()) { - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 direct dispatch of call slot via functor @ %3, invalidation %4\n", name(), pthread_self(), &f, invalidation)); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 direct dispatch of call slot via functor @ %3, invalidation %4\n", name(), pthread_name(), &f, invalidation)); f (); return; } @@ -368,7 +368,7 @@ AbstractUI::call_slot (InvalidationRecord* invalidation, const bo return; } - DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 queue call-slot using functor @ %3, invalidation %4\n", name(), pthread_self(), &f, invalidation)); + DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 queue call-slot using functor @ %3, invalidation %4\n", name(), pthread_name(), &f, invalidation)); /* copy semantics: copy the functor into the request object */ -- cgit v1.2.3 From 5162181767046a58e8c97194a8bb596871369166 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:05:37 -0400 Subject: Fix some usage of non-standard types for portability --- gtk2_ardour/session_metadata_dialog.h | 2 +- libs/ardour/import.cc | 32 ++++++++++++++-------------- libs/ardour/sndfileimportable.cc | 2 +- libs/audiographer/private/gdither/gdither.cc | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gtk2_ardour/session_metadata_dialog.h b/gtk2_ardour/session_metadata_dialog.h index 9aa62ed4ca..bd1e042bb7 100644 --- a/gtk2_ardour/session_metadata_dialog.h +++ b/gtk2_ardour/session_metadata_dialog.h @@ -82,7 +82,7 @@ class TextMetadataField : public MetadataField { Gtk::Label* value_label; Gtk::Entry* entry; - uint width; + guint width; }; /// MetadataField that accepts only numbers diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 047b46f553..48937fb576 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -117,7 +117,7 @@ open_importable_source (const string& path, framecnt_t samplerate, ARDOUR::SrcQu } static std::string -get_non_existent_filename (HeaderFormat hf, DataType type, const bool allow_replacing, const std::string& destdir, const std::string& basename, uint channel, uint channels) +get_non_existent_filename (HeaderFormat hf, DataType type, const bool allow_replacing, const std::string& destdir, const std::string& basename, uint32_t channel, uint32_t channels) { char buf[PATH_MAX+1]; bool goodfile = false; @@ -172,14 +172,14 @@ get_non_existent_filename (HeaderFormat hf, DataType type, const bool allow_repl } static vector -get_paths_for_new_sources (HeaderFormat hf, const bool allow_replacing, const string& import_file_path, const string& session_dir, uint channels) +get_paths_for_new_sources (HeaderFormat hf, const bool allow_replacing, const string& import_file_path, const string& session_dir, uint32_t channels) { vector new_paths; const string basename = basename_nosuffix (import_file_path); SessionDirectory sdir(session_dir); - for (uint n = 0; n < channels; ++n) { + for (uint32_t n = 0; n < channels; ++n) { const DataType type = SMFSource::safe_midi_file_extension (import_file_path) ? DataType::MIDI : DataType::AUDIO; @@ -196,7 +196,7 @@ get_paths_for_new_sources (HeaderFormat hf, const bool allow_replacing, const st static bool map_existing_mono_sources (const vector& new_paths, Session& /*sess*/, - uint /*samplerate*/, vector >& newfiles, Session *session) + uint32_t /*samplerate*/, vector >& newfiles, Session *session) { for (vector::const_iterator i = new_paths.begin(); i != new_paths.end(); ++i) @@ -215,7 +215,7 @@ map_existing_mono_sources (const vector& new_paths, Session& /*sess*/, static bool create_mono_sources_for_writing (const vector& new_paths, - Session& sess, uint samplerate, + Session& sess, uint32_t samplerate, vector >& newfiles, framepos_t timeline_position) { @@ -253,10 +253,10 @@ create_mono_sources_for_writing (const vector& new_paths, static string compose_status_message (const string& path, - uint file_samplerate, - uint session_samplerate, - uint /* current_file */, - uint /* total_files */) + uint32_t file_samplerate, + uint32_t session_samplerate, + uint32_t /* current_file */, + uint32_t /* total_files */) { if (file_samplerate != session_samplerate) { return string_compose (_("Resampling %1 from %2kHz to %3kHz"), @@ -274,12 +274,12 @@ write_audio_data_to_new_files (ImportableSource* source, ImportStatus& status, { const framecnt_t nframes = ResampledImportableSource::blocksize; boost::shared_ptr afs; - uint channels = source->channels(); + uint32_t channels = source->channels(); boost::scoped_array data(new float[nframes * channels]); vector > channel_data; - for (uint n = 0; n < channels; ++n) { + for (uint32_t n = 0; n < channels; ++n) { channel_data.push_back(boost::shared_array(new Sample[nframes])); } @@ -300,7 +300,7 @@ write_audio_data_to_new_files (ImportableSource* source, ImportStatus& status, */ float peak = 0; - uint read_count = 0; + uint32_t read_count = 0; while (!status.cancel) { framecnt_t const nread = source->read (data.get(), nframes); @@ -324,13 +324,13 @@ write_audio_data_to_new_files (ImportableSource* source, ImportStatus& status, progress_base = 0.5; } - uint read_count = 0; + uint32_t read_count = 0; while (!status.cancel) { framecnt_t nread, nfread; - uint x; - uint chn; + uint32_t x; + uint32_t chn; if ((nread = source->read (data.get(), nframes)) == 0) { break; @@ -479,7 +479,7 @@ Session::import_files (ImportStatus& status) Sources all_new_sources; boost::shared_ptr afs; boost::shared_ptr smfs; - uint channels = 0; + uint32_t channels = 0; status.sources.clear (); diff --git a/libs/ardour/sndfileimportable.cc b/libs/ardour/sndfileimportable.cc index c9f6c4014f..ceb88eddc9 100644 --- a/libs/ardour/sndfileimportable.cc +++ b/libs/ardour/sndfileimportable.cc @@ -51,7 +51,7 @@ SndFileImportableSource::read (Sample* buffer, framecnt_t nframes) return per_channel * sf_info.channels; } -uint +uint32_t SndFileImportableSource::channels () const { return sf_info.channels; diff --git a/libs/audiographer/private/gdither/gdither.cc b/libs/audiographer/private/gdither/gdither.cc index fe9ecc655a..d2a237eb74 100644 --- a/libs/audiographer/private/gdither/gdither.cc +++ b/libs/audiographer/private/gdither/gdither.cc @@ -226,7 +226,7 @@ inline static void gdither_innner_loop(const GDitherType dt, switch (bit_depth) { case GDither8bit: - o8[i] = (u_int8_t) (clamped * post_scale); + o8[i] = (uint8_t) (clamped * post_scale); break; case GDither16bit: o16[i] = (int16_t) (clamped * post_scale); -- cgit v1.2.3 From 62cfd6a75222e8835b5e204a6be4325e7143d895 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:23:05 -0400 Subject: Only call configure in surface subdirectories if the required deps are available I think these checks should probably be in the surface build files so they are self contained... --- libs/surfaces/wscript | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libs/surfaces/wscript b/libs/surfaces/wscript index 3a4b562629..e0e91af725 100644 --- a/libs/surfaces/wscript +++ b/libs/surfaces/wscript @@ -23,10 +23,6 @@ children = [ 'control_protocol', 'frontier', 'generic_midi', - 'mackie', - 'osc', - 'tranzport', - 'wiimote' ] def options(opt): @@ -47,14 +43,19 @@ def configure(conf): #if Options.options.tranzport and conf.is_defined('HAVE_USB'): # conf.define('BUILD_TRANZPORT', 1) - autowaf.check_pkg (conf, 'liblo', mandatory=False, uselib_store="LO", atleast_version="0.24") - + if conf.check_cc (header_name='poll.h', define_name='BUILD_MACKIE'): + sub_config_and_use(conf, 'mackie') + + if autowaf.check_pkg (conf, 'liblo', mandatory=False, uselib_store="LO", atleast_version="0.24"): + sub_config_and_use(conf, 'osc') + conf.check_cc (header_name='cwiid.h', define_name='HAVE_CWIID_H',mandatory=False) if conf.is_defined('HAVE_CWIID_H'): conf.check_cc (header_name='bluetooth/bluetooth.h', define_name='HAVE_BLUETOOTH_H',mandatory=False) if conf.is_defined('HAVE_BLUETOOTH_H'): autowaf.check_pkg(conf, 'cwiid', uselib_store='CWIID', atleast_version='0.6.00') conf.define ('BUILD_WIIMOTE', 1) + sub_config_and_use(conf, 'wiimote') else: print('You are missing the libbluetooth headers needed to compile wiimote support') else: @@ -62,8 +63,8 @@ def configure(conf): def build(bld): bld.recurse('control_protocol') - bld.recurse('generic_midi') - bld.recurse('mackie') + if bld.is_defined ('BUILD_MACKIE'): + bld.recurse('mackie') if bld.is_defined ('HAVE_LO'): bld.recurse('osc') if bld.is_defined('BUILD_WIIMOTE'): -- cgit v1.2.3 From 3b8f2e82f27215d5c24e964b88ff7784164dc2ca Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:23:50 -0400 Subject: Add Windows building/packaging scripts --- tools/windows_packaging/Fedora-16-mingw.txt | 41 ++++++ tools/windows_packaging/README | 112 ++++++++++++++++ tools/windows_packaging/ardour.nsi | 123 ++++++++++++++++++ tools/windows_packaging/configure-debug.sh | 8 ++ tools/windows_packaging/configure-release.sh | 8 ++ tools/windows_packaging/cptovm.sh | 62 +++++++++ tools/windows_packaging/gdbinit | 2 + tools/windows_packaging/loaders.cache | 144 +++++++++++++++++++++ tools/windows_packaging/make-installer.sh | 15 +++ tools/windows_packaging/mingw-env.sh | 51 ++++++++ tools/windows_packaging/package.sh | 186 +++++++++++++++++++++++++++ tools/windows_packaging/pango.modules | 35 +++++ tools/windows_packaging/print-env.sh | 40 ++++++ tools/windows_packaging/run-wine.sh | 39 ++++++ tools/windows_packaging/startvm.sh | 3 + tools/windows_packaging/waf.sh | 6 + 16 files changed, 875 insertions(+) create mode 100644 tools/windows_packaging/Fedora-16-mingw.txt create mode 100644 tools/windows_packaging/README create mode 100644 tools/windows_packaging/ardour.nsi create mode 100644 tools/windows_packaging/configure-debug.sh create mode 100644 tools/windows_packaging/configure-release.sh create mode 100644 tools/windows_packaging/cptovm.sh create mode 100644 tools/windows_packaging/gdbinit create mode 100644 tools/windows_packaging/loaders.cache create mode 100644 tools/windows_packaging/make-installer.sh create mode 100644 tools/windows_packaging/mingw-env.sh create mode 100644 tools/windows_packaging/package.sh create mode 100644 tools/windows_packaging/pango.modules create mode 100644 tools/windows_packaging/print-env.sh create mode 100644 tools/windows_packaging/run-wine.sh create mode 100644 tools/windows_packaging/startvm.sh create mode 100644 tools/windows_packaging/waf.sh diff --git a/tools/windows_packaging/Fedora-16-mingw.txt b/tools/windows_packaging/Fedora-16-mingw.txt new file mode 100644 index 0000000000..23c9a749ce --- /dev/null +++ b/tools/windows_packaging/Fedora-16-mingw.txt @@ -0,0 +1,41 @@ + +Fedora Packages are installed via $ yum install foobar + +wine, needed to run some tests during the configure process + +mingw32-gcc + +mingw32-libogg + +mingw32-flac not in repo <- requires libogg + +mingw32-libvorbis + +mingw32-libsndfile not in repo <- requires flac, vorbis +mingw32-libsamplerate not in repo <- requires sndfile for examples? + +mingw32-gtkmm24, this will pull in all the gtk+ deps etc + +mingw32-gtk2-engines not in repo <- provides clearlooks + +mingw32-libglade2, required for gnomecanvas + +mingw32-libart_lgpl not in repo +mingw32-libgnomecanvas not in repo <- requires libart, libglade2 +mingw32-libgnomecanvasmm not in repo <- requires + +mingw32-portaudio not in repo + +mingw32-jack-audio-connection-kit not in repo + +mingw32-fftw not in repo + +mingw32-curl + +Optional + +mingw32-cppunit, if tests enabled +mingw32-gdb, for debugging + +qemu-kvm to run virt images + diff --git a/tools/windows_packaging/README b/tools/windows_packaging/README new file mode 100644 index 0000000000..cb01c5675f --- /dev/null +++ b/tools/windows_packaging/README @@ -0,0 +1,112 @@ +Building Ardour for Windows + +The windows build is compiled and tested with the MinGW compiler that is +packaged in Fedora, Currently using Fedora 16. There are many cross compiled +"mingw" libraries that Ardour requires that are also available on Fedora but +not all are yet. + + +Prerequisites + +Follow instructions in Fedora-16.txt to build and/or install the required +packages. + + +Configuring + +After all the necessary packages are installed the next step is to call +one of the configure scripts configure-debug.sh or configure-release.sh. + +The configure-debug.sh script will enable debugging support and install +the tests to the package directory. It will also mean the GDB debugger +is packaged. + +The configure-release.sh is intended for releases only, none of the tests +will be built and all the binaries will be optimized and stripped. + +These scripts both source the mingw-env.sh script to setup the appropriate +environment variables and then call waf with a specific set of parameters +that are appropriate to configure for the windows build. + + +Building + +After the build is configured the waf.sh script is used to build the Ardour +application and all necessary libraries. The waf.sh script is not strictly +needed, it just saves having to change working directories. + + +Packaging + +When the build is successful the package.sh script will call waf install +and then move some of the installed files to appropriate locations for a +windows executable. This could probably be done in the waf scripts specifically +for the windows build but I felt it simpler to do it in the packaging script +for now. + +The packaging script then copies the JACK deamon and all the required mingw +shared libraries from the host system into the packaging directory. The +shared libraries or dll's are placed in the same directory as the Ardour +executable so they are found at runtime. + +Once the package.sh script has been run then the package directory located +in the Ardour source root directory will contain everything necessary to run +the Ardour executable. + +The make-installer.sh script is only really relevant when configure-release.sh +has been used to configure the build. The script creates a basic and little +tested windows installer for Ardour using the Nullsoft Scriptable Installer +System(NSIS). + + +Running + +The Ardour windows binary is intended to be run and tested on windows. Testing +is mainly performed using Windows XP, but should work on Vista/7. It is only +a 32bit binary at the moment but that may change with mingw64. + +The binary does not run successfully under WINE but that may change with updates +and or bug fixes. + +When running Ardour for debugging purposes it is best to start the jack server +in a separate terminal(Command Prompt) before starting Ardour so that they are +not both writing to the same terminal. This will probably be fixed at some point +so when jackd is started by Ardour the output is redirected etc. + +The cptovm.sh and startvm.sh scripts are intended for testing Ardour in a +Windows XP virt image and may need to be altered to be used successfully. + + +Testing + +When configured for debugging there are a number of test programs(prefixed with +test_) included in the package. + + +Debugging + +Ardour has some verbose logging/debugging output that can be useful that is used +with the -D option. + +When configured for debugging the package contains gdb along with a .gdbinit +file to automatically set the source directory so that the "list" gdb command +will show the source code corresponding to the current stack frame. + +Use break `Somenamespace::somepartialsymbolname + tab to list symbols, then remove +` to set break. If you press tab with when there are thousands of possible +matching symbols be prepared to wait a long time(this can also cause gdb to use a +lot of memory). + +For reasons I've yet to determine many symbols are not accessible so the best way +to set a breakpoint is by using filename and line number. + +e.g (gdb) break audiosource.cc:976 + +but this seems to only work after running Ardour at least once. + +They are a number of glib debugging options see + +http://developer.gnome.org/glib/2.30/glib-running.html + +use $ set G_DEBUG=fatal_warnings to get backtrace + diff --git a/tools/windows_packaging/ardour.nsi b/tools/windows_packaging/ardour.nsi new file mode 100644 index 0000000000..3bfcc050b3 --- /dev/null +++ b/tools/windows_packaging/ardour.nsi @@ -0,0 +1,123 @@ +#!Nsis Installer Command Script +# +# This is an NSIS Installer Command Script generated automatically +# by the Fedora nsiswrapper program. For more information see: +# +# http://fedoraproject.org/wiki/MinGW +# +# To build an installer from the script you would normally do: +# +# makensis this_script +# +# which will generate the output file 'installer.exe' which is a Windows +# installer containing your program. + +SetCompressor /SOLID lzma +SetCompressorDictSize 32 + +!include MUI.nsh + +!define MUI_ABORTWARNING +!define MUI_ICON ..\icons\icon\ardour.ico +!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" +;!define MUI_HEADERIMAGE +;!define MUI_HEADERIMAGE_BITMAP header.bmp +;!define MUI_WELCOMEFINISHPAGE_BITMAP welcomefinish.bmp +;!define MUI_COMPONENTSPAGE_SMALLDESC + +; Installer pages +!insertmacro MUI_PAGE_WELCOME + +LicenseForceSelection off + +!define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)" +!define MUI_LICENSEPAGE_TEXT_BOTTOM "$(LICENSE_BOTTOM_TEXT)" +!insertmacro MUI_PAGE_LICENSE ..\COPYING + +!insertmacro MUI_PAGE_DIRECTORY + +!insertmacro MUI_PAGE_INSTFILES + +!define MUI_FINISHPAGE_RUN "$INSTDIR\Ardour-3.0.exe" +!insertmacro MUI_PAGE_FINISH + +; Uninstaller pages +!insertmacro MUI_UNPAGE_CONFIRM + +!insertmacro MUI_UNPAGE_INSTFILES +ShowUninstDetails hide +!insertmacro MUI_UNPAGE_FINISH + +!insertmacro MUI_LANGUAGE "English" + +; Product definitions +;!define DUMMYINSTALL ; Define this to make it build quickly, not including any of the files or code in the sections, for quick testing of features of the installer and development thereof. +!define INSTDIR_KEY "SOFTWARE\Ardour-3.0" + +; Product Information +Name "Ardour-3.0" +OutFile "Ardour-3.0-Setup.exe" +InstallDir "$PROGRAMFILES\Ardour" +InstallDirRegKey HKLM "${INSTDIR_KEY}" "Install_Dir" + + +ComponentText "Select which optional components you want to install." + +DirText "Please select the installation folder." + +Section "Ardour-3.0" +!ifndef DUMMYINSTALL + SectionIn RO + + SetOutPath $INSTDIR + File ardour-3.0.exe + File *.dll + File jack*.exe + File ardour.ico + File /r etc + File /r jack + File /r lib + File /r share + +!endif +SectionEnd + +Section "Start Menu Shortcuts" +!ifndef DUMMY_INSTALL + CreateDirectory "$SMPROGRAMS\Ardour-3.0" + CreateShortCut "$SMPROGRAMS\Ardour-3.0\Uninstall Ardour-3.0.lnk" "$INSTDIR\Uninstall Ardour-3.0.exe" "" "$INSTDIR\Uninstall Ardour-3.0.exe" 0 + CreateShortCut "$SMPROGRAMS\Ardour-3.0\ardour-3.0.exe.lnk" "$INSTDIR\.\ardour-3.0.exe" "" "$INSTDIR\ardour.ico" 0 +!endif +SectionEnd + +Section "Desktop Icons" +!ifndef DUMMY_INSTALL + CreateShortCut "$DESKTOP\Ardour-3.0.exe.lnk" "$INSTDIR\ardour-3.0.exe" "" "$INSTDIR\ardour.ico" +!endif +SectionEnd + +Section "Uninstall" +!ifndef DUMMY_INSTALL + Delete /rebootok "$DESKTOP\ardour-3.0.exe.lnk" + Delete /rebootok "$SMPROGRAMS\Ardour-3.0\ardour-3.0.exe.lnk" + Delete /rebootok "$SMPROGRAMS\Ardour-3.0\Uninstall Ardour-3.0.lnk" + RMDir "$SMPROGRAMS\Ardour-3.0" + + ;RMDir "$INSTDIR\." + Delete /rebootok "$INSTDIR\ardour-3.0.exe" + Delete /rebootok "$INSTDIR\jack*.exe" + Delete /rebootok "$INSTDIR\*.dll" + Delete /rebootok "$INSTDIR\ardour.ico" + RMDir /r "$INSTDIR\etc" + RMDir /r "$INSTDIR\jack" + RMDir /r "$INSTDIR\lib" + RMDir /r "$INSTDIR\share" + RMDir "$INSTDIR" +!endif +SectionEnd + +Section -post +!ifndef DUMMY_INSTALL + WriteUninstaller "$INSTDIR\Uninstall Ardour-3.0.exe" +!endif +SectionEnd diff --git a/tools/windows_packaging/configure-debug.sh b/tools/windows_packaging/configure-debug.sh new file mode 100644 index 0000000000..bcee29deba --- /dev/null +++ b/tools/windows_packaging/configure-debug.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +. ./mingw-env.sh + +. ./print-env.sh + +cd $BASE || exit 1 +./waf configure --prefix="/" --bindir="/" --configdir="/share" --noconfirm --no-lv2 --test --single-tests --dist-target=mingw "$@" diff --git a/tools/windows_packaging/configure-release.sh b/tools/windows_packaging/configure-release.sh new file mode 100644 index 0000000000..2e943e00fe --- /dev/null +++ b/tools/windows_packaging/configure-release.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +. ./mingw-env.sh + +. ./print-env.sh + +cd $BASE || exit 1 +./waf configure --prefix="/" --bindir="/" --configdir="/share" --optimize --noconfirm --no-lv2 --dist-target=mingw "$@" diff --git a/tools/windows_packaging/cptovm.sh b/tools/windows_packaging/cptovm.sh new file mode 100644 index 0000000000..62e6fd6a27 --- /dev/null +++ b/tools/windows_packaging/cptovm.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +. ./mingw-env.sh + +TMP_DIR=tmp +LOOP_DEV=/dev/loop4 + +cd $BASE || exit 1 + +if [ ! -d $TMP_DIR ]; then + echo "Creating temp directory to mount vm image ..." + mkdir $TMP_DIR || exit 1 +fi + +echo "mounting vm image as loopback device ..." + +sudo mount -o loop=$LOOP_DEV,offset=32256 $VIRT_IMAGE_PATH $TMP_DIR || exit 1 + +if [ -d $TMP_DIR/$PACKAGE_DIR ]; then + echo "Removing old copy of $PACKAGE_DIR from vm image ..." + rm -rf $TMP_DIR/$PACKAGE_DIR || exit 1 +fi + +echo "Copying $PACKAGE_DIR to vm image ..." +cp -r $PACKAGE_DIR $TMP_DIR || exit 1 + +if [ "$1" == "--data" ]; then + DATA_DIR=data + + if [ -d $TMP_DIR/$DATA_DIR ]; then + echo "Removing old copy of $DATA_DIR from vm image ..." + rm -rf $TMP_DIR/$DATA_DIR || exit 1 + fi + + echo "Copying $DATA_DIR to vm image ..." + cp -r $DATA_DIR $TMP_DIR || exit 1 +fi + + +# in case mount is busy +sleep 2 + +echo "Unmounting vm image ..." + +sudo umount -d tmp + +echo "Removing temp directory used to mount vm image ..." +rm -rf $TMP_DIR || exit 1 + +if sudo losetup $LOOP_DEV; then + echo "sleeping for 10 seconds and trying again ..." + sleep 10 + if sudo losetup -d $LOOP_DEV; then + echo "Unmounted loopback device successfully" + exit 0 + else: + echo "Unmounting loopback device unsuccessful, you will need to use losetup -d to unmount device" + exit 1 + fi +fi + +exit 0 diff --git a/tools/windows_packaging/gdbinit b/tools/windows_packaging/gdbinit new file mode 100644 index 0000000000..b170ccad1a --- /dev/null +++ b/tools/windows_packaging/gdbinit @@ -0,0 +1,2 @@ +echo dir src/gtk2_ardour \n + dir src/gtk2_ardour diff --git a/tools/windows_packaging/loaders.cache b/tools/windows_packaging/loaders.cache new file mode 100644 index 0000000000..8293cd8898 --- /dev/null +++ b/tools/windows_packaging/loaders.cache @@ -0,0 +1,144 @@ +# GdkPixbuf Image Loader Modules file +# Automatically generated file, do not edit +# Created by gdk-pixbuf-query-loaders.exe from gdk-pixbuf-2.21.7 +# +# LoaderDir = Z:\usr\i686-pc-mingw32\sys-root\mingw/lib/gdk-pixbuf-2.0/2.10.0/loaders +# +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.dll" +"png" 5 "gdk-pixbuf" "The PNG image format" "LGPL" +"image/png" "" +"png" "" +"\211PNG\r\n\032\n" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-xpm.dll" +"xpm" 4 "gdk-pixbuf" "The XPM image format" "LGPL" +"image/x-xpixmap" "" +"xpm" "" +"/* XPM */" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gdip-bmp.dll" +"bmp" 5 "gdk-pixbuf" "Het BMP-bestandsformaat" "LGPL" +"image/bmp" "image/x-bmp" "image/x-MS-bmp" "" +"bmp" "" +"BM" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gdip-tiff.dll" +"tiff" 5 "gdk-pixbuf" "The TIFF image format" "LGPL" +"image/tiff" "" +"tiff" "tif" "" +"MM *" " z " 100 +"II* " " z" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-pcx.dll" +"pcx" 4 "gdk-pixbuf" "The PCX image format" "LGPL" +"image/x-pcx" "" +"pcx" "" +"\n \001" "" 100 +"\n\002\001" "" 100 +"\n\003\001" "" 100 +"\n\004\001" "" 100 +"\n\005\001" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gdip-wmf.dll" +"wmf" 4 "gdk-pixbuf" "Het WMF-bestandsformaat" "LGPL" +"image/x-wmf" "" +"wmf" "apm" "" +"\327\315\306\232" "" 100 +"\001" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ras.dll" +"ras" 4 "gdk-pixbuf" "The Sun raster image format" "LGPL" +"image/x-cmu-raster" "image/x-sun-raster" "" +"ras" "" +"Y\246j\225" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gdip-ico.dll" +"ico" 4 "gdk-pixbuf" "Het ICO-bestandsformaat" "LGPL" +"image/x-icon" "image/x-ico" "" +"ico" "cur" "" +" \001 " "zz znz" 100 +" \002 " "zz znz" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-wbmp.dll" +"wbmp" 4 "gdk-pixbuf" "The WBMP image format" "LGPL" +"image/vnd.wap.wbmp" "" +"wbmp" "" +" " "zz" 1 +" `" "z " 1 +" @" "z " 1 +" " "z " 1 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-pnm.dll" +"pnm" 4 "gdk-pixbuf" "The PNM/PBM/PGM/PPM image format family" "LGPL" +"image/x-portable-anymap" "image/x-portable-bitmap" "image/x-portable-graymap" "image/x-portable-pixmap" "" +"pnm" "pbm" "pgm" "ppm" "" +"P1" "" 100 +"P2" "" 100 +"P3" "" 100 +"P4" "" 100 +"P5" "" 100 +"P6" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ani.dll" +"ani" 4 "gdk-pixbuf" "The ANI image format" "LGPL" +"application/x-navi-animation" "" +"ani" "" +"RIFF ACON" " xxxx " 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-qtif.dll" +"qtif" 4 "gdk-pixbuf" "The QTIF image format" "LGPL" +"image/x-quicktime" "image/qtif" "" +"qtif" "qif" "" +"abcdidsc" "xxxx " 100 +"abcdidat" "xxxx " 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-xbm.dll" +"xbm" 4 "gdk-pixbuf" "The XBM image format" "LGPL" +"image/x-xbitmap" "" +"xbm" "" +"#define " "" 100 +"/*" "" 50 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-icns.dll" +"icns" 4 "gdk-pixbuf" "The ICNS image format" "GPL" +"image/x-icns" "" +"icns" "" +"icns" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-jasper.dll" +"jpeg2000" 4 "gdk-pixbuf" "The JPEG 2000 image format" "LGPL" +"image/jp2" "image/jpeg2000" "image/jpx" "" +"jp2" "jpc" "jpx" "j2k" "jpf" "" +" jP" "!!!! " 100 +"\377O\377Q" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gdip-jpeg.dll" +"jpeg" 5 "gdk-pixbuf" "Het JPEG-bestandsformaat" "LGPL" +"image/jpeg" "" +"jpeg" "jpe" "jpg" "" +"\377\330" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gdip-gif.dll" +"gif" 5 "gdk-pixbuf" "Het GIF-bestandsformaat" "LGPL" +"image/gif" "" +"gif" "" +"GIF8" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gdip-emf.dll" +"emf" 4 "gdk-pixbuf" "Het EMF-bestandsformaat" "LGPL" +"application/emf" "application/x-emf" "image/x-emf" "image/x-mgx-emf" "" +"emf" "" +"\001" "" 100 + +"lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-tga.dll" +"tga" 4 "gdk-pixbuf" "The Targa image format" "LGPL" +"image/x-tga" "" +"tga" "targa" "" +" \001\001" "x " 100 +" \001\t" "x " 100 +" \002" "xz " 99 +" \003" "xz " 100 +" \n" "xz " 100 +" \013" "xz " 100 + + diff --git a/tools/windows_packaging/make-installer.sh b/tools/windows_packaging/make-installer.sh new file mode 100644 index 0000000000..621f271a61 --- /dev/null +++ b/tools/windows_packaging/make-installer.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +. ./mingw-env.sh + +cd $BASE || exit 1 + +if test ! -d $PACKAGE_DIR; then + echo "Win32 package directory does not exist" + exit 1 +fi + +cp $TOOLS_DIR/ardour.nsi $PACKAGE_DIR || exit 1 +cp $BASE/icons/icon/ardour.ico $PACKAGE_DIR || exit 1 + +cd $PACKAGE_DIR && makensis ardour.nsi diff --git a/tools/windows_packaging/mingw-env.sh b/tools/windows_packaging/mingw-env.sh new file mode 100644 index 0000000000..c6747ae03b --- /dev/null +++ b/tools/windows_packaging/mingw-env.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +BASE=$(readlink -f $0) +BASE=$(dirname $BASE) # up one +BASE=$(dirname $BASE) # up one more +BASE=$(dirname $BASE) # up one more + +HOST=i686-pc-mingw32 +MINGW_ROOT=/usr/$HOST/sys-root/mingw + +export PKG_CONFIG_PREFIX=$MINGW_ROOT +export PKG_CONFIG_LIBDIR=$MINGW_ROOT/lib/pkgconfig +export PKGCONFIG=mingw32-pkg-config +export AR=$HOST-ar +export RANLIB=$HOST-ranlib +export CC=$HOST-gcc +export CPP=$HOST-g++ +export CXX=$HOST-g++ +export AS=$HOST-as +export LINK_CC=$HOST-gcc +export LINK_CXX=$HOST-g++ +export WINRC=$HOST-windres +export STRIP=$HOST-strip + +BUILD_DIR=$BASE/build +BUILD_CACHE_FILE=$BUILD_DIR/c4che/_cache.py +TOOLS_DIR=$BASE/tools/windows_packaging + +APPNAME=`grep -m 1 '^APPNAME' $BASE/wscript | awk '{print $3}' | sed "s/'//g"` +VERSION=`grep -m 1 '^VERSION' $BASE/wscript | awk '{print $3}' | sed "s/'//g"` + +# These are only relevant after a build +if test -f $BUILD_CACHE_FILE +then + # Figure out the Build Type + if grep -q "DEBUG = True" $BUILD_CACHE_FILE; then + DEBUG=1 + PACKAGE_DIR="$APPNAME-$VERSION-win32-dbg" + else + PACKAGE_DIR="$APPNAME-$VERSION-win32" + fi + + if grep -q "BUILD_TESTS = True" $BUILD_CACHE_FILE; then + WITH_TESTS=1 + fi + + ARDOUR_DATA_DIR=$PACKAGE_DIR/share/ardour3 +fi + +# put this somewhere better... +VIRT_IMAGE_PATH=$HOME/virt-images/winxp.raw diff --git a/tools/windows_packaging/package.sh b/tools/windows_packaging/package.sh new file mode 100644 index 0000000000..2d7cb7d097 --- /dev/null +++ b/tools/windows_packaging/package.sh @@ -0,0 +1,186 @@ +#!/bin/bash + +. ./mingw-env.sh + +. ./print-env.sh + +cd $BASE || exit 1 + +if ! test -f $BUILD_CACHE_FILE; then + echo "ERROR: $APPNAME is not configured and built yet..." + exit 1 +fi + +if [ -d $PACKAGE_DIR ]; then + echo "Removing old package directory structure ..." + rm -rf $PACKAGE_DIR || exit 1 +fi + +./waf --destdir=$PACKAGE_DIR install || exit 1 + +echo "Moving Ardour dll's and executable to $PACKAGE_DIR ..." + +mv $PACKAGE_DIR/lib/ardour3/*.dll $PACKAGE_DIR || exit 1 +mv $PACKAGE_DIR/lib/ardour3/*.exe $PACKAGE_DIR || exit 1 + +echo "Deleting import libs ..." + +rm $PACKAGE_DIR/lib/*dll.a + +# delete sh script +rm $PACKAGE_DIR/ardour3 + +if test x$WITH_TESTS != x ; then + echo "Copying tests and test data to $PACKAGE_DIR ..." + cp $BUILD_DIR/libs/pbd/run-tests.exe $PACKAGE_DIR/pbd-run-tests.exe + cp -r $BASE/libs/pbd/test $PACKAGE_DIR/pbd_testdata + + cp $BUILD_DIR/libs/evoral/run-tests.exe $PACKAGE_DIR/evoral-run-tests.exe + mkdir -p $PACKAGE_DIR/test/testdata + cp -r $BASE/libs/evoral/test/testdata/TakeFive.mid $PACKAGE_DIR/test/testdata + + cp -r $BASE/libs/ardour/test/data $PACKAGE_DIR/ardour_testdata +fi + +echo "Copying mingw config files to $PACKAGE_DIR ..." +# just copy it all for now +cp -r $MINGW_ROOT/etc $PACKAGE_DIR + +cp -r $MINGW_ROOT/lib/gtk-2.0 $PACKAGE_DIR/lib +cp -r $MINGW_ROOT/lib/gdk-pixbuf-2.0 $PACKAGE_DIR/lib +cp $TOOLS_DIR/loaders.cache $PACKAGE_DIR/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache + +mkdir -p $PACKAGE_DIR/lib/pango/1.6.0/modules +cp -r $MINGW_ROOT/lib/pango/1.6.0/modules/*.dll $PACKAGE_DIR/lib/pango/1.6.0/modules +cp $TOOLS_DIR/pango.modules $PACKAGE_DIR/etc/pango + +DLLS=' +jack-0.dll +jackserver-0.dll +libart_lgpl_2-2.dll +libatk-1.0-0.dll +libatkmm-1.6-1.dll +libcairo-2.dll +libcairo-gobject-2.dll +libcairomm-1.0-1.dll +libcairo-script-interpreter-2.dll +libcppunit-1-12-1.dll +libcrypto-10.dll +libcurl-4.dll +libexpat-1.dll +libfftw3-3.dll +libfftw3f-3.dll +libfontconfig-1.dll +libfreetype-6.dll +libgailutil-18.dll +libgcc_s_sjlj-1.dll +libgdkmm-2.4-1.dll +libgdk_pixbuf-2.0-0.dll +libgdk-win32-2.0-0.dll +libgio-2.0-0.dll +libgiomm-2.4-1.dll +libglib-2.0-0.dll +libglibmm-2.4-1.dll +libglibmm_generate_extra_defs-2.4-1.dll +libgmodule-2.0-0.dll +libgnomecanvas-2-0.dll +libgnomecanvasmm-2.6-1.dll +libgnurx-0.dll +libgobject-2.0-0.dll +libgthread-2.0-0.dll +libgtkmm-2.4-1.dll +libgtk-win32-2.0-0.dll +libiconv-2.dll +iconv.dll +libFLAC-8.dll +libogg-0.dll +libvorbis-0.dll +libvorbisenc-2.dll +libffi-5.dll +libidn-11.dll +libintl-8.dll +libpango-1.0-0.dll +libpangocairo-1.0-0.dll +libpangoft2-1.0-0.dll +libpangomm-1.4-1.dll +libpangowin32-1.0-0.dll +libpixman-1-0.dll +libpng14-14.dll +libsamplerate-0.dll +libsigc-2.0-0.dll +libsndfile-1.dll +libssh2-1.dll +libssl-10.dll +libstdc++-6.dll +libxml2-2.dll +pthreadGC2.dll +zlib1.dll +' + +echo "Copying mingw shared libraries to $PACKAGE_DIR ..." + +for i in $DLLS; +do +cp $MINGW_ROOT/bin/$i $PACKAGE_DIR +done + +echo "Copying JACK server and drivers to $PACKAGE_DIR ..." + +cp $MINGW_ROOT/bin/jackd.exe $PACKAGE_DIR +cp -r $MINGW_ROOT/bin/jack $PACKAGE_DIR +cp $MINGW_ROOT/bin/libportaudio-2.dll $PACKAGE_DIR + +SRC_DIRS=' +libs/ardour +libs/pbd +libs/gtkmm2ext +libs/midi++2 +libs/evoral +libs/panners +libs/timecode +libs/audiographer +' + +if test x$DEBUG != x ; then + + PACKAGE_SRC_DIR=$PACKAGE_DIR/src + echo "Copying source files to $PACKAGE_SRC_DIR ..." + mkdir -p $PACKAGE_SRC_DIR/libs + cp -r $BASE/gtk2_ardour $PACKAGE_SRC_DIR + for i in $SRC_DIRS; + do + cp -r -p $BASE/$i $PACKAGE_SRC_DIR/libs + done + + echo "Copying JACK utility programs to $PACKAGE_DIR ..." + cp $MINGW_ROOT/bin/jack_*.exe $PACKAGE_DIR + + echo "Copying any debug files to $PACKAGE_DIR ..." + cp $MINGW_ROOT/bin/*.debug $PACKAGE_DIR + + echo "Copying gdb to $PACKAGE_DIR ..." + cp $MINGW_ROOT/bin/gdb.exe $PACKAGE_DIR + + echo "Copying .gdbinit to $PACKAGE_DIR ..." + cp $TOOLS_DIR/gdbinit $PACKAGE_DIR/.gdbinit + + echo "Copying Gtk demo to $PACKAGE_DIR ..." + cp $MINGW_ROOT/bin/gtk-demo.exe $PACKAGE_DIR +else + echo "Optimized build Stripping executable ..." + $STRIP $PACKAGE_DIR/ardour-3.0.exe + echo "Stripping libraries ..." + find $PACKAGE_DIR -type f -name "*.dll*" | xargs $STRIP +fi + +if [ "$1" == "--tarball" ]; then + echo "Creating tarball from $PACKAGE_DIR ..." + cd $BASE || exit 1 + tar -cvJf $PACKAGE_DIR.tar.xz $PACKAGE_DIR +fi + +if [ "$1" == "--zip" ]; then + echo "Creating zip file from $PACKAGE_DIR ..." + cd $BASE || exit 1 + zip -r $PACKAGE_DIR.zip $PACKAGE_DIR +fi diff --git a/tools/windows_packaging/pango.modules b/tools/windows_packaging/pango.modules new file mode 100644 index 0000000000..70d300bc10 --- /dev/null +++ b/tools/windows_packaging/pango.modules @@ -0,0 +1,35 @@ +# Pango Modules file +# Automatically generated file, do not edit +# +# ModulesPath = Z:\usr\i686-pc-mingw32\sys-root\mingw\lib\pango\1.6.0\modules +# +"lib\\pango\\1.6.0\\modules\\pango-thai-fc.dll" ThaiScriptEngineFc PangoEngineShape PangoRenderFc thai:* lao:* +"lib\\pango\\1.6.0\\modules\\pango-basic-win32.dll" BasicScriptEngineWin32 PangoEngineShape PangoRenderWin32 common: +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" devaScriptEngineFc PangoEngineShape PangoRenderFc devanagari:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" bengScriptEngineFc PangoEngineShape PangoRenderFc bengali:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" guruScriptEngineFc PangoEngineShape PangoRenderFc gurmukhi:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" gujrScriptEngineFc PangoEngineShape PangoRenderFc gujarati:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" oryaScriptEngineFc PangoEngineShape PangoRenderFc oriya:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" tamlScriptEngineFc PangoEngineShape PangoRenderFc tamil:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" teluScriptEngineFc PangoEngineShape PangoRenderFc telugu:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" kndaScriptEngineFc PangoEngineShape PangoRenderFc kannada:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" mlymScriptEngineFc PangoEngineShape PangoRenderFc malayalam:* +"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" sinhScriptEngineFc PangoEngineShape PangoRenderFc sinhala:* +"lib\\pango\\1.6.0\\modules\\pango-syriac-fc.dll" SyriacScriptEngineFc PangoEngineShape PangoRenderFc syriac:* +"lib\\pango\\1.6.0\\modules\\pango-khmer-fc.dll" KhmerScriptEngineFc PangoEngineShape PangoRenderFc khmer:* +"lib\\pango\\1.6.0\\modules\\pango-arabic-lang.dll" ArabicScriptEngineLang PangoEngineLang PangoRenderNone arabic:* +"lib\\pango\\1.6.0\\modules\\pango-basic-fc.dll" BasicScriptEngineFc PangoEngineShape PangoRenderFc latin:* cyrillic:* greek:* armenian:* georgian:* runic:* ogham:* bopomofo:* cherokee:* coptic:* deseret:* ethiopic:* gothic:* han:* hiragana:* katakana:* old-italic:* canadian-aboriginal:* yi:* braille:* cypriot:* limbu:* osmanya:* shavian:* linear-b:* ugaritic:* glagolitic:* cuneiform:* phoenician:* common: +"lib\\pango\\1.6.0\\modules\\pango-arabic-fc.dll" ArabicScriptEngineFc PangoEngineShape PangoRenderFc arabic:* nko:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" devaIndicScriptEngineLang PangoEngineLang PangoRenderNone devanagari:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" bengIndicScriptEngineLang PangoEngineLang PangoRenderNone bengali:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" guruIndicScriptEngineLang PangoEngineLang PangoRenderNone gurmukhi:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" gujrIndicScriptEngineLang PangoEngineLang PangoRenderNone gujarati:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" oryaIndicScriptEngineLang PangoEngineLang PangoRenderNone oriya:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" tamlIndicScriptEngineLang PangoEngineLang PangoRenderNone tamil:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" teluIndicScriptEngineLang PangoEngineLang PangoRenderNone telugu:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" kndaIndicScriptEngineLang PangoEngineLang PangoRenderNone kannada:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" mlymIndicScriptEngineLang PangoEngineLang PangoRenderNone malayalam:* +"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" sinhIndicScriptEngineLang PangoEngineLang PangoRenderNone sinhala:* +"lib\\pango\\1.6.0\\modules\\pango-hebrew-fc.dll" HebrewScriptEngineFc PangoEngineShape PangoRenderFc hebrew:* +"lib\\pango\\1.6.0\\modules\\pango-tibetan-fc.dll" TibetanScriptEngineFc PangoEngineShape PangoRenderFc tibetan:* +"lib\\pango\\1.6.0\\modules\\pango-hangul-fc.dll" HangulScriptEngineFc PangoEngineShape PangoRenderFc hangul:* diff --git a/tools/windows_packaging/print-env.sh b/tools/windows_packaging/print-env.sh new file mode 100644 index 0000000000..d6f63a2e5b --- /dev/null +++ b/tools/windows_packaging/print-env.sh @@ -0,0 +1,40 @@ +echo "Build Environment Settings...." +echo " " +echo " " +echo "HOST : $HOST" +echo "MINGW_ROOT : $MINGW_ROOT" +echo "PKG_CONFIG_PREFIX : $PKG_CONFIG_PREFIX" +echo "PKG_CONFIG_LIBDIR : $PKG_CONFIG_LIBDIR" +echo "PKGCONFIG : $PKGCONFIG" +echo "AR : $AR" +echo "RANLIB : $RANLIB" +echo "CC : $CC" +echo "CPP : $CPP" +echo "CXX : $CXX" +echo "AS : $AS" +echo "LINK_CC : $LINK_CC" +echo "LINK_CXX : $LINK_CXX" +echo "WINRC : $WINRC" +echo "STRIP : $STRIP" +echo " " +echo " " +echo "Path Environment Settings...." +echo " " +echo " " +echo "BASE : $BASE" +echo "BUILD_DIR : $BUILD_DIR" +echo "BUILD_CACHE_FILE : $BUILD_CACHE_FILE" +echo "TOOLS_DIR : $TOOLS_DIR" +echo "PACKAGE_DIR : $PACKAGE_DIR" +echo " " +echo " " +echo "Config Environment Settings...." +echo " " +echo " " +echo "APPNAME : $APPNAME" +echo "VERSION : $VERSION" +echo "DEBUG : $DEBUG" +echo "WITH_TESTS : $WITH_TESTS" +echo "ARDOUR_DATA_DIR : $ARDOUR_DATA_DIR" +echo " " +echo " " diff --git a/tools/windows_packaging/run-wine.sh b/tools/windows_packaging/run-wine.sh new file mode 100644 index 0000000000..86415206cc --- /dev/null +++ b/tools/windows_packaging/run-wine.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +. ./mingw-env.sh + +cd $BASE + +LIBS=$BUILD_DIR/libs + +export ARDOUR_PATH=$BASE/gtk2_ardour/icons:$BASE/gtk2_ardour/pixmaps:$BASE/build/default/gtk2_ardour:$BASE/gtk2_ardour:. +export ARDOUR_SURFACES_PATH=$LIBS/surfaces/osc:$LIBS/surfaces/generic_midi:$LIBS/surfaces/tranzport:$LIBS/surfaces/powermate:$LIBS/surfaces/mackie +export ARDOUR_PANNER_PATH=$LIBS/panners/2in2out:$LIBS/panners/1in2out:$LIBS/panners/vbap +export ARDOUR_DATA_PATH=$BASE/gtk2_ardour:build/default/gtk2_ardour:. + +export VAMP_PATH=$LIBS/vamp-plugins${VAMP_PATH:+:$VAMP_PATH} + +export PBD_TEST_PATH=$BASE/libs/pbd/test/ + +if test ! -d $PACKAGE_DIR; then + echo "Win32 package directory does not exist" + exit 1 +fi + +cd $PACKAGE_DIR + + +if [ "$1" == "--run-tests" ]; then + if test x$WITH_TESTS != x ; then + echo "<<<<<<<<<<<<<<<<<< RUNNING LIBPBD TESTS >>>>>>>>>>>>>>>>>>>" + wine pbd-run-tests.exe + echo "<<<<<<<<<<<<<<<<<< RUNNING EVORAL TESTS >>>>>>>>>>>>>>>>>>>" + wine evoral-run-tests.exe + echo "<<<<<<<<<<<<<<<<<< RUNNING ARDOUR TESTS >>>>>>>>>>>>>>>>>>>" + wine ardour-run-tests.exe + else + echo "No tests to run ..." + fi +else + wine ardour-3.0.exe +fi diff --git a/tools/windows_packaging/startvm.sh b/tools/windows_packaging/startvm.sh new file mode 100644 index 0000000000..6d36bd8cb7 --- /dev/null +++ b/tools/windows_packaging/startvm.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +qemu-kvm -smp 2 -m 1536 -hda $HOME/virt-images/winxp.raw -net nic -net user -vga std -soundhw all diff --git a/tools/windows_packaging/waf.sh b/tools/windows_packaging/waf.sh new file mode 100644 index 0000000000..5b581ba85e --- /dev/null +++ b/tools/windows_packaging/waf.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +. ./mingw-env.sh + +cd $BASE || exit 1 +./waf "$@" -- cgit v1.2.3 From f83b435c83b27fc7c6baf9be9305b1aa72095093 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:26:29 -0400 Subject: Add clean script to windows stuff to save a bit of typing --- tools/windows_packaging/clean.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tools/windows_packaging/clean.sh diff --git a/tools/windows_packaging/clean.sh b/tools/windows_packaging/clean.sh new file mode 100644 index 0000000000..95776124aa --- /dev/null +++ b/tools/windows_packaging/clean.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +. mingw-env.sh + +rm -rf $BUILD_DIR -- cgit v1.2.3 From 36a55b8674f0c3c2d06a9654aef0d9d5ab42e8aa Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:30:32 -0400 Subject: Use boost::uuid instead of libuuid --- libs/pbd/pbd/uuid.h | 40 ++++++++++++++++++-------------- libs/pbd/pbd/uuid_boost.h | 58 ----------------------------------------------- libs/pbd/uuid.cc | 7 +++--- libs/pbd/uuid_boost.cc | 37 ------------------------------ libs/pbd/wscript | 3 --- 5 files changed, 26 insertions(+), 119 deletions(-) delete mode 100644 libs/pbd/pbd/uuid_boost.h delete mode 100644 libs/pbd/uuid_boost.cc diff --git a/libs/pbd/pbd/uuid.h b/libs/pbd/pbd/uuid.h index 16a67436b7..bf5abfc1ac 100644 --- a/libs/pbd/pbd/uuid.h +++ b/libs/pbd/pbd/uuid.h @@ -22,29 +22,35 @@ #define __pbd_uuid_h__ #include -#include +#include +#include namespace PBD { -class UUID { +class UUID : public boost::uuids::uuid { public: - UUID () { uuid_generate (id); } - UUID (UUID const & other) { uuid_copy (id, other.id); } - UUID (std::string const & str) { uuid_parse (str.c_str(), id); } - - UUID& operator= (std::string const & str); - std::string to_s () const; - - bool operator== (UUID const & other) const { return !uuid_compare (id, other.id); } - bool operator!= (UUID const & other) const { return uuid_compare (id, other.id); } - bool operator< (UUID const & other) const { return uuid_compare (id, other.id) < 0; } - - operator bool() const { return !uuid_is_null (id); } - - private: - uuid_t id; + UUID () + : boost::uuids::uuid (boost::uuids::random_generator()()) {} + UUID (std::string const & str) + : boost::uuids::uuid (boost::uuids::string_generator()(str)) {} + explicit UUID (boost::uuids::uuid const& u) + : boost::uuids::uuid(u) + {} + + operator boost::uuids::uuid() { + return static_cast(*this); + } + + operator boost::uuids::uuid() const { + return static_cast(*this); + } + + UUID& operator= (std::string const & str); + std::string to_s () const; + + operator bool() const { return !is_nil(); } }; } // namespace PBD diff --git a/libs/pbd/pbd/uuid_boost.h b/libs/pbd/pbd/uuid_boost.h deleted file mode 100644 index 275b72648a..0000000000 --- a/libs/pbd/pbd/uuid_boost.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2008 Paul Davis - Author: Sakari Bergen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef __pbd_uuid_h__ -#define __pbd_uuid_h__ - -#include -#include -#include - -namespace PBD { - -class UUID : public boost::uuids::uuid { - - public: - UUID () - : boost::uuids::uuid (boost::uuids::random_generator()()) {} - UUID (std::string const & str) - : boost::uuids::uuid (boost::uuids::string_generator()(str)) {} - - explicit UUID (boost::uuids::uuid const& u) - : boost::uuids::uuid(u) - {} - - operator boost::uuids::uuid() { - return static_cast(*this); - } - - operator boost::uuids::uuid() const { - return static_cast(*this); - } - - UUID& operator= (std::string const & str); - std::string to_s () const; - - operator bool() const { return !is_nil(); } -}; - -} // namespace PBD - -#endif // __pbd_uuid_h__ diff --git a/libs/pbd/uuid.cc b/libs/pbd/uuid.cc index 0ffeca23cb..1a988b9820 100644 --- a/libs/pbd/uuid.cc +++ b/libs/pbd/uuid.cc @@ -25,14 +25,13 @@ using namespace PBD; UUID& UUID::operator= (std::string const & str) { - uuid_parse (str.c_str(), id); + boost::uuids::string_generator gen; + *((boost::uuids::uuid*) this) = gen (str); return *this; } std::string UUID::to_s () const { - char buf[37]; - uuid_unparse (id, buf); - return std::string (buf); + return std::string ((const char*) data, size()); } diff --git a/libs/pbd/uuid_boost.cc b/libs/pbd/uuid_boost.cc deleted file mode 100644 index 1a988b9820..0000000000 --- a/libs/pbd/uuid_boost.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2008 Paul Davis - Author: Sakari Bergen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "pbd/uuid.h" - -using namespace PBD; - -UUID& -UUID::operator= (std::string const & str) -{ - boost::uuids::string_generator gen; - *((boost::uuids::uuid*) this) = gen (str); - return *this; -} - -std::string -UUID::to_s () const -{ - return std::string ((const char*) data, size()); -} diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 5c8ed194a8..77403bddf4 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -89,8 +89,6 @@ def configure(conf): autowaf.configure(conf) autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML') autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0') - if sys.platform != 'darwin': - autowaf.check_pkg(conf, 'uuid', uselib_store='UUID') conf.check(function_name='getmntent', header_name='mntent.h', define_name='HAVE_GETMNTENT',mandatory=False) conf.check(header_name='execinfo.h', define_name='HAVE_EXECINFO',mandatory=False) @@ -102,7 +100,6 @@ def configure(conf): # Boost headers autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp') autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp') - # autowaf.check_header(conf, 'cxx', 'boost/uuid/uuid.hpp') def build(bld): -- cgit v1.2.3 From acc13d37a7e18ab5b4af9410f8a80d6e9d2c4a72 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:36:16 -0400 Subject: Use boost::tokenizer in PBD::parse_debug_options for portability --- libs/pbd/debug.cc | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/libs/pbd/debug.cc b/libs/pbd/debug.cc index c86afbe87e..51d4d1e871 100644 --- a/libs/pbd/debug.cc +++ b/libs/pbd/debug.cc @@ -24,6 +24,8 @@ #include #include +#include + #include "pbd/debug.h" #include "i18n.h" @@ -75,36 +77,31 @@ PBD::set_debug_bits (uint64_t bits) int PBD::parse_debug_options (const char* str) { - char* p; - char* sp; + typedef boost::tokenizer > tokenizer; + boost::char_separator sep (","); + tokenizer tokens (string(str), sep); uint64_t bits = 0; - char* copy = strdup (str); - - p = strtok_r (copy, ",", &sp); - while (p) { - if (strcasecmp (p, "list") == 0) { + for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) { + if (*tok_iter == "list") { list_debug_options (); - free (copy); return 1; } - if (strcasecmp (p, "all") == 0) { + if (*tok_iter == "all") { PBD::set_debug_bits (~0ULL); - free (copy); return 0; } for (map::iterator i = _debug_bit_map().begin(); i != _debug_bit_map().end(); ++i) { - if (strncasecmp (p, i->first, strlen (p)) == 0) { + const char* cstr = (*tok_iter).c_str(); + + if (strncasecmp (cstr, i->first, strlen (cstr)) == 0) { bits |= i->second; } } - - p = strtok_r (0, ",", &sp); } - free (copy); PBD::set_debug_bits (bits); return 0; } -- cgit v1.2.3 From 38ebf63961529c87d88defc969ad7bc6dbbacc0a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:39:24 -0400 Subject: Fallback to gettimeofday for access time in FileManager --- libs/pbd/file_manager.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/pbd/file_manager.cc b/libs/pbd/file_manager.cc index a71ffca190..72eeeb2524 100644 --- a/libs/pbd/file_manager.cc +++ b/libs/pbd/file_manager.cc @@ -116,10 +116,14 @@ FileManager::allocate (FileDescriptor* d) #ifdef __APPLE__ d->_last_used = mach_absolute_time(); -#else +#elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) struct timespec t; clock_gettime (CLOCK_MONOTONIC, &t); d->_last_used = t.tv_sec + (double) t.tv_nsec / 10e9; +#else + struct timeval now; + gettimeofday (&now, NULL); + d->_last_used = now.tv_sec + (double) now.tv_usec / 10e6; #endif d->_refcount++; -- cgit v1.2.3 From 4eff7b4e822d71897ebf938250b732499a3bc7ab Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:41:55 -0400 Subject: Add pbd/resource.h for portable access to resource limits --- libs/pbd/pbd/resource.h | 49 +++++++++++++++++++++++++++++++ libs/pbd/resource.cc | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ libs/pbd/wscript | 1 + 3 files changed, 127 insertions(+) create mode 100644 libs/pbd/pbd/resource.h create mode 100644 libs/pbd/resource.cc diff --git a/libs/pbd/pbd/resource.h b/libs/pbd/pbd/resource.h new file mode 100644 index 0000000000..ec826e4930 --- /dev/null +++ b/libs/pbd/pbd/resource.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2011 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include + +namespace PBD { + +typedef uint64_t rlimit_t; + +enum ResourceType { + OpenFiles +}; + +struct ResourceLimit +{ + rlimit_t current_limit; + rlimit_t max_limit; +}; + +/** + * @return true on success, false on error + */ +bool +get_resource_limit (ResourceType resource, ResourceLimit& limit); + +/** + * @return true on success, false on error + */ +bool +set_resource_limit (ResourceType resource, const ResourceLimit& limit); + + +} // namespace PBD diff --git a/libs/pbd/resource.cc b/libs/pbd/resource.cc new file mode 100644 index 0000000000..b2988b6314 --- /dev/null +++ b/libs/pbd/resource.cc @@ -0,0 +1,77 @@ +/* + Copyright (C) 2011 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifdef WIN32 +#include +#else +#include +#include +#endif + +#include "pbd/resource.h" + +namespace PBD { + +bool +get_resource_limit (ResourceType resource, ResourceLimit& limit) +{ + if (resource == OpenFiles) + { +#ifdef WIN32 + limit.current_limit = _getmaxstdio(); + limit.max_limit = 2048; + return true; +#else + struct rlimit rl; + if (getrlimit (RLIMIT_NOFILE, &rl) == 0) { + limit.current_limit = rl.rlim_cur; + limit.max_limit = rl.rlim_max; + return true; + } +#endif + } + + return false; +} + +bool +set_resource_limit (ResourceType resource, const ResourceLimit& limit) +{ + if (resource == OpenFiles) + { +#ifdef WIN32 + // no soft and hard limits on windows + rlimit_t new_max = _setmaxstdio(limit.current_limit); + + if (new_max == limit.current_limit) return true; +#else + struct rlimit rl; + rl.rlim_cur = limit.current_limit; + rl.rlim_max = limit.max_limit; + if (setrlimit (RLIMIT_NOFILE, &rl) == 0) { + return true; + } + +#endif + } + + return false; +} + +} // namespace PBD diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 77403bddf4..2057c728da 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -60,6 +60,7 @@ libpbd_sources = [ 'property_list.cc', 'pthread_utils.cc', 'receiver.cc', + 'resource.cc', 'search_path.cc', 'semutils.cc', 'shortpath.cc', -- cgit v1.2.3 From d7b7953705b1fc22f0803b428fedfde36c5ddcaa Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:42:53 -0400 Subject: Use pbd/resource.h in PBD::FileManager --- libs/pbd/file_manager.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/pbd/file_manager.cc b/libs/pbd/file_manager.cc index 72eeeb2524..e02bcc2b0d 100644 --- a/libs/pbd/file_manager.cc +++ b/libs/pbd/file_manager.cc @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -31,6 +30,7 @@ #include "pbd/compose.h" #include "pbd/file_manager.h" +#include "pbd/resource.h" #include "pbd/debug.h" using namespace std; @@ -41,12 +41,11 @@ FileManager* FileDescriptor::_manager; FileManager::FileManager () : _open (0) { - struct rlimit rl; - int const r = getrlimit (RLIMIT_NOFILE, &rl); + struct ResourceLimit rl; /* XXX: this is a bit arbitrary */ - if (r == 0) { - _max_open = rl.rlim_cur - 64; + if (get_resource_limit (OpenFiles, rl)) { + _max_open = rl.current_limit - 64; } else { _max_open = 256; } -- cgit v1.2.3 From daf570ea5df1013e3b237ed35df1b565340851d1 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:43:55 -0400 Subject: Add an empty implementation of PBD::mountpoint for mingw PBD::mountpoint is only used to find peakfiles for old sessions, so it might not be necessary to implement this for windows. --- libs/pbd/mountpoint.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/pbd/mountpoint.cc b/libs/pbd/mountpoint.cc index 46cea42e0a..b2fb84760d 100644 --- a/libs/pbd/mountpoint.cc +++ b/libs/pbd/mountpoint.cc @@ -94,6 +94,14 @@ mountpoint (string path) return best; } +#elif defined(WIN32) + +string +mountpoint (string path) +{ + // TODO ... if needed +} + #else // !HAVE_GETMNTENT #include -- cgit v1.2.3 From 8b63e005a15afb4cf769fd0c7fc91e48dde254a2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:44:33 -0400 Subject: Include io.h on windows for access --- libs/pbd/file_utils.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index bb290fa6aa..01c2fe286a 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -23,6 +23,10 @@ #include #include +#ifdef WIN32 +#include // for W_OK +#endif + #include #include #include -- cgit v1.2.3 From e70db68fac1adbb5c9823231aa800658c4d7cc12 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:46:05 -0400 Subject: Add implementation for ProcessSemaphore on windows --- libs/pbd/pbd/semutils.h | 16 +++++++++++++++- libs/pbd/semutils.cc | 30 ++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/libs/pbd/pbd/semutils.h b/libs/pbd/pbd/semutils.h index 6f5f0e9331..0e8bed0512 100644 --- a/libs/pbd/pbd/semutils.h +++ b/libs/pbd/pbd/semutils.h @@ -19,13 +19,20 @@ #ifndef __pbd_semutils_h__ #define __pbd_semutils_h__ +#ifdef WIN32 +#include +#else #include +#endif namespace PBD { class ProcessSemaphore { private: -#ifdef __APPLE__ +#ifdef WIN32 + HANDLE _sem; + +#elif __APPLE__ sem_t* _sem; sem_t* ptr_to_sem() const { return _sem; } #else @@ -37,8 +44,15 @@ class ProcessSemaphore { ProcessSemaphore (const char* name, int val); ~ProcessSemaphore (); +#ifdef WIN32 + + int signal (); + int wait (); + +#else int signal () { return sem_post (ptr_to_sem()); } int wait () { return sem_wait (ptr_to_sem()); } +#endif }; } diff --git a/libs/pbd/semutils.cc b/libs/pbd/semutils.cc index 9ac5f60d35..e5df2e5c44 100644 --- a/libs/pbd/semutils.cc +++ b/libs/pbd/semutils.cc @@ -23,7 +23,12 @@ using namespace PBD; ProcessSemaphore::ProcessSemaphore (const char* name, int val) { -#ifdef __APPLE__ +#ifdef WIN32 + if ((_sem = CreateSemaphore(NULL, val, 32767, name)) == NULL) { + throw failed_constructor (); + } + +#elif __APPLE__ if ((_sem = sem_open (name, O_CREAT, 0600, val)) == (sem_t*) SEM_FAILED) { throw failed_constructor (); } @@ -43,7 +48,28 @@ ProcessSemaphore::ProcessSemaphore (const char* name, int val) ProcessSemaphore::~ProcessSemaphore () { -#ifdef __APPLE__ +#ifdef WIN32 + CloseHandle(_sem); +#elif __APPLE__ sem_close (ptr_to_sem()); #endif } + +#ifdef WIN32 + +int +ProcessSemaphore::signal () +{ + // non-zero on success, opposite to posix + return !ReleaseSemaphore(_sem, 1, NULL); +} + +int +ProcessSemaphore::wait () +{ + DWORD result = 0; + result = WaitForSingleObject(_sem, INFINITE); + return (result == WAIT_OBJECT_0); +} + +#endif -- cgit v1.2.3 From cb23bdd547c41121fd1e3bfff93de2e55981ad4c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:46:52 -0400 Subject: Don't use parts of signal.h that aren't defined when using mingw --- libs/pbd/transmitter.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/pbd/transmitter.cc b/libs/pbd/transmitter.cc index aa5c75da19..a172ac457d 100644 --- a/libs/pbd/transmitter.cc +++ b/libs/pbd/transmitter.cc @@ -84,10 +84,12 @@ Transmitter::deliver () /* do the right thing if this should not return */ if (does_not_return()) { +#ifndef WIN32 sigset_t mask; sigemptyset (&mask); sigsuspend (&mask); +#endif /*NOTREACHED*/ exit (1); } -- cgit v1.2.3 From 5d20b3e24eefc55b575d3703667d4a87e6491028 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:47:56 -0400 Subject: Ifdef unix specific test for mingw build --- libs/pbd/test/filesystem_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/pbd/test/filesystem_test.cc b/libs/pbd/test/filesystem_test.cc index ce2faadc82..0cbe5baf32 100644 --- a/libs/pbd/test/filesystem_test.cc +++ b/libs/pbd/test/filesystem_test.cc @@ -10,6 +10,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION (FilesystemTest); void FilesystemTest::testPathIsWithin () { +#ifndef WIN32 system ("rm -r foo"); CPPUNIT_ASSERT (g_mkdir_with_parents ("foo/bar/baz", 0755) == 0); @@ -31,5 +32,6 @@ FilesystemTest::testPathIsWithin () CPPUNIT_ASSERT (PBD::path_is_within ("foo/bar", "foo/bar")); CPPUNIT_ASSERT (PBD::path_is_within ("foo/jim/baz", "frobozz") == false); +#endif } -- cgit v1.2.3 From 7626cd68ac033de3ebaa0bf60ce4bdbf7da44329 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:52:46 -0400 Subject: Hide UI request mechanism from inheriting classes --- libs/gtkmm2ext/gtk_ui.cc | 2 +- libs/pbd/base_ui.cc | 17 ++++++++++++++--- libs/pbd/pbd/abstract_ui.cc | 2 +- libs/pbd/pbd/base_ui.h | 6 +++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 6e466f5c9f..ee5e0c07f6 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -94,7 +94,7 @@ UI::UI (string namestr, int *argc, char ***argv) /* attach our request source to the default main context */ - request_channel.ios()->attach (MainContext::get_default()); + attach_request_source (MainContext::get_default()); errors = new TextViewer (800,600); errors->text().set_editable (false); diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index 69b156589f..35ea6078ee 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -42,9 +42,9 @@ BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type(); BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type(); BaseUI::BaseUI (const string& str) - : request_channel (true) - , run_loop_thread (0) + : run_loop_thread (0) , _name (str) + , request_channel (true) { base_ui_instance = this; @@ -138,4 +138,15 @@ BaseUI::request_handler (Glib::IOCondition ioc) return true; } - + +void +BaseUI::signal_new_request () +{ + request_channel.wakeup (); +} + +void +BaseUI::attach_request_source (Glib::RefPtr context) +{ + request_channel.ios()->attach (context); +} diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc index 64fd718dbc..02b42fdead 100644 --- a/libs/pbd/pbd/abstract_ui.cc +++ b/libs/pbd/pbd/abstract_ui.cc @@ -349,7 +349,7 @@ AbstractUI::send_request (RequestObject *req) at the per-thread and generic request lists. */ - request_channel.wakeup (); + signal_new_request (); } } diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h index 186a3c55a6..22784c9bfc 100644 --- a/libs/pbd/pbd/base_ui.h +++ b/libs/pbd/pbd/base_ui.h @@ -71,7 +71,6 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop void quit (); protected: - CrossThreadChannel request_channel; bool _ok; Glib::RefPtr _main_loop; @@ -96,6 +95,9 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop */ bool request_handler (Glib::IOCondition); + void signal_new_request (); + void attach_request_source (Glib::RefPtr context); + /** Derived UI objects must implement this method, * which will be called whenever there are requests * to be dealt with. @@ -105,6 +107,8 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop private: std::string _name; BaseUI* base_ui_instance; + + CrossThreadChannel request_channel; static uint64_t rt_bit; -- cgit v1.2.3 From 4adb2f97cc991341d7e3b2a165e72373221a1b5e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:56:35 -0400 Subject: Use timeout source to process ui requests on windows Using a timeout source to process ui events/requests is suboptimal but it works for the moment. Have to use g_source functions as glibmm functions are not thread safe AFAIK. Behaviour should be exactly the same on unix. --- libs/gtkmm2ext/gtk_ui.cc | 2 +- libs/pbd/base_ui.cc | 58 +++++++++++++++++++++++++++++++++++++++++------- libs/pbd/pbd/base_ui.h | 14 +++++++++--- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index ee5e0c07f6..831fa7e38f 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -94,7 +94,7 @@ UI::UI (string namestr, int *argc, char ***argv) /* attach our request source to the default main context */ - attach_request_source (MainContext::get_default()); + attach_request_source (); errors = new TextViewer (800,600); errors->text().set_editable (false); diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index 35ea6078ee..5725d69182 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -33,6 +33,8 @@ #include "i18n.h" +#include "pbd/debug.h" + using namespace std; using namespace PBD; using namespace Glib; @@ -42,13 +44,18 @@ BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type(); BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type(); BaseUI::BaseUI (const string& str) - : run_loop_thread (0) + : m_context(MainContext::get_default()) + , run_loop_thread (0) , _name (str) +#ifndef WIN32 , request_channel (true) +#endif { base_ui_instance = this; +#ifndef WIN32 request_channel.ios()->connect (sigc::mem_fun (*this, &BaseUI::request_handler)); +#endif /* derived class must set _ok */ } @@ -95,11 +102,9 @@ BaseUI::run () /* to be called by UI's that need/want their own distinct, self-created event loop thread. */ - _main_loop = MainLoop::create (MainContext::create()); - request_channel.ios()->attach (_main_loop->get_context()); - - /* glibmm hack - drop the refptr to the IOSource now before it can hurt */ - request_channel.drop_ios (); + m_context = MainContext::create(); + _main_loop = MainLoop::create (m_context); + attach_request_source (); Glib::Threads::Mutex::Lock lm (_run_lock); run_loop_thread = Glib::Threads::Thread::create (mem_fun (*this, &BaseUI::main_thread)); @@ -115,6 +120,24 @@ BaseUI::quit () } } +#ifdef WIN32 +gboolean +BaseUI::_request_handler (gpointer data) +{ + BaseUI* ui = static_cast(data); + return ui->request_handler (); +} + +bool +BaseUI::request_handler () +{ + DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::request_handler\n"); + handle_ui_requests (); + // keep calling indefinitely at the timeout interval + return true; +} + +#else bool BaseUI::request_handler (Glib::IOCondition ioc) { @@ -133,20 +156,39 @@ BaseUI::request_handler (Glib::IOCondition ioc) /* handle requests */ + DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::request_handler\n"); handle_ui_requests (); } return true; } +#endif void BaseUI::signal_new_request () { + DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::signal_new_request\n"); +#ifdef WIN32 + // handled in timeout, how to signal...? +#else request_channel.wakeup (); +#endif } +/** + * This method relies on the caller having already set m_context + */ void -BaseUI::attach_request_source (Glib::RefPtr context) +BaseUI::attach_request_source () { - request_channel.ios()->attach (context); + DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::attach_request_source\n"); +#ifdef WIN32 + GSource* request_source = g_timeout_source_new(200); + g_source_set_callback (request_source, &BaseUI::_request_handler, this, NULL); + g_source_attach (request_source, m_context->gobj()); +#else + request_channel.ios()->attach (m_context); + /* glibmm hack - drop the refptr to the IOSource now before it can hurt */ + request_channel.drop_ios (); +#endif } diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h index 22784c9bfc..686af485e6 100644 --- a/libs/pbd/pbd/base_ui.h +++ b/libs/pbd/pbd/base_ui.h @@ -74,9 +74,10 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop bool _ok; Glib::RefPtr _main_loop; - Glib::Threads::Thread* run_loop_thread; + Glib::RefPtr m_context; + Glib::Threads::Thread* run_loop_thread; Glib::Threads::Mutex _run_lock; - Glib::Threads::Cond _running; + Glib::Threads::Cond _running; /* this signals _running from within the event loop, from an idle callback @@ -91,12 +92,17 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop virtual void thread_init () {}; +#ifdef WIN32 + static gboolean _request_handler (gpointer); + bool request_handler (); +#else /** Called when there input ready on the request_channel */ bool request_handler (Glib::IOCondition); +#endif void signal_new_request (); - void attach_request_source (Glib::RefPtr context); + void attach_request_source (); /** Derived UI objects must implement this method, * which will be called whenever there are requests @@ -108,7 +114,9 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop std::string _name; BaseUI* base_ui_instance; +#ifndef WIN32 CrossThreadChannel request_channel; +#endif static uint64_t rt_bit; -- cgit v1.2.3 From 8a9cdd04c55ccac7c5d3186cdcf3ecd4e122410c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 12:58:44 -0400 Subject: Include pthread.h as it isn't included via jack headers on windows --- libs/midi++2/midi++/port.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/midi++2/midi++/port.h b/libs/midi++2/midi++/port.h index 599fabaa87..439760115c 100644 --- a/libs/midi++2/midi++/port.h +++ b/libs/midi++2/midi++/port.h @@ -24,6 +24,8 @@ #include +#include + #include "pbd/xml++.h" #include "pbd/crossthread.h" #include "pbd/signals.h" -- cgit v1.2.3 From ab8918fa733efd1660761c9f50ced74948ce724c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:00:42 -0400 Subject: Changes to get IPMIDIPort to compile(but not functional) on MinGW --- libs/midi++2/ipmidi_port.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/midi++2/ipmidi_port.cc b/libs/midi++2/ipmidi_port.cc index c90a3dbe6f..7f166f5b24 100644 --- a/libs/midi++2/ipmidi_port.cc +++ b/libs/midi++2/ipmidi_port.cc @@ -25,7 +25,11 @@ #include #include #include +#if defined(WIN32) +#include +#else #include +#endif #if defined(WIN32) static WSADATA g_wsaData; @@ -147,6 +151,7 @@ get_address (int sock, struct in_addr *inaddr, const string& ifname ) bool IPMIDIPort::open_sockets (int base_port, const string& ifname) { +#if !defined(WIN32) int protonum = 0; struct protoent *proto = ::getprotobyname("IP"); @@ -243,6 +248,9 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname) } return true; +#else + return false; +#endif // !WIN32 } int -- cgit v1.2.3 From 8d1f88f87b29186b57b38f341fe36121ac59a0cd Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:01:16 -0400 Subject: Include unistd.h for usleep on MinGW --- libs/midi++2/jack_midi_port.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/midi++2/jack_midi_port.cc b/libs/midi++2/jack_midi_port.cc index e1a68b6475..57ca2b3629 100644 --- a/libs/midi++2/jack_midi_port.cc +++ b/libs/midi++2/jack_midi_port.cc @@ -19,6 +19,7 @@ */ #include #include +#include #include #include -- cgit v1.2.3 From 2b9f50ffc75cae6b27199a5a1ca6221a3f36aa7d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:03:24 -0400 Subject: include winsock2.h on windows in libsmf for htons/l etc. --- libs/evoral/src/libsmf/smf.c | 4 ++++ libs/evoral/src/libsmf/smf_decode.c | 4 ++++ libs/evoral/src/libsmf/smf_load.c | 4 ++++ libs/evoral/src/libsmf/smf_save.c | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/libs/evoral/src/libsmf/smf.c b/libs/evoral/src/libsmf/smf.c index b79d7543b6..d01c9bf148 100644 --- a/libs/evoral/src/libsmf/smf.c +++ b/libs/evoral/src/libsmf/smf.c @@ -39,7 +39,11 @@ #include #include #include +#ifdef WIN32 +#include +#else #include +#endif #include "smf.h" #include "smf_private.h" diff --git a/libs/evoral/src/libsmf/smf_decode.c b/libs/evoral/src/libsmf/smf_decode.c index 0951a6e2f8..dc152d37a5 100644 --- a/libs/evoral/src/libsmf/smf_decode.c +++ b/libs/evoral/src/libsmf/smf_decode.c @@ -37,7 +37,11 @@ #include #include #include +#ifdef WIN32 +#include +#else #include +#endif #include #include "smf.h" #include "smf_private.h" diff --git a/libs/evoral/src/libsmf/smf_load.c b/libs/evoral/src/libsmf/smf_load.c index 6da6036ea0..4215d03e43 100644 --- a/libs/evoral/src/libsmf/smf_load.c +++ b/libs/evoral/src/libsmf/smf_load.c @@ -40,7 +40,11 @@ #include #include #include +#ifdef WIN32 +#include +#else #include +#endif #include "smf.h" #include "smf_private.h" diff --git a/libs/evoral/src/libsmf/smf_save.c b/libs/evoral/src/libsmf/smf_save.c index b99af75461..2cceba1ce2 100644 --- a/libs/evoral/src/libsmf/smf_save.c +++ b/libs/evoral/src/libsmf/smf_save.c @@ -39,7 +39,11 @@ #include #include #include +#ifdef WIN32 +#include +#else #include +#endif #include "smf.h" #include "smf_private.h" -- cgit v1.2.3 From 350bd56a069a2b350a4e714c9372c448348cee3d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:03:55 -0400 Subject: Fix evoral test to compile with mingw --- libs/evoral/test/SMFTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/evoral/test/SMFTest.cpp b/libs/evoral/test/SMFTest.cpp index d4b2a28aff..fe9efa479f 100644 --- a/libs/evoral/test/SMFTest.cpp +++ b/libs/evoral/test/SMFTest.cpp @@ -1,5 +1,9 @@ #include "SMFTest.hpp" +#ifdef WIN32 +#include // for R_OK +#endif + using namespace std; CPPUNIT_TEST_SUITE_REGISTRATION( SMFTest ); -- cgit v1.2.3 From 0c3bbd41dd34460e033117a5b2bf4523df7fbce0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:04:39 -0400 Subject: Fix for mingw compiler --- libs/rubberband/src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/rubberband/src/main.cpp b/libs/rubberband/src/main.cpp index 1c80696180..178685300b 100644 --- a/libs/rubberband/src/main.cpp +++ b/libs/rubberband/src/main.cpp @@ -495,7 +495,11 @@ int main(int argc, char **argv) } delete[] obf; } else { +#ifdef WIN32 + RubberBand::usleep(10000); +#else usleep(10000); +#endif } } -- cgit v1.2.3 From 27a5a589ed2dd177143d56e70437e969b46ca33f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:05:24 -0400 Subject: INFINITE is defined via windows.h so undefine it --- libs/ardour/ardour/chan_count.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/ardour/ardour/chan_count.h b/libs/ardour/ardour/chan_count.h index c4f3caef6b..03e2fcd8ff 100644 --- a/libs/ardour/ardour/chan_count.h +++ b/libs/ardour/ardour/chan_count.h @@ -26,6 +26,10 @@ #include "pbd/xml++.h" #include "ardour/data_type.h" +#ifdef INFINITE +#undef INFINITE +#endif + namespace ARDOUR { -- cgit v1.2.3 From 157b0e385af29f1158fa9c90130a0cfbe800910f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:52:29 -0400 Subject: Disable peakfile reading and writing on windows for now There is no point trying to implement this until it can be tested --- libs/ardour/audiosource.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index e11fe1c4fa..da9be81007 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -392,7 +392,9 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t cerr << "DIRECT PEAKS\n"; #endif +#ifndef WIN32 nread = ::pread (peakfile_fd, peaks, sizeof (PeakData)* npeaks, first_peak_byte); +#endif if (nread != sizeof (PeakData) * npeaks) { cerr << "AudioSource[" @@ -477,6 +479,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t cerr << "read " << sizeof (PeakData) * to_read << " from peakfile @ " << start_byte << endl; #endif +#ifndef WIN32 if ((nread = ::pread (peakfile_fd, staging, sizeof (PeakData) * to_read, start_byte)) != sizeof (PeakData) * to_read) { @@ -498,7 +501,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t << endl; goto out; } - +#endif i = 0; stored_peaks_read = nread / sizeof(PeakData); } @@ -768,11 +771,12 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame off_t byte = (peak_leftover_frame / fpp) * sizeof (PeakData); +#ifndef WIN32 if (::pwrite (_peakfile_fd, &x, sizeof (PeakData), byte) != sizeof (PeakData)) { error << string_compose(_("%1: could not write peak file data (%2)"), _name, strerror (errno)) << endmsg; goto out; } - +#endif _peak_byte_max = max (_peak_byte_max, (off_t) (byte + sizeof(PeakData))); { @@ -881,10 +885,12 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame } } +#ifndef WIN32 if (::pwrite (_peakfile_fd, peakbuf, sizeof (PeakData) * peaks_computed, first_peak_byte) != (ssize_t) (sizeof (PeakData) * peaks_computed)) { error << string_compose(_("%1: could not write peak file data (%2)"), _name, strerror (errno)) << endmsg; goto out; } +#endif _peak_byte_max = max (_peak_byte_max, (off_t) (first_peak_byte + sizeof(PeakData)*peaks_computed)); -- cgit v1.2.3 From 0e513f04694c773b47dd5b03daa07842598ac8b6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:53:12 -0400 Subject: Include header that declares ::free for mingw build --- libs/audiographer/audiographer/debug_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/audiographer/audiographer/debug_utils.h b/libs/audiographer/audiographer/debug_utils.h index a1d8259716..7b9e50124a 100644 --- a/libs/audiographer/audiographer/debug_utils.h +++ b/libs/audiographer/audiographer/debug_utils.h @@ -7,6 +7,7 @@ #ifdef __GNUC__ #include +#include #endif namespace AudioGrapher -- cgit v1.2.3 From ef9ed302e3365aee9207054dd9e4382fb49adc8d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:53:35 -0400 Subject: Add necessary header include for int64_t type --- libs/audiographer/audiographer/broadcast_info.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/audiographer/audiographer/broadcast_info.h b/libs/audiographer/audiographer/broadcast_info.h index c111156c82..819978f8c6 100644 --- a/libs/audiographer/audiographer/broadcast_info.h +++ b/libs/audiographer/audiographer/broadcast_info.h @@ -21,6 +21,8 @@ #ifndef AUDIOGRAPHER_BROADCAST_INFO_H #define AUDIOGRAPHER_BROADCAST_INFO_H +#include + #include #include -- cgit v1.2.3 From 058ebf98b928f735ac2dbd5026a4dcf3fba3e67b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:55:03 -0400 Subject: Disable increasing open file limit on windows --- libs/ardour/globals.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 4c91956ffd..cc427f7428 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -25,7 +25,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include #include @@ -193,6 +195,7 @@ setup_hardware_optimization (bool try_optimization) static void lotsa_files_please () { +#ifndef WIN32 struct rlimit rl; if (getrlimit (RLIMIT_NOFILE, &rl) == 0) { @@ -213,6 +216,7 @@ lotsa_files_please () } else { error << string_compose (_("Could not get system open files limit (%1)"), strerror (errno)) << endmsg; } +#endif } int -- cgit v1.2.3 From 83ed3d7dcc121bb7947d7532c869ccf3e0510b86 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 13:58:48 -0400 Subject: Use glibmm for modules instead of dlfch.h --- libs/ardour/ardour/ladspa_plugin.h | 9 ++++---- libs/ardour/ardour/panner_manager.h | 11 ++++----- libs/ardour/control_protocol_manager.cc | 36 ++++++++++++++++------------- libs/ardour/ladspa_plugin.cc | 40 +++++++++++++++------------------ libs/ardour/panner_manager.cc | 22 +++++++++--------- libs/ardour/plugin_manager.cc | 18 +++++++-------- 6 files changed, 71 insertions(+), 65 deletions(-) diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h index 6853a1dc36..62cad017fc 100644 --- a/libs/ardour/ardour/ladspa_plugin.h +++ b/libs/ardour/ardour/ladspa_plugin.h @@ -23,8 +23,8 @@ #include #include #include -#include +#include #include "pbd/stateful.h" @@ -39,7 +39,7 @@ class Session; class LadspaPlugin : public ARDOUR::Plugin { public: - LadspaPlugin (void *module, ARDOUR::AudioEngine&, ARDOUR::Session&, uint32_t index, framecnt_t sample_rate); + LadspaPlugin (std::string module_path, ARDOUR::AudioEngine&, ARDOUR::Session&, uint32_t index, framecnt_t sample_rate); LadspaPlugin (const LadspaPlugin &); ~LadspaPlugin (); @@ -122,7 +122,8 @@ class LadspaPlugin : public ARDOUR::Plugin void connect_port (uint32_t port, float *ptr) { _descriptor->connect_port (_handle, port, ptr); } private: - void* _module; + std::string _module_path; + Glib::Module* _module; const LADSPA_Descriptor* _descriptor; LADSPA_Handle _handle; framecnt_t _sample_rate; @@ -134,7 +135,7 @@ class LadspaPlugin : public ARDOUR::Plugin void find_presets (); - void init (void *mod, uint32_t index, framecnt_t rate); + void init (std::string module_path, uint32_t index, framecnt_t rate); void run_in_place (pframes_t nsamples); void latency_compute_run (); int set_state_2X (const XMLNode&, int version); diff --git a/libs/ardour/ardour/panner_manager.h b/libs/ardour/ardour/panner_manager.h index 016ba56ce3..c34d22285d 100644 --- a/libs/ardour/ardour/panner_manager.h +++ b/libs/ardour/ardour/panner_manager.h @@ -20,7 +20,8 @@ #ifndef __ardour_panner_manager_h__ #define __ardour_panner_manager_h__ -#include +#include + #include "ardour/panner.h" #include "ardour/session_handle.h" @@ -28,15 +29,15 @@ namespace ARDOUR { struct PannerInfo { PanPluginDescriptor descriptor; - void* module; + Glib::Module* module; - PannerInfo (PanPluginDescriptor& d, void* handle) + PannerInfo (PanPluginDescriptor& d, Glib::Module* m) : descriptor (d) - , module (handle) + , module (m) {} ~PannerInfo () { - dlclose (module); + delete module; } }; diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 2e65a8d6f8..3ccc1f134b 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -17,7 +17,7 @@ */ -#include +#include #include @@ -29,8 +29,14 @@ #include "ardour/debug.h" #include "ardour/control_protocol_manager.h" + +#ifdef SearchPath +#undef SearchPath +#endif + #include "ardour/control_protocol_search_path.h" + using namespace ARDOUR; using namespace std; using namespace PBD; @@ -179,7 +185,7 @@ ControlProtocolManager::teardown (ControlProtocolInfo& cpi) cpi.protocol = 0; delete cpi.state; cpi.state = 0; - dlclose (cpi.descriptor->module); + delete (Glib::Module*)cpi.descriptor->module; ProtocolStatusChange (&cpi); @@ -264,7 +270,7 @@ ControlProtocolManager::control_protocol_discover (string path) string_compose(_("Control surface protocol discovered: \"%1\"\n"), cpi->name)); } - dlclose (descriptor->module); + delete (Glib::Module*)descriptor->module; } return 0; @@ -273,31 +279,31 @@ ControlProtocolManager::control_protocol_discover (string path) ControlProtocolDescriptor* ControlProtocolManager::get_descriptor (string path) { - void *module; + Glib::Module* module = new Glib::Module(path); ControlProtocolDescriptor *descriptor = 0; ControlProtocolDescriptor* (*dfunc)(void); - const char *errstr; + void* func = 0; - if ((module = dlopen (path.c_str(), RTLD_NOW)) == 0) { - error << string_compose(_("ControlProtocolManager: cannot load module \"%1\" (%2)"), path, dlerror()) << endmsg; + if (!(*module)) { + error << string_compose(_("ControlProtocolManager: cannot load module \"%1\" (%2)"), path, Glib::Module::get_last_error()) << endmsg; + delete module; return 0; } - - dfunc = (ControlProtocolDescriptor* (*)(void)) dlsym (module, "protocol_descriptor"); - - if ((errstr = dlerror()) != 0) { + if (!module->get_symbol("protocol_descriptor", func)) { error << string_compose(_("ControlProtocolManager: module \"%1\" has no descriptor function."), path) << endmsg; - error << errstr << endmsg; - dlclose (module); + error << Glib::Module::get_last_error() << endmsg; + delete module; return 0; } + dfunc = (ControlProtocolDescriptor* (*)(void))func; descriptor = dfunc(); + if (descriptor) { - descriptor->module = module; + descriptor->module = (void*)module; } else { - dlclose (module); + delete module; } return descriptor; diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index cebff59771..b306269276 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -51,16 +51,16 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -LadspaPlugin::LadspaPlugin (void *mod, AudioEngine& e, Session& session, uint32_t index, framecnt_t rate) +LadspaPlugin::LadspaPlugin (string module_path, AudioEngine& e, Session& session, uint32_t index, framecnt_t rate) : Plugin (e, session) { - init (mod, index, rate); + init (module_path, index, rate); } LadspaPlugin::LadspaPlugin (const LadspaPlugin &other) : Plugin (other) { - init (other._module, other._index, other._sample_rate); + init (other._module_path, other._index, other._sample_rate); for (uint32_t i = 0; i < parameter_count(); ++i) { _control_data[i] = other._shadow_data[i]; @@ -69,25 +69,32 @@ LadspaPlugin::LadspaPlugin (const LadspaPlugin &other) } void -LadspaPlugin::init (void *mod, uint32_t index, framecnt_t rate) +LadspaPlugin::init (string module_path, uint32_t index, framecnt_t rate) { + void* func; LADSPA_Descriptor_Function dfunc; uint32_t i, port_cnt; - const char *errstr; - _module = mod; + _module_path = module_path; + _module = new Glib::Module(_module_path); _control_data = 0; _shadow_data = 0; _latency_control_port = 0; _was_activated = false; - dfunc = (LADSPA_Descriptor_Function) dlsym (_module, "ladspa_descriptor"); + if (!(*_module)) { + error << _("LADSPA: Unable to open module: ") << Glib::Module::get_last_error() << endmsg; + delete _module; + throw failed_constructor(); + } - if ((errstr = dlerror()) != NULL) { + if (!_module->get_symbol("ladspa_descriptor", func)) { error << _("LADSPA: module has no descriptor function.") << endmsg; throw failed_constructor(); } + dfunc = (LADSPA_Descriptor_Function)func; + if ((_descriptor = dfunc (index)) == 0) { error << _("LADSPA: plugin has gone away since discovery!") << endmsg; throw failed_constructor(); @@ -141,9 +148,8 @@ LadspaPlugin::~LadspaPlugin () deactivate (); cleanup (); - /* XXX who should close a plugin? */ - - // dlclose (module); + // glib has internal reference counting on modules so this is ok + delete _module; delete [] _control_data; delete [] _shadow_data; @@ -700,17 +706,7 @@ PluginPtr LadspaPluginInfo::load (Session& session) { try { - PluginPtr plugin; - void *module; - - if ((module = dlopen (path.c_str(), RTLD_NOW)) == 0) { - error << string_compose(_("LADSPA: cannot load module from \"%1\""), path) << endmsg; - error << dlerror() << endmsg; - return PluginPtr ((Plugin*) 0); - } else { - plugin.reset (new LadspaPlugin (module, session.engine(), session, index, session.frame_rate())); - } - + PluginPtr plugin (new LadspaPlugin (path, session.engine(), session, index, session.frame_rate())); plugin->set_info(PluginInfoPtr(new LadspaPluginInfo(*this))); return plugin; } diff --git a/libs/ardour/panner_manager.cc b/libs/ardour/panner_manager.cc index c3601d41de..e77104dd33 100644 --- a/libs/ardour/panner_manager.cc +++ b/libs/ardour/panner_manager.cc @@ -106,31 +106,33 @@ PannerManager::panner_discover (string path) PannerInfo* PannerManager::get_descriptor (string path) { - void *module; + Glib::Module* module = new Glib::Module(path); PannerInfo* info = 0; PanPluginDescriptor *descriptor = 0; PanPluginDescriptor* (*dfunc)(void); - const char *errstr; + void* func = 0; - if ((module = dlopen (path.c_str(), RTLD_NOW)) == 0) { - error << string_compose(_("PannerManager: cannot load module \"%1\" (%2)"), path, dlerror()) << endmsg; + if (!module) { + error << string_compose(_("PannerManager: cannot load module \"%1\" (%2)"), path, + Glib::Module::get_last_error()) << endmsg; + delete module; return 0; } - dfunc = (PanPluginDescriptor* (*)(void)) dlsym (module, "panner_descriptor"); - - if ((errstr = dlerror()) != 0) { + if (!module->get_symbol("panner_descriptor", func)) { error << string_compose(_("PannerManager: module \"%1\" has no descriptor function."), path) << endmsg; - error << errstr << endmsg; - dlclose (module); + error << Glib::Module::get_last_error() << endmsg; + delete module; return 0; } + dfunc = (PanPluginDescriptor* (*)(void))func; descriptor = dfunc(); + if (descriptor) { info = new PannerInfo (*descriptor, module); } else { - dlclose (module); + delete module; } return info; diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 90522a7e06..a3a7fb48da 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -365,25 +364,26 @@ PluginManager::add_lrdf_data (const string &path) int PluginManager::ladspa_discover (string path) { - void *module; + Glib::Module module(path); const LADSPA_Descriptor *descriptor; LADSPA_Descriptor_Function dfunc; - const char *errstr; + void* func = 0; - if ((module = dlopen (path.c_str(), RTLD_NOW)) == 0) { - error << string_compose(_("LADSPA: cannot load module \"%1\" (%2)"), path, dlerror()) << endmsg; + if (!module) { + error << string_compose(_("LADSPA: cannot load module \"%1\" (%2)"), + path, Glib::Module::get_last_error()) << endmsg; return -1; } - dfunc = (LADSPA_Descriptor_Function) dlsym (module, "ladspa_descriptor"); - if ((errstr = dlerror()) != 0) { + if (!module.get_symbol("ladspa_descriptor", func)) { error << string_compose(_("LADSPA: module \"%1\" has no descriptor function."), path) << endmsg; - error << errstr << endmsg; - dlclose (module); + error << Glib::Module::get_last_error() << endmsg; return -1; } + dfunc = (LADSPA_Descriptor_Function)func; + for (uint32_t i = 0; ; ++i) { if ((descriptor = dfunc (i)) == 0) { break; -- cgit v1.2.3 From 1b21eec042ca3c689cfeddbef9d00d1fa653079a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:13:55 -0400 Subject: Fix for ambiguity of UUID type on windows --- libs/ardour/export_profile_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/export_profile_manager.cc b/libs/ardour/export_profile_manager.cc index 42e494c0cb..7ff4282c74 100644 --- a/libs/ardour/export_profile_manager.cc +++ b/libs/ardour/export_profile_manager.cc @@ -685,7 +685,7 @@ ExportProfileManager::FormatStatePtr ExportProfileManager::deserialize_format (XMLNode & root) { XMLProperty * prop; - UUID id; + PBD::UUID id; if ((prop = root.property ("id"))) { id = prop->value(); -- cgit v1.2.3 From 742753a9969f443e4a548fc11d3ed82efe74f5e9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:20:02 -0400 Subject: Don't require liblrdf on windows This removes dependence on liblrdf, libraptor and libxslt --- gtk2_ardour/generic_pluginui.cc | 2 -- gtk2_ardour/plugin_selector.cc | 1 - gtk2_ardour/plugin_ui.cc | 2 -- libs/ardour/audio_library.cc | 18 +++++++++++++++++- libs/ardour/globals.cc | 6 ++++++ libs/ardour/ladspa_plugin.cc | 26 +++++++++++++++++++++++++- libs/ardour/plugin.cc | 2 ++ libs/ardour/plugin_manager.cc | 14 ++++++++++++-- 8 files changed, 62 insertions(+), 9 deletions(-) diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index 52bb468a67..c66a1fec38 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -43,8 +43,6 @@ #include "ardour/plugin_insert.h" #include "ardour/session.h" -#include - #include "ardour_ui.h" #include "prompter.h" #include "plugin_ui.h" diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc index 81adf40896..2a031318ff 100644 --- a/gtk2_ardour/plugin_selector.cc +++ b/gtk2_ardour/plugin_selector.cc @@ -21,7 +21,6 @@ #endif #include -#include #include #include diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index d9741f5e39..c19738f02f 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -59,8 +59,6 @@ #include "lv2_plugin_ui.h" #endif -#include - #include "ardour_window.h" #include "ardour_ui.h" #include "prompter.h" diff --git a/libs/ardour/audio_library.cc b/libs/ardour/audio_library.cc index c2b2f1bff7..4a6089dac3 100644 --- a/libs/ardour/audio_library.cc +++ b/libs/ardour/audio_library.cc @@ -17,11 +17,18 @@ */ +#ifdef WAF_BUILD +#include "libardour-config.h" +#endif + #include #include +#ifdef HAVE_LRDF #include +#endif + #include #include @@ -57,7 +64,9 @@ AudioLibrary::AudioLibrary () touch_file(sfdb_file_path); +#ifdef HAVE_LRDF lrdf_read_file(src.c_str()); +#endif } AudioLibrary::~AudioLibrary () @@ -67,14 +76,17 @@ AudioLibrary::~AudioLibrary () void AudioLibrary::save_changes () { +#ifdef HAVE_LRDF if (lrdf_export_by_source(src.c_str(), src.substr(5).c_str())) { PBD::warning << string_compose(_("Could not open %1. Audio Library not saved"), src) << endmsg; } +#endif } void AudioLibrary::set_tags (string member, vector tags) { +#ifdef HAVE_LRDF sort (tags.begin(), tags.end()); tags.erase (unique(tags.begin(), tags.end()), tags.end()); @@ -85,12 +97,14 @@ AudioLibrary::set_tags (string member, vector tags) for (vector::iterator i = tags.begin(); i != tags.end(); ++i) { lrdf_add_triple (src.c_str(), file_uri.c_str(), TAG, (*i).c_str(), lrdf_literal); } +#endif } vector AudioLibrary::get_tags (string member) { vector tags; +#ifdef HAVE_LRDF lrdf_statement pattern; pattern.subject = strdup(Glib::filename_to_uri(member).c_str()); @@ -111,13 +125,14 @@ AudioLibrary::get_tags (string member) lrdf_free_statements (matches); sort (tags.begin(), tags.end()); - +#endif return tags; } void AudioLibrary::search_members_and (vector& members, const vector& tags) { +#ifdef HAVE_LRDF lrdf_statement **head; lrdf_statement* pattern = 0; lrdf_statement* old = 0; @@ -153,4 +168,5 @@ AudioLibrary::search_members_and (vector& members, const vector& pattern = pattern->next; delete old; } +#endif } diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index cc427f7428..fe07332d85 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -57,7 +57,9 @@ #include #include +#ifdef HAVE_LRDF #include +#endif #include "pbd/cpus.h" #include "pbd/error.h" @@ -265,7 +267,9 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization, const char* localedir // allow ardour the absolute maximum number of open files lotsa_files_please (); +#ifdef HAVE_LRDF lrdf_init(); +#endif Library = new AudioLibrary; BootMessage (_("Loading configuration")); @@ -360,7 +364,9 @@ int ARDOUR::cleanup () { delete Library; +#ifdef HAVE_LRDF lrdf_cleanup (); +#endif delete &ControlProtocolManager::instance(); #ifdef WINDOWS_VST_SUPPORT fst_exit (); diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index b306269276..6ee810f6b1 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -17,6 +17,10 @@ */ +#ifdef WAF_BUILD +#include "libardour-config.h" +#endif + #include #include @@ -29,7 +33,9 @@ #include #include +#ifdef HAVE_LRDF #include +#endif #include "pbd/compose.h" #include "pbd/error.h" @@ -625,10 +631,11 @@ LadspaPlugin::print_parameter (uint32_t param, char *buf, uint32_t len) const boost::shared_ptr LadspaPlugin::get_scale_points(uint32_t port_index) const { + boost::shared_ptr ret; +#ifdef HAVE_LRDF const uint32_t id = atol(unique_id().c_str()); lrdf_defaults* points = lrdf_get_scale_values(id, port_index); - boost::shared_ptr ret; if (!points) { return ret; } @@ -641,6 +648,7 @@ LadspaPlugin::get_scale_points(uint32_t port_index) const } lrdf_free_setting_values(points); +#endif return ret; } @@ -725,6 +733,7 @@ LadspaPluginInfo::LadspaPluginInfo() void LadspaPlugin::find_presets () { +#ifdef HAVE_LRDF uint32_t id; std::string unique (unique_id()); @@ -745,12 +754,14 @@ LadspaPlugin::find_presets () } lrdf_free_uris(set_uris); } +#endif } bool LadspaPlugin::load_preset (PresetRecord r) { +#ifdef HAVE_LRDF lrdf_defaults* defs = lrdf_get_setting_values (r.uri.c_str()); if (defs) { @@ -763,6 +774,7 @@ LadspaPlugin::load_preset (PresetRecord r) } Plugin::load_preset (r); +#endif return true; } @@ -770,6 +782,7 @@ LadspaPlugin::load_preset (PresetRecord r) static void lrdf_remove_preset (const char* /*source*/, const char *setting_uri) { +#ifdef HAVE_LRDF lrdf_statement p; lrdf_statement *q; lrdf_statement *i; @@ -803,11 +816,13 @@ lrdf_remove_preset (const char* /*source*/, const char *setting_uri) p.predicate = NULL; p.object = NULL; lrdf_remove_matches (&p); +#endif } void LadspaPlugin::do_remove_preset (string name) { +#ifdef HAVE_LRDF string const envvar = preset_envvar (); if (envvar.empty()) { warning << _("Could not locate HOME. Preset not removed.") << endmsg; @@ -823,6 +838,7 @@ LadspaPlugin::do_remove_preset (string name) lrdf_remove_preset (source.c_str(), p->uri.c_str ()); write_preset_file (envvar); +#endif } string @@ -845,6 +861,7 @@ LadspaPlugin::preset_source (string envvar) const bool LadspaPlugin::write_preset_file (string envvar) { +#ifdef HAVE_LRDF string path = string_compose("%1/.ladspa", envvar); if (g_mkdir_with_parents (path.c_str(), 0775)) { warning << string_compose(_("Could not create %1. Preset not saved. (%2)"), path, strerror(errno)) << endmsg; @@ -865,11 +882,15 @@ LadspaPlugin::write_preset_file (string envvar) } return true; +#else + return false; +#endif } string LadspaPlugin::do_save_preset (string name) { +#ifdef HAVE_LRDF /* make a vector of pids that are input parameters */ vector input_parameter_pids; for (uint32_t i = 0; i < parameter_count(); ++i) { @@ -913,6 +934,9 @@ LadspaPlugin::do_save_preset (string name) } return uri; +#else + return string(); +#endif } LADSPA_PortDescriptor diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc index e76353e8d5..ec9e333285 100644 --- a/libs/ardour/plugin.cc +++ b/libs/ardour/plugin.cc @@ -32,7 +32,9 @@ #include #include +#ifdef HAVE_LRDF #include +#endif #include "pbd/compose.h" #include "pbd/error.h" diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index a3a7fb48da..6ea0292872 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -25,10 +25,13 @@ #include #include -#include #include #include +#ifdef HAVE_LRDF +#include +#endif + #ifdef WINDOWS_VST_SUPPORT #include "fst.h" #include "pbd/basename.h" @@ -314,7 +317,7 @@ PluginManager::add_lxvst_presets() void PluginManager::add_presets(string domain) { - +#ifdef HAVE_LRDF PathScanner scanner; vector *presets; vector::iterator x; @@ -337,11 +340,13 @@ PluginManager::add_presets(string domain) vector_delete (presets); } +#endif } void PluginManager::add_lrdf_data (const string &path) { +#ifdef HAVE_LRDF PathScanner scanner; vector* rdf_files; vector::iterator x; @@ -359,6 +364,7 @@ PluginManager::add_lrdf_data (const string &path) vector_delete (rdf_files); } +#endif } int @@ -448,6 +454,7 @@ PluginManager::ladspa_discover (string path) string PluginManager::get_ladspa_category (uint32_t plugin_id) { +#ifdef HAVE_LRDF char buf[256]; lrdf_statement pattern; @@ -505,6 +512,9 @@ PluginManager::get_ladspa_category (uint32_t plugin_id) } else { return label; } +#else + return ("Unknown"); +#endif } #ifdef LV2_SUPPORT -- cgit v1.2.3 From 4d71933f5ba09af4dfb79459798611994ca60b8f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:23:20 -0400 Subject: Add cast for mingw compiler --- libs/ardour/meter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/meter.cc b/libs/ardour/meter.cc index f239a1c4b7..304bffe5c9 100644 --- a/libs/ardour/meter.cc +++ b/libs/ardour/meter.cc @@ -269,7 +269,7 @@ PeakMeter::meter () } else { // do falloff new_peak = _visible_peak_power[n] - (Config->get_meter_falloff() * 0.01f); - _visible_peak_power[n] = std::max (new_peak, -INFINITY); + _visible_peak_power[n] = std::max (new_peak, (float)-INFINITY); } } } -- cgit v1.2.3 From b6afce39a40f5a6f06de665c242d96934b7e3f8e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:27:24 -0400 Subject: Undef SearchPath where needed as it is defined via windows.h This is pretty annoying, might even be worth renaming the class --- libs/ardour/ardour/export_profile_manager.h | 4 ++++ libs/ardour/ardour/filesystem_paths.h | 4 ++++ libs/ardour/panner_manager.cc | 5 +++++ libs/ardour/template_utils.cc | 4 ++++ libs/pbd/pbd/search_path.h | 4 ++++ 5 files changed, 21 insertions(+) diff --git a/libs/ardour/ardour/export_profile_manager.h b/libs/ardour/ardour/export_profile_manager.h index 424e0fe163..114fb09647 100644 --- a/libs/ardour/ardour/export_profile_manager.h +++ b/libs/ardour/ardour/export_profile_manager.h @@ -38,6 +38,10 @@ #include "ardour/types.h" #include "ardour/export_handler.h" +#ifdef SearchPath +#undef SearchPath +#endif + namespace ARDOUR { diff --git a/libs/ardour/ardour/filesystem_paths.h b/libs/ardour/ardour/filesystem_paths.h index cfeb633597..7c817e86a1 100644 --- a/libs/ardour/ardour/filesystem_paths.h +++ b/libs/ardour/ardour/filesystem_paths.h @@ -22,6 +22,10 @@ #include "pbd/search_path.h" +#ifdef SearchPath +#undef SearchPath +#endif + namespace ARDOUR { /** diff --git a/libs/ardour/panner_manager.cc b/libs/ardour/panner_manager.cc index e77104dd33..06fc42aab9 100644 --- a/libs/ardour/panner_manager.cc +++ b/libs/ardour/panner_manager.cc @@ -28,6 +28,11 @@ #include "ardour/debug.h" #include "ardour/panner_manager.h" + +#ifdef SearchPath +#undef SearchPath +#endif + #include "ardour/panner_search_path.h" #include "i18n.h" diff --git a/libs/ardour/template_utils.cc b/libs/ardour/template_utils.cc index 05007b0ade..c57f2400ac 100644 --- a/libs/ardour/template_utils.cc +++ b/libs/ardour/template_utils.cc @@ -32,6 +32,10 @@ #include "ardour/filename_extensions.h" #include "ardour/io.h" +#ifdef SearchPath +#undef SearchPath +#endif + using namespace std; using namespace PBD; diff --git a/libs/pbd/pbd/search_path.h b/libs/pbd/pbd/search_path.h index 5358d6e14c..cc53dbebac 100644 --- a/libs/pbd/pbd/search_path.h +++ b/libs/pbd/pbd/search_path.h @@ -20,6 +20,10 @@ #ifndef PBD_SEARCH_PATH_INCLUDED #define PBD_SEARCH_PATH_INCLUDED +#ifdef SearchPath +#undef SearchPath +#endif + #include #include -- cgit v1.2.3 From 2218a70d376586633451134cb790b5c8d794e431 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:30:38 -0400 Subject: Add timersub macro for platforms where it isn't defined --- libs/pbd/pbd/timersub.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 libs/pbd/pbd/timersub.h diff --git a/libs/pbd/pbd/timersub.h b/libs/pbd/pbd/timersub.h new file mode 100644 index 0000000000..6cb152414c --- /dev/null +++ b/libs/pbd/pbd/timersub.h @@ -0,0 +1,32 @@ +/* Copyright (C) 1991-1994,1996-2003,2005,2006,2009 + Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#ifndef timersub +# define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + -- cgit v1.2.3 From 6a8901eb8d5feadf9ff9e3adac7197d3dd5ca464 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:31:15 -0400 Subject: Include pbd/timersub.h in session_midi.cc --- libs/ardour/session_midi.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 9feaa1fb2b..5b5554be7c 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -33,6 +33,7 @@ #include "pbd/error.h" #include "pbd/pthread_utils.h" +#include "pbd/timersub.h" #include "timecode/time.h" -- cgit v1.2.3 From 0f1ed673d055205569513d372f9ae35a447a485f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:35:26 -0400 Subject: Move request pipe setup into separate function --- libs/ardour/ardour/butler.h | 2 ++ libs/ardour/butler.cc | 41 ++++++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/libs/ardour/ardour/butler.h b/libs/ardour/ardour/butler.h index cdd48c3e3a..321755197c 100644 --- a/libs/ardour/ardour/butler.h +++ b/libs/ardour/ardour/butler.h @@ -80,6 +80,8 @@ class Butler : public SessionHandleRef private: void empty_pool_trash (); void config_changed (std::string); + + int setup_request_pipe (); }; } // namespace ARDOUR diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index db1b316368..38ffef6fbc 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -69,24 +69,8 @@ Butler::config_changed (std::string p) } int -Butler::start_thread() +Butler::setup_request_pipe () { - const float rate = (float)_session.frame_rate(); - - /* size is in Samples, not bytes */ - audio_dstream_capture_buffer_size = (uint32_t) floor (Config->get_audio_capture_buffer_seconds() * rate); - audio_dstream_playback_buffer_size = (uint32_t) floor (Config->get_audio_playback_buffer_seconds() * rate); - - /* size is in bytes - * XXX: Jack needs to tell us the MIDI buffer size - * (i.e. how many MIDI bytes we might see in a cycle) - */ - midi_dstream_buffer_size = (uint32_t) floor (Config->get_midi_track_buffer_seconds() * rate); - - MidiDiskstream::set_readahead_frames ((framecnt_t) (Config->get_midi_readahead() * rate)); - - should_run = false; - if (pipe (request_pipe)) { error << string_compose(_("Cannot create transport request signal pipe (%1)"), strerror (errno)) << endmsg; @@ -104,6 +88,29 @@ Butler::start_thread() strerror (errno)) << endmsg; return -1; } + return 0; +} + +int +Butler::start_thread() +{ + const float rate = (float)_session.frame_rate(); + + /* size is in Samples, not bytes */ + audio_dstream_capture_buffer_size = (uint32_t) floor (Config->get_audio_capture_buffer_seconds() * rate); + audio_dstream_playback_buffer_size = (uint32_t) floor (Config->get_audio_playback_buffer_seconds() * rate); + + /* size is in bytes + * XXX: Jack needs to tell us the MIDI buffer size + * (i.e. how many MIDI bytes we might see in a cycle) + */ + midi_dstream_buffer_size = (uint32_t) floor (Config->get_midi_track_buffer_seconds() * rate); + + MidiDiskstream::set_readahead_frames ((framecnt_t) (Config->get_midi_readahead() * rate)); + + should_run = false; + + if (setup_request_pipe() != 0) return -1; if (pthread_create_and_store ("disk butler", &thread, _thread_work, this)) { error << _("Session: could not create butler thread") << endmsg; -- cgit v1.2.3 From dd55df80f0376e587ebf6f389a6ae5722b56561f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:36:43 -0400 Subject: Refactor the non-portable parts of Butler thread into new functions --- libs/ardour/ardour/butler.h | 18 +++++++++ libs/ardour/butler.cc | 90 ++++++++++++++++++++++++++++----------------- 2 files changed, 74 insertions(+), 34 deletions(-) diff --git a/libs/ardour/ardour/butler.h b/libs/ardour/ardour/butler.h index 321755197c..8799899004 100644 --- a/libs/ardour/ardour/butler.h +++ b/libs/ardour/ardour/butler.h @@ -82,6 +82,24 @@ private: void config_changed (std::string); int setup_request_pipe (); + + /** + * return true if there are requests to be processed + */ + bool wait_for_requests (); + + /** + * Remove request from butler request queue + * + * return true if there was another request and req is valid + */ + bool dequeue_request (Request::Type& req); + + /** + * Add request to butler thread request queue + */ + void queue_request (Request::Type r); + }; } // namespace ARDOUR diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index 38ffef6fbc..ad54e7dee7 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -127,8 +127,7 @@ Butler::terminate_thread () { if (thread) { void* status; - const char c = Request::Quit; - (void) ::write (request_pipe[1], &c, 1); + queue_request (Request::Quit); pthread_join (thread, &status); } } @@ -141,28 +140,24 @@ Butler::_thread_work (void* arg) return ((Butler *) arg)->thread_work (); } -void * -Butler::thread_work () +bool +Butler::wait_for_requests () { - uint32_t err = 0; - struct pollfd pfd[1]; - bool disk_work_outstanding = false; - RouteList::iterator i; - while (true) { - pfd[0].fd = request_pipe[0]; - pfd[0].events = POLLIN|POLLERR|POLLHUP; + pfd[0].fd = request_pipe[0]; + pfd[0].events = POLLIN|POLLERR|POLLHUP; - if (poll (pfd, 1, (disk_work_outstanding ? 0 : -1)) < 0) { + while(true) { + if (poll (pfd, 1, -1) < 0) { if (errno == EINTR) { continue; } error << string_compose (_("poll on butler request pipe failed (%1)"), - strerror (errno)) - << endmsg; + strerror (errno)) + << endmsg; break; } @@ -172,16 +167,47 @@ Butler::thread_work () } if (pfd[0].revents & POLLIN) { + return true; + } + } + return false; +} - char req; +bool +Butler::dequeue_request (Request::Type& r) +{ + char req; + size_t nread = ::read (request_pipe[0], &req, sizeof (req)); + if (nread == 1) { + r = (Request::Type) req; + return true; + } else if (nread == 0) { + return false; + } else if (errno == EAGAIN) { + return false; + } else { + fatal << _("Error reading from butler request pipe") << endmsg; + /*NOTREACHED*/ + } + return false; +} - /* empty the pipe of all current requests */ + void * +Butler::thread_work () +{ + uint32_t err = 0; + + bool disk_work_outstanding = false; + RouteList::iterator i; - while (1) { - size_t nread = ::read (request_pipe[0], &req, sizeof (req)); - if (nread == 1) { + while (true) { + if(!disk_work_outstanding) { + if (wait_for_requests ()) { + Request::Type req; - switch ((Request::Type) req) { + /* empty the pipe of all current requests */ + while(dequeue_request(req)) { + switch (req) { case Request::Run: should_run = true; @@ -199,14 +225,6 @@ Butler::thread_work () default: break; } - - } else if (nread == 0) { - break; - } else if (errno == EAGAIN) { - break; - } else { - fatal << _("Error reading from butler request pipe") << endmsg; - /*NOTREACHED*/ } } } @@ -347,18 +365,23 @@ Butler::schedule_transport_work () } void -Butler::summon () +Butler::queue_request (Request::Type r) { - char c = Request::Run; + char c = r; (void) ::write (request_pipe[1], &c, 1); } +void +Butler::summon () +{ + queue_request (Request::Run); +} + void Butler::stop () { Glib::Threads::Mutex::Lock lm (request_lock); - char c = Request::Pause; - (void) ::write (request_pipe[1], &c, 1); + queue_request (Request::Pause); paused.wait(request_lock); } @@ -366,8 +389,7 @@ void Butler::wait_until_finished () { Glib::Threads::Mutex::Lock lm (request_lock); - char c = Request::Pause; - (void) ::write (request_pipe[1], &c, 1); + queue_request (Request::Pause); paused.wait(request_lock); } -- cgit v1.2.3 From 57f3ba6a1f4f72e6257a537bc7b6a167184aa2c0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:37:27 -0400 Subject: Add wrapping class for glib atomic counter --- libs/pbd/pbd/atomic_counter.h | 99 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 libs/pbd/pbd/atomic_counter.h diff --git a/libs/pbd/pbd/atomic_counter.h b/libs/pbd/pbd/atomic_counter.h new file mode 100644 index 0000000000..1e1998e1f1 --- /dev/null +++ b/libs/pbd/pbd/atomic_counter.h @@ -0,0 +1,99 @@ +/* + Copyright (C) 2010 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef PBD_ATOMIC_COUNTER_H +#define PBD_ATOMIC_COUNTER_H + +#include + +namespace PBD { + +class atomic_counter +{ + /** + * Prevent copying and assignment + */ + atomic_counter (const atomic_counter&); + atomic_counter& operator= (const atomic_counter&); + +public: + + atomic_counter (gint value = 0) + : + m_value(value) + { } + + gint get() const + { + return g_atomic_int_get (&m_value); + } + + void set (gint new_value) + { + g_atomic_int_set (&m_value, new_value); + } + + void increment () + { + g_atomic_int_inc (&m_value); + } + + void operator++ () + { + increment (); + } + + bool decrement_and_test () + { + return g_atomic_int_dec_and_test (&m_value); + } + + bool operator-- () + { + return decrement_and_test (); + } + + bool compare_and_exchange (gint old_value, gint new_value) + { + return g_atomic_int_compare_and_exchange + ( + &m_value, + old_value, + new_value + ); + } + + /** + * convenience method, \see compare_and_exchange + */ + bool cas (gint old_value, gint new_value) + { + return compare_and_exchange (old_value, new_value); + } + +private: + + // Has to be mutable when using the apple version of gcc. + mutable volatile gint m_value; + +}; + +} // namespace PBD + +#endif // PBD_ATOMIC_COUNTER_H -- cgit v1.2.3 From 29f178aa4b1a35449ddcfcc98a1ffd9d0e648dbf Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:38:53 -0400 Subject: Add PBD::GlibSemaphore class that uses PBD::atomic_counter etc. PBD::Semaphore can really be used instead of this class now, but it didn't exist when I needed this class and it is header only, which causes some problems because windows.h is included --- libs/pbd/glib_semaphore.cc | 68 +++++++++++++++++++++++++++++++++++++++++++ libs/pbd/pbd/glib_semaphore.h | 56 +++++++++++++++++++++++++++++++++++ libs/pbd/wscript | 1 + 3 files changed, 125 insertions(+) create mode 100644 libs/pbd/glib_semaphore.cc create mode 100644 libs/pbd/pbd/glib_semaphore.h diff --git a/libs/pbd/glib_semaphore.cc b/libs/pbd/glib_semaphore.cc new file mode 100644 index 0000000000..7565e0c069 --- /dev/null +++ b/libs/pbd/glib_semaphore.cc @@ -0,0 +1,68 @@ +/* + Copyright (C) 2010 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "pbd/glib_semaphore.h" + +namespace PBD { + +GlibSemaphore::GlibSemaphore (gint initial_val) + : + m_counter(initial_val) +{ } + +void +GlibSemaphore::wait () +{ + Glib::Threads::Mutex::Lock guard (m_mutex); + + while (m_counter.get() < 1) { + m_cond.wait(m_mutex); + } + + // this shouldn't need to be inside the lock + --m_counter; +} + +bool +GlibSemaphore::try_wait () +{ + if (!m_mutex.trylock()) + { + return false; + } + // lock successful + while (m_counter.get() < 1) { + m_cond.wait(m_mutex); + } + + // the order of these should not matter + --m_counter; + m_mutex.unlock(); + return true; +} + +void +GlibSemaphore::post () +{ + // atomic, no locking required + ++m_counter; + m_cond.signal(); +} + +} // namespace PBD diff --git a/libs/pbd/pbd/glib_semaphore.h b/libs/pbd/pbd/glib_semaphore.h new file mode 100644 index 0000000000..c78226f737 --- /dev/null +++ b/libs/pbd/pbd/glib_semaphore.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2010 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef PBD_GLIB_SEMAPHORE_H +#define PBD_GLIB_SEMAPHORE_H + +#include + +#include "atomic_counter.h" + +namespace PBD { + +class GlibSemaphore +{ + + // prevent copying and assignment + GlibSemaphore(const GlibSemaphore& sema); + GlibSemaphore& operator= (const GlibSemaphore& sema); + +public: + + GlibSemaphore (gint initial_val = 1); + + void wait (); + + bool try_wait (); + + void post (); + +private: + + atomic_counter m_counter; + Glib::Threads::Cond m_cond; + Glib::Threads::Mutex m_mutex; + +}; + +} // namespace PBD + +#endif // PBD_SEMAPHORE_H diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 2057c728da..ebf7f64ab4 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -49,6 +49,7 @@ libpbd_sources = [ 'file_manager.cc', 'file_utils.cc', 'fpu.cc', + 'glib_semaphore.cc', 'id.cc', 'locale_guard.cc', 'malign.cc', -- cgit v1.2.3 From 2ddab2d2f6738f9c1dc0dd31a12cdeb6b7fe540e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:41:08 -0400 Subject: Use PBD::GlibSemaphore in Butler to signal requests on windows --- libs/ardour/ardour/butler.h | 16 +++++++++++++++- libs/ardour/butler.cc | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/libs/ardour/ardour/butler.h b/libs/ardour/ardour/butler.h index 8799899004..81159f7d3c 100644 --- a/libs/ardour/ardour/butler.h +++ b/libs/ardour/ardour/butler.h @@ -22,11 +22,17 @@ #include +#ifdef WIN32 +#include "pbd/glib_semaphore.h" +#endif + #include "pbd/ringbuffer.h" #include "pbd/pool.h" #include "ardour/types.h" #include "ardour/session_handle.h" + + namespace ARDOUR { /** @@ -71,17 +77,25 @@ class Butler : public SessionHandleRef Glib::Threads::Cond paused; bool should_run; mutable gint should_do_transport_work; - int request_pipe[2]; framecnt_t audio_dstream_capture_buffer_size; framecnt_t audio_dstream_playback_buffer_size; uint32_t midi_dstream_buffer_size; RingBuffer pool_trash; +#ifdef WIN32 + PBD::atomic_counter m_request_state; + PBD::GlibSemaphore m_request_sem; +#else + int request_pipe[2]; +#endif + private: void empty_pool_trash (); void config_changed (std::string); +#ifndef WIN32 int setup_request_pipe (); +#endif /** * return true if there are requests to be processed diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index ad54e7dee7..2998314443 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -20,7 +20,11 @@ #include #include #include + +#ifndef WIN32 #include +#endif + #include "pbd/error.h" #include "pbd/pthread_utils.h" #include "ardour/butler.h" @@ -38,7 +42,7 @@ namespace ARDOUR { Butler::Butler(Session& s) : SessionHandleRef (s) - , thread(0) + , thread() , audio_dstream_capture_buffer_size(0) , audio_dstream_playback_buffer_size(0) , midi_dstream_buffer_size(0) @@ -68,6 +72,7 @@ Butler::config_changed (std::string p) } } +#ifndef WIN32 int Butler::setup_request_pipe () { @@ -90,6 +95,7 @@ Butler::setup_request_pipe () } return 0; } +#endif int Butler::start_thread() @@ -110,7 +116,9 @@ Butler::start_thread() should_run = false; +#ifndef WIN32 if (setup_request_pipe() != 0) return -1; +#endif if (pthread_create_and_store ("disk butler", &thread, _thread_work, this)) { error << _("Session: could not create butler thread") << endmsg; @@ -125,11 +133,9 @@ Butler::start_thread() void Butler::terminate_thread () { - if (thread) { - void* status; - queue_request (Request::Quit); - pthread_join (thread, &status); - } + void* status; + queue_request (Request::Quit); + pthread_join (thread, &status); } void * @@ -143,6 +149,7 @@ Butler::_thread_work (void* arg) bool Butler::wait_for_requests () { +#ifndef WIN32 struct pollfd pfd[1]; pfd[0].fd = request_pipe[0]; @@ -171,11 +178,16 @@ Butler::wait_for_requests () } } return false; +#else + m_request_sem.wait (); + return true; +#endif } bool Butler::dequeue_request (Request::Type& r) { +#ifndef WIN32 char req; size_t nread = ::read (request_pipe[0], &req, sizeof (req)); if (nread == 1) { @@ -189,6 +201,9 @@ Butler::dequeue_request (Request::Type& r) fatal << _("Error reading from butler request pipe") << endmsg; /*NOTREACHED*/ } +#else + r = (Request::Type) m_request_state.get(); +#endif return false; } @@ -206,7 +221,12 @@ Butler::thread_work () Request::Type req; /* empty the pipe of all current requests */ +#ifdef WIN32 + dequeue_request (req); + { +#else while(dequeue_request(req)) { +#endif switch (req) { case Request::Run: @@ -367,8 +387,13 @@ Butler::schedule_transport_work () void Butler::queue_request (Request::Type r) { +#ifndef WIN32 char c = r; (void) ::write (request_pipe[1], &c, 1); +#else + m_request_state.set (r); + m_request_sem.post (); +#endif } void -- cgit v1.2.3 From 09e471545bd1c41f474e733cc404867d87e87d49 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:57:16 -0400 Subject: remove direct of realpath(2), replace with canonical_path() which is a no-op on windows --- gtk2_ardour/main.cc | 3 ++- libs/ardour/find_session.cc | 9 ++------- libs/ardour/session_state.cc | 30 +++++++----------------------- libs/pbd/pathexpand.cc | 27 +++++++++++++++++++-------- libs/pbd/pbd/pathexpand.h | 1 + 5 files changed, 31 insertions(+), 39 deletions(-) diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index cd26a8cf8f..01678ed080 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -31,6 +31,7 @@ #include "pbd/file_utils.h" #include "pbd/textreceiver.h" #include "pbd/failed_constructor.h" +#include "pbd/pathexpand.h" #include "pbd/pthread_utils.h" #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS #include "pbd/boost_debug.h" @@ -277,7 +278,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) lpath.push_back (dir_path); lpath.push_back ("share"); lpath.push_back ("locale"); - localedir = realpath (Glib::build_filename (lpath).c_str(), NULL); + localedir = canonical_path (Glib::build_filename (lpath)).c_str(); } #endif diff --git a/libs/ardour/find_session.cc b/libs/ardour/find_session.cc index f0a034d8d4..afcbe7393b 100644 --- a/libs/ardour/find_session.cc +++ b/libs/ardour/find_session.cc @@ -27,6 +27,7 @@ #include #include "pbd/compose.h" +#include "pbd/pathexpand.h" #include "pbd/error.h" #include "ardour/filename_extensions.h" @@ -43,16 +44,10 @@ int find_session (string str, string& path, string& snapshot, bool& isnew) { struct stat statbuf; - char buf[PATH_MAX+1]; isnew = false; - if (!realpath (str.c_str(), buf) && (errno != ENOENT && errno != ENOTDIR)) { - error << string_compose (_("Could not resolve path: %1 (%2)"), buf, strerror(errno)) << endmsg; - return -1; - } - - str = buf; + str = canonical_path (str); /* check to see if it exists, and what it is */ diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index ff7da665ed..d3c73d99e4 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -64,6 +64,7 @@ #include "pbd/enumwriter.h" #include "pbd/error.h" #include "pbd/file_utils.h" +#include "pbd/pathexpand.h" #include "pbd/pathscanner.h" #include "pbd/pthread_utils.h" #include "pbd/stacktrace.h" @@ -128,14 +129,7 @@ Session::first_stage_init (string fullpath, string snapshot_name) throw failed_constructor(); } - char buf[PATH_MAX+1]; - if (!realpath (fullpath.c_str(), buf) && (errno != ENOENT)) { - error << string_compose(_("Could not use path %1 (%2)"), buf, strerror(errno)) << endmsg; - destroy (); - throw failed_constructor(); - } - - _path = string(buf); + _path = canonical_path (fullpath); if (_path[_path.length()-1] != G_DIR_SEPARATOR) { _path += G_DIR_SEPARATOR; @@ -2664,6 +2658,8 @@ Session::cleanup_sources (CleanupReport& rep) bool used; string spath; int ret = -1; + string tmppath1; + string tmppath2; _state_of_the_state = (StateOfTheState) (_state_of_the_state | InCleanup); @@ -2788,9 +2784,6 @@ Session::cleanup_sources (CleanupReport& rep) i = tmp; } - char tmppath1[PATH_MAX+1]; - char tmppath2[PATH_MAX+1]; - if (candidates) { for (vector::iterator x = candidates->begin(); x != candidates->end(); ++x) { @@ -2799,19 +2792,10 @@ Session::cleanup_sources (CleanupReport& rep) for (set::iterator i = all_sources.begin(); i != all_sources.end(); ++i) { - if (realpath(spath.c_str(), tmppath1) == 0) { - error << string_compose (_("Cannot expand path %1 (%2)"), - spath, strerror (errno)) << endmsg; - continue; - } - - if (realpath((*i).c_str(), tmppath2) == 0) { - error << string_compose (_("Cannot expand path %1 (%2)"), - (*i), strerror (errno)) << endmsg; - continue; - } + tmppath1 = canonical_path (spath); + tmppath2 = canonical_path ((*i)); - if (strcmp(tmppath1, tmppath2) == 0) { + if (tmppath1 == tmppath2) { used = true; break; } diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc index 4911f12788..ad53bea37b 100644 --- a/libs/pbd/pathexpand.cc +++ b/libs/pbd/pathexpand.cc @@ -18,8 +18,10 @@ */ #include -#include #include +#include +#include +#include #include @@ -31,6 +33,21 @@ using std::string; using std::vector; +string +PBD::canonical_path (const std::string& path) +{ +#ifdef WIN32 + return path; +#endif + char buf[PATH_MAX+1]; + + if (!realpath (path.c_str(), buf) && (errno != ENOENT)) { + return path; + } + + return string (buf); +} + string PBD::path_expand (string path) { @@ -97,13 +114,7 @@ PBD::path_expand (string path) /* canonicalize */ - char buf[PATH_MAX+1]; - - if (realpath (path.c_str(), buf)) { - return buf; - } else { - return string(); - } + return canonical_path (path); } string diff --git a/libs/pbd/pbd/pathexpand.h b/libs/pbd/pbd/pathexpand.h index a7b9f7557a..2b2639e07e 100644 --- a/libs/pbd/pbd/pathexpand.h +++ b/libs/pbd/pbd/pathexpand.h @@ -22,6 +22,7 @@ #include namespace PBD { + std::string canonical_path (const std::string& path); std::string path_expand (std::string path); std::string search_path_expand (std::string path); } -- cgit v1.2.3 From 5d125e1eaeb95e95117007cd6d5501ce97310ad8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:58:00 -0400 Subject: Use PBD::pthread_name in debug output --- libs/ardour/session_events.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/ardour/session_events.cc b/libs/ardour/session_events.cc index 6c828ac6f0..19034da247 100644 --- a/libs/ardour/session_events.cc +++ b/libs/ardour/session_events.cc @@ -23,6 +23,7 @@ #include "pbd/error.h" #include "pbd/enumwriter.h" #include "pbd/stacktrace.h" +#include "pbd/pthread_utils.h" #include "ardour/debug.h" #include "ardour/session_event.h" @@ -56,7 +57,7 @@ SessionEvent::operator new (size_t) { CrossThreadPool* p = pool->per_thread_pool (); SessionEvent* ev = static_cast (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); @@ -74,7 +75,7 @@ SessionEvent::operator delete (void *ptr, size_t /*size*/) 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() + pthread_name(), ev, p->name(), ev->own_pool->name() )); #ifndef NDEBUG -- cgit v1.2.3 From c43ff1113d89db0250ad092b9c213092cd4b8a92 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:00:22 -0400 Subject: Add ::localtime_r implementation for mingw --- libs/pbd/localtime_r.cc | 41 +++++++++++++++++++++++++++++++++++++++++ libs/pbd/pbd/localtime_r.h | 7 +++++++ libs/pbd/wscript | 2 ++ 3 files changed, 50 insertions(+) create mode 100644 libs/pbd/localtime_r.cc create mode 100644 libs/pbd/pbd/localtime_r.h diff --git a/libs/pbd/localtime_r.cc b/libs/pbd/localtime_r.cc new file mode 100644 index 0000000000..26e9dcc4a4 --- /dev/null +++ b/libs/pbd/localtime_r.cc @@ -0,0 +1,41 @@ +#ifdef WAF_BUILD +#include "libpbd-config.h" +#endif + +#ifndef HAVE_LOCALTIME_R +#include +#include +#include + +#include "pbd/localtime_r.h" + +#ifdef localtime_r +#undef localtime_r +#endif + +struct tm * +localtime_r(const time_t *const timep, struct tm *p_tm) +{ + static pthread_mutex_t time_mutex; + static int time_mutex_inited = 0; + struct tm *tmp; + + if (!time_mutex_inited) + { + time_mutex_inited = 1; + pthread_mutex_init(&time_mutex, NULL); + } + + pthread_mutex_lock(&time_mutex); + tmp = localtime(timep); + if (tmp) + { + memcpy(p_tm, tmp, sizeof(struct tm)); + tmp = p_tm; + } + pthread_mutex_unlock(&time_mutex); + + return tmp; +} + +#endif diff --git a/libs/pbd/pbd/localtime_r.h b/libs/pbd/pbd/localtime_r.h new file mode 100644 index 0000000000..2e7c7aa149 --- /dev/null +++ b/libs/pbd/pbd/localtime_r.h @@ -0,0 +1,7 @@ +#ifndef PBD_LOCALTIME_R +#define PBD_LOCALTIME_R +#include + +extern struct tm *localtime_r(const time_t *const timep, struct tm *p_tm); + +#endif diff --git a/libs/pbd/wscript b/libs/pbd/wscript index ebf7f64ab4..797f6e2cad 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -52,6 +52,7 @@ libpbd_sources = [ 'glib_semaphore.cc', 'id.cc', 'locale_guard.cc', + 'localtime_r.cc', 'malign.cc', 'mountpoint.cc', 'openuri.cc', @@ -96,6 +97,7 @@ def configure(conf): conf.check(header_name='execinfo.h', define_name='HAVE_EXECINFO',mandatory=False) conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False) conf.check_cc(function_name='posix_memalign', header_name='stdlib.h', cflags='-D_XOPEN_SOURCE=600', define_name='HAVE_POSIX_MEMALIGN', mandatory=False) + conf.check(function_name='localtime_r', header_name='time.h', define_name='HAVE_LOCALTIME_R',mandatory=False) conf.write_config_header('libpbd-config.h', remove=False) -- cgit v1.2.3 From a69847b6713fcc067265cfc95213510107ec7e7d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:00:56 -0400 Subject: Include pbd/localtime_r.h for mingw build --- libs/ardour/session_state.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index d3c73d99e4..7ccaca1a27 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -70,6 +70,7 @@ #include "pbd/stacktrace.h" #include "pbd/convert.h" #include "pbd/clear_dir.h" +#include "pbd/localtime_r.h" #include "ardour/amp.h" #include "ardour/audio_diskstream.h" -- cgit v1.2.3 From fa2dcea820fb3aa9ba244a7e28890c4c9296019a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:08:10 -0400 Subject: Use jack_native_thread_t for portability Requires future attention in AudioEngine due to timbyr's use JACK2 extension to JACK API --- libs/ardour/ardour/audioengine.h | 3 ++- libs/ardour/ardour/graph.h | 2 +- libs/ardour/audioengine.cc | 24 +++++++++++++++++++++++- libs/ardour/graph.cc | 7 +++---- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 165ad6744f..363238baad 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -258,7 +258,8 @@ _ the regular process() call to session->process() is not made. static void destroy(); void died (); - int create_process_thread (boost::function, pthread_t*, size_t stacksize); + int create_process_thread (boost::function, jack_native_thread_t*, size_t stacksize); + bool stop_process_thread (jack_native_thread_t); private: static AudioEngine* _instance; diff --git a/libs/ardour/ardour/graph.h b/libs/ardour/ardour/graph.h index cac09d34af..0a288d68d3 100644 --- a/libs/ardour/ardour/graph.h +++ b/libs/ardour/ardour/graph.h @@ -92,7 +92,7 @@ protected: virtual void session_going_away (); private: - std::list _thread_list; + std::list _thread_list; volatile bool _quit_threads; void reset_thread_list (); diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 08de54960c..690012e529 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1548,7 +1548,7 @@ AudioEngine::is_realtime () const } int -AudioEngine::create_process_thread (boost::function f, pthread_t* thread, size_t stacksize) +AudioEngine::create_process_thread (boost::function f, jack_native_thread_t* thread, size_t stacksize) { GET_PRIVATE_JACK_POINTER_RET (_jack, 0); ThreadData* td = new ThreadData (this, f, stacksize); @@ -1561,6 +1561,28 @@ AudioEngine::create_process_thread (boost::function f, pthread_t* thread return 0; } +bool +AudioEngine::stop_process_thread (jack_native_thread_t thread) +{ + /** + * can't use GET_PRIVATE_JACK_POINTER_RET (_jack, 0) here + * because _jack is 0 when this is called. At least for + * Jack 2 _jack arg is not used so it should be OK + */ + +#ifdef USING_JACK2_EXPANSION_OF_JACK_API + if (jack_client_stop_thread (_jack, thread) != 0) { + error << "AudioEngine: cannot stop process thread" << endmsg; + return false; + } +#else + void* status; + pthread_join (thread, &status); +#endif + + return true; +} + void* AudioEngine::_start_process_thread (void* arg) { diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index cb0fa1b21a..3eb601e82b 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -101,7 +101,7 @@ Graph::reset_thread_list () } Glib::Threads::Mutex::Lock lm (_session.engine().process_lock()); - pthread_t a_thread; + jack_native_thread_t a_thread; if (!_thread_list.empty()) { drop_threads (); @@ -146,9 +146,8 @@ Graph::drop_threads () _callback_start_sem.signal (); - for (list::iterator i = _thread_list.begin(); i != _thread_list.end(); ++i) { - void* status; - pthread_join (*i, &status); + for (list::iterator i = _thread_list.begin(); i != _thread_list.end(); ++i) { + AudioEngine::instance()->stop_process_thread(*i); } _thread_list.clear (); -- cgit v1.2.3 From 2b93c878d0fea64a6b1cea3d951d6170baa6b923 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:08:47 -0400 Subject: Disable some non-portable code that is only used for debugging --- libs/ardour/graph.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index 3eb601e82b..3ec912ecd3 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -583,10 +583,12 @@ 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()) { return true; } } return false; +#endif } -- cgit v1.2.3 From 01a4c3186a89ff38ba99d61e0b903b3c2d1e365a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:09:29 -0400 Subject: Use PBD::pthread_name in debug output for portability --- libs/ardour/graph.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index 3ec912ecd3..12752c158e 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -22,6 +22,7 @@ #include "pbd/compose.h" #include "pbd/debug_rt_alloc.h" +#include "pbd/pthread_utils.h" #include "ardour/debug.h" #include "ardour/graph.h" @@ -365,7 +366,7 @@ Graph::run_one() /* update the number of threads that will still be sleeping */ _execution_tokens -= wakeup; - DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 signals %2\n", pthread_self(), wakeup)); + DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 signals %2\n", pthread_name(), wakeup)); for (int i = 0; i < wakeup; i++) { _execution_sem.signal (); @@ -374,12 +375,12 @@ Graph::run_one() while (to_run == 0) { _execution_tokens += 1; pthread_mutex_unlock (&_trigger_mutex); - DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_self())); + DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_name())); _execution_sem.wait (); if (_quit_threads) { return true; } - DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 is awake\n", pthread_self())); + DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 is awake\n", pthread_name())); pthread_mutex_lock (&_trigger_mutex); if (_trigger_queue.size()) { to_run = _trigger_queue.back(); @@ -391,7 +392,7 @@ Graph::run_one() to_run->process(); to_run->finish (_current_chain); - DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 has finished run_one()\n", pthread_self())); + DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 has finished run_one()\n", pthread_name())); return false; } @@ -559,7 +560,7 @@ Graph::process_one_route (Route* route) assert (route); - DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 runs route %2\n", pthread_self(), route->name())); + DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 runs route %2\n", pthread_name(), route->name())); if (_process_silent) { retval = route->silent_roll (_process_nframes, _process_start_frame, _process_end_frame, need_butler); -- cgit v1.2.3 From 9f7e293c3b32165dfaab9734f8665e9468f490b4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:10:10 -0400 Subject: Use Glib::usleep for portability --- libs/ardour/automation_watch.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/ardour/automation_watch.cc b/libs/ardour/automation_watch.cc index 16e10c95f9..4e5f64bd32 100644 --- a/libs/ardour/automation_watch.cc +++ b/libs/ardour/automation_watch.cc @@ -19,6 +19,8 @@ #include +#include + #include "pbd/compose.h" #include "ardour/automation_control.h" @@ -134,7 +136,7 @@ void AutomationWatch::thread () { while (_run_thread) { - usleep ((useconds_t) floor (Config->get_automation_interval_msecs() * 1000)); + Glib::usleep ((useconds_t) floor (Config->get_automation_interval_msecs() * 1000)); timer (); } } -- cgit v1.2.3 From abd478d1c8e05e01f7522e8521aa7afd61bf4079 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:11:22 -0400 Subject: Include pthread.h in butler.h for mingw build Jack2 on windows doesn't include pthread headers so it is necessary to include them explicitly. --- libs/ardour/ardour/butler.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/ardour/ardour/butler.h b/libs/ardour/ardour/butler.h index 81159f7d3c..97020bed66 100644 --- a/libs/ardour/ardour/butler.h +++ b/libs/ardour/ardour/butler.h @@ -20,6 +20,8 @@ #ifndef __ardour_butler_h__ #define __ardour_butler_h__ +#include + #include #ifdef WIN32 -- cgit v1.2.3 From ef3ea6c6a647b0f885dc0f3fe4d692756a5654b4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:14:51 -0400 Subject: Work around badly chosen argument name in giomm/dbusmessage.h interface is defined in windows/mingw headers. hopefully this will be fixed in giomm at some point and this crap can be removed --- libs/gtkmm2ext/gtkmm2ext/auto_spin.h | 4 ++++ libs/gtkmm2ext/gtkmm2ext/click_box.h | 4 ++++ libs/gtkmm2ext/gtkmm2ext/doi.h | 4 ++++ libs/gtkmm2ext/gtkmm2ext/popup.h | 4 ++++ libs/gtkmm2ext/gtkmm2ext/selector.h | 4 ++++ libs/gtkmm2ext/gtkmm2ext/slider_controller.h | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/libs/gtkmm2ext/gtkmm2ext/auto_spin.h b/libs/gtkmm2ext/gtkmm2ext/auto_spin.h index b692a7ccdc..4eab2dae98 100644 --- a/libs/gtkmm2ext/gtkmm2ext/auto_spin.h +++ b/libs/gtkmm2ext/gtkmm2ext/auto_spin.h @@ -20,6 +20,10 @@ #ifndef __gtkmm2ext_auto_spin_h__ #define __gtkmm2ext_auto_spin_h__ +#ifdef interface +#undef interface +#endif + #include namespace Gtkmm2ext { diff --git a/libs/gtkmm2ext/gtkmm2ext/click_box.h b/libs/gtkmm2ext/gtkmm2ext/click_box.h index 8f9655e2bf..ea0041e540 100644 --- a/libs/gtkmm2ext/gtkmm2ext/click_box.h +++ b/libs/gtkmm2ext/gtkmm2ext/click_box.h @@ -20,6 +20,10 @@ #ifndef __gtkmm2ext_click_box_h__ #define __gtkmm2ext_click_box_h__ +#ifdef interface +#undef interface +#endif + #include #include diff --git a/libs/gtkmm2ext/gtkmm2ext/doi.h b/libs/gtkmm2ext/gtkmm2ext/doi.h index 6ad1f7dd94..f61127dd74 100644 --- a/libs/gtkmm2ext/gtkmm2ext/doi.h +++ b/libs/gtkmm2ext/gtkmm2ext/doi.h @@ -20,6 +20,10 @@ #ifndef __ardour_gtk_doi_h__ #define __ardour_gtk_doi_h__ +#ifdef interface +#undef interface +#endif + #include /* XXX g++ 2.95 can't compile this as pair of member function templates */ diff --git a/libs/gtkmm2ext/gtkmm2ext/popup.h b/libs/gtkmm2ext/gtkmm2ext/popup.h index 1db357341d..994932e733 100644 --- a/libs/gtkmm2ext/gtkmm2ext/popup.h +++ b/libs/gtkmm2ext/gtkmm2ext/popup.h @@ -20,6 +20,10 @@ #ifndef __qui_popup_h__ #define __qui_popup_h__ +#ifdef interface +#undef interface +#endif + #include #include diff --git a/libs/gtkmm2ext/gtkmm2ext/selector.h b/libs/gtkmm2ext/gtkmm2ext/selector.h index 841742db03..56e075a242 100644 --- a/libs/gtkmm2ext/gtkmm2ext/selector.h +++ b/libs/gtkmm2ext/gtkmm2ext/selector.h @@ -19,6 +19,10 @@ #ifndef __gtkselector_h__ #define __gtkselector_h__ +#ifdef interface +#undef interface +#endif + #include #include diff --git a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h index 4c6a5cb41d..42ed05a761 100644 --- a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h +++ b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h @@ -19,6 +19,10 @@ #ifndef __gtkmm2ext_slider_controller_h__ #define __gtkmm2ext_slider_controller_h__ +#ifdef interface +#undef interface +#endif + #include #include #include -- cgit v1.2.3 From 965883bc223afe07ebcbb693e1108b419826d399 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:15:40 -0400 Subject: Use Glib functions to create tmp file path --- libs/gtkmm2ext/motionfeedback.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/gtkmm2ext/motionfeedback.cc b/libs/gtkmm2ext/motionfeedback.cc index 44fb3e5f47..bd0fd1cd73 100644 --- a/libs/gtkmm2ext/motionfeedback.cc +++ b/libs/gtkmm2ext/motionfeedback.cc @@ -468,14 +468,18 @@ Glib::RefPtr MotionFeedback::render_pixbuf (int size) { Glib::RefPtr pixbuf; - char path[32]; + char *path; int fd; + GError *error = NULL; - snprintf (path, sizeof (path), "/tmp/mfimg%dXXXXXX", size); - - if ((fd = mkstemp (path)) < 0) { + fd = g_file_open_tmp ("mfimgXXXXXX", &path, &error); + close (fd); + + if(error) { + g_critical("failed to open a temporary file for writing: %s.", error->message); + g_error_free (error); return pixbuf; - } + } GdkColor col2 = {0,0,0,0}; GdkColor col3 = {0,0,0,0}; @@ -522,6 +526,8 @@ MotionFeedback::render_pixbuf (int size) unlink (path); + g_free(path); + return pixbuf; } -- cgit v1.2.3 From b8c369fe2d183fafffad237ef79fc36a59bad17e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:16:11 -0400 Subject: Include pbd/timersub.h for mingw build --- libs/gtkmm2ext/idle_adjustment.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/gtkmm2ext/idle_adjustment.cc b/libs/gtkmm2ext/idle_adjustment.cc index 3e3a3da566..f74a3a9701 100644 --- a/libs/gtkmm2ext/idle_adjustment.cc +++ b/libs/gtkmm2ext/idle_adjustment.cc @@ -22,6 +22,8 @@ #include #include +#include "pbd/timersub.h" + using namespace Gtk; using namespace sigc; using namespace Gtkmm2ext; -- cgit v1.2.3 From f80859f3bdcb5c3b982379481ae3999446f35e81 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:16:50 -0400 Subject: Use uint32_t type instead of uint --- libs/audiographer/tests/sndfile/tmp_file_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/audiographer/tests/sndfile/tmp_file_test.cc b/libs/audiographer/tests/sndfile/tmp_file_test.cc index 94647cc1a6..9ce8af7a5c 100644 --- a/libs/audiographer/tests/sndfile/tmp_file_test.cc +++ b/libs/audiographer/tests/sndfile/tmp_file_test.cc @@ -23,7 +23,7 @@ class TmpFileTest : public CppUnit::TestFixture void testProcess() { - uint channels = 2; + uint32_t channels = 2; file.reset (new TmpFile(SF_FORMAT_WAV | SF_FORMAT_FLOAT, channels, 44100)); AllocatingProcessContext c (random_data, frames, channels); c.set_flag (ProcessContext::EndOfInput); -- cgit v1.2.3 From 029c530203748b2a53706d152a33adfb38ef08d3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:18:31 -0400 Subject: Disable checking for memory locking support on windows not sure if this is needed on windows, can implement later in PBD --- gtk2_ardour/ardour_ui.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 77fab156bb..0f7ccebab7 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -27,6 +27,10 @@ #include #include +#ifndef WIN32 +#include # +#endif + #include #include #include @@ -776,7 +780,7 @@ ARDOUR_UI::no_memory_warning () void ARDOUR_UI::check_memory_locking () { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(WIN32) /* OS X doesn't support mlockall(2), and so testing for memory locking capability there is pointless */ return; #else // !__APPLE__ -- cgit v1.2.3 From 32f4d7787e0916f6b90eeba25838e37d44706280 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:22:33 -0400 Subject: Change/improve enum as IN and OUT are defined via windows.h --- gtk2_ardour/global_port_matrix.cc | 10 +++++----- gtk2_ardour/global_port_matrix.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/global_port_matrix.cc b/gtk2_ardour/global_port_matrix.cc index 8c1fde3082..e1bdfb199e 100644 --- a/gtk2_ardour/global_port_matrix.cc +++ b/gtk2_ardour/global_port_matrix.cc @@ -47,7 +47,7 @@ GlobalPortMatrix::setup_ports (int dim) } _ports[dim].suspend_signals (); - _ports[dim].gather (_session, type(), dim == IN, false, show_only_bundles ()); + _ports[dim].gather (_session, type(), dim == FLOW_IN, false, show_only_bundles ()); _ports[dim].resume_signals (); } @@ -58,8 +58,8 @@ GlobalPortMatrix::set_state (BundleChannel c[2], bool s) return; } - Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel); - Bundle::PortList const & out_ports = c[OUT].bundle->channel_ports (c[OUT].channel); + Bundle::PortList const & in_ports = c[FLOW_IN].bundle->channel_ports (c[FLOW_IN].channel); + Bundle::PortList const & out_ports = c[FLOW_OUT].bundle->channel_ports (c[FLOW_OUT].channel); for (Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) { for (Bundle::PortList::const_iterator j = out_ports.begin(); j != out_ports.end(); ++j) { @@ -102,8 +102,8 @@ GlobalPortMatrix::get_state (BundleChannel c[2]) const return PortMatrixNode::NOT_ASSOCIATED; } - Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel); - Bundle::PortList const & out_ports = c[OUT].bundle->channel_ports (c[OUT].channel); + Bundle::PortList const & in_ports = c[FLOW_IN].bundle->channel_ports (c[FLOW_IN].channel); + Bundle::PortList const & out_ports = c[FLOW_OUT].bundle->channel_ports (c[FLOW_OUT].channel); if (in_ports.empty() || out_ports.empty()) { /* we're looking at a bundle with no parts associated with this channel, so nothing to connect */ diff --git a/gtk2_ardour/global_port_matrix.h b/gtk2_ardour/global_port_matrix.h index d45a639093..3def23a6a3 100644 --- a/gtk2_ardour/global_port_matrix.h +++ b/gtk2_ardour/global_port_matrix.h @@ -46,8 +46,8 @@ public: private: /* see PortMatrix: signal flow from 0 to 1 (out to in) */ enum { - OUT = 0, - IN = 1, + FLOW_OUT = 0, + FLOW_IN = 1, }; }; -- cgit v1.2.3 From 167e8bbc2fce72bc0b95f160e6c81fb9d0c7ddfb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:23:12 -0400 Subject: Include pbd/localtime_r.h for mingw build --- gtk2_ardour/ardour_ui.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 0f7ccebab7..db3dc5cb7c 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -52,6 +52,7 @@ #include "pbd/memento_command.h" #include "pbd/openuri.h" #include "pbd/file_utils.h" +#include "pbd/localtime_r.h" #include "gtkmm2ext/application.h" #include "gtkmm2ext/bindings.h" -- cgit v1.2.3 From 01ed4f3388069e521b6f27526bcc3d73123ca8fa Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:24:36 -0400 Subject: undef SearchPath where needed as it is defined via windows.h --- libs/ardour/midi_patch_manager.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/ardour/midi_patch_manager.cc b/libs/ardour/midi_patch_manager.cc index 4bced4e46d..f3541a2e62 100644 --- a/libs/ardour/midi_patch_manager.cc +++ b/libs/ardour/midi_patch_manager.cc @@ -28,6 +28,11 @@ #include "ardour/session.h" #include "ardour/session_directory.h" #include "ardour/midi_patch_manager.h" + +#ifdef SearchPath +#undef SearchPath +#endif + #include "ardour/midi_patch_search_path.h" #include "i18n.h" -- cgit v1.2.3 From 5cafb98983adf47c2daa4480e04984309355b7bf Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:29:28 -0400 Subject: Work around badly chosen argument name in giomm/dbusmessage.h interface is defined in windows/mingw headers. hopefully this will be fixed in giomm at some point and this crap can be removed --- gtk2_ardour/ardour_ui.cc | 2 +- gtk2_ardour/audio_region_view.h | 4 ++++ gtk2_ardour/export_channel_selector.h | 4 ++++ gtk2_ardour/export_format_dialog.h | 4 ++++ gtk2_ardour/export_timespan_selector.h | 5 +++++ gtk2_ardour/midi_region_view.h | 4 ++++ gtk2_ardour/region_gain_line.h | 4 ++++ gtk2_ardour/region_view.h | 4 ++++ gtk2_ardour/session_metadata_dialog.h | 4 ++++ 9 files changed, 34 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index db3dc5cb7c..5bef863c95 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -28,7 +28,7 @@ #include #ifndef WIN32 -#include # +#include #endif #include diff --git a/gtk2_ardour/audio_region_view.h b/gtk2_ardour/audio_region_view.h index 10159d0cfb..7c6d6b88f2 100644 --- a/gtk2_ardour/audio_region_view.h +++ b/gtk2_ardour/audio_region_view.h @@ -19,6 +19,10 @@ #ifndef __gtk_ardour_audio_region_view_h__ #define __gtk_ardour_audio_region_view_h__ +#ifdef interface +#undef interface +#endif + #include #include diff --git a/gtk2_ardour/export_channel_selector.h b/gtk2_ardour/export_channel_selector.h index 984026a748..bc165273c7 100644 --- a/gtk2_ardour/export_channel_selector.h +++ b/gtk2_ardour/export_channel_selector.h @@ -25,6 +25,10 @@ #include "ardour/export_profile_manager.h" +#ifdef interface +#undef interface +#endif + #include #include #include diff --git a/gtk2_ardour/export_format_dialog.h b/gtk2_ardour/export_format_dialog.h index 8d37ded2cd..3e38cf09d6 100644 --- a/gtk2_ardour/export_format_dialog.h +++ b/gtk2_ardour/export_format_dialog.h @@ -32,6 +32,10 @@ #include "ardour_dialog.h" #include "audio_clock.h" +#ifdef interface +#undef interface +#endif + #include class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList { diff --git a/gtk2_ardour/export_timespan_selector.h b/gtk2_ardour/export_timespan_selector.h index 2118a57b83..5556f5f676 100644 --- a/gtk2_ardour/export_timespan_selector.h +++ b/gtk2_ardour/export_timespan_selector.h @@ -25,9 +25,14 @@ #include +#ifdef interface +#undef interface +#endif + #include #include + #include "ardour/types.h" #include "ardour/session_handle.h" #include "ardour/export_profile_manager.h" diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 5f374da55c..219d07f376 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -22,6 +22,10 @@ #include #include +#ifdef interface +#undef interface +#endif + #include #include diff --git a/gtk2_ardour/region_gain_line.h b/gtk2_ardour/region_gain_line.h index c0b843acd0..61b361210b 100644 --- a/gtk2_ardour/region_gain_line.h +++ b/gtk2_ardour/region_gain_line.h @@ -22,6 +22,10 @@ #include "ardour/ardour.h" +#ifdef interface +#undef interface +#endif + #include #include "automation_line.h" diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index 1eda8fd360..3016117353 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -19,6 +19,10 @@ #ifndef __gtk_ardour_region_view_h__ #define __gtk_ardour_region_view_h__ +#ifdef interface +#undef interface +#endif + #include #include diff --git a/gtk2_ardour/session_metadata_dialog.h b/gtk2_ardour/session_metadata_dialog.h index bd1e042bb7..1599e50bb3 100644 --- a/gtk2_ardour/session_metadata_dialog.h +++ b/gtk2_ardour/session_metadata_dialog.h @@ -22,6 +22,10 @@ #include "ardour_dialog.h" +#ifdef interface +#undef interface +#endif + #include #include -- cgit v1.2.3 From c08b336292cd66e066eae23bc6272dce42ae28c2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:32:31 -0400 Subject: Fix ambiguous type CheckMenuItem that is also defined via windows.h --- gtk2_ardour/audio_time_axis.cc | 4 ++-- gtk2_ardour/automation_time_axis.cc | 12 ++++++------ gtk2_ardour/editor_markers.cc | 4 ++-- gtk2_ardour/main_clock.cc | 2 +- gtk2_ardour/midi_time_axis.cc | 8 ++++---- gtk2_ardour/mixer_strip.cc | 4 ++-- gtk2_ardour/panner_ui.cc | 2 +- gtk2_ardour/port_matrix.cc | 2 +- gtk2_ardour/processor_box.cc | 2 +- gtk2_ardour/route_time_axis.cc | 6 +++--- gtk2_ardour/route_ui.cc | 24 ++++++++++++------------ 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc index bf980690aa..994f167014 100644 --- a/gtk2_ardour/audio_time_axis.cc +++ b/gtk2_ardour/audio_time_axis.cc @@ -387,14 +387,14 @@ AudioTimeAxisView::build_automation_action_menu (bool for_selection) MenuList& automation_items = automation_action_menu->items (); automation_items.push_back (CheckMenuElem (_("Fader"), sigc::mem_fun (*this, &AudioTimeAxisView::update_gain_track_visibility))); - gain_automation_item = dynamic_cast (&automation_items.back ()); + gain_automation_item = dynamic_cast (&automation_items.back ()); gain_automation_item->set_active ((!for_selection || _editor.get_selection().tracks.size() == 1) && (gain_track && string_is_affirmative (gain_track->gui_property ("visible")))); _main_automation_menu_map[Evoral::Parameter(GainAutomation)] = gain_automation_item; automation_items.push_back (CheckMenuElem (_("Pan"), sigc::mem_fun (*this, &AudioTimeAxisView::update_pan_track_visibility))); - pan_automation_item = dynamic_cast (&automation_items.back ()); + pan_automation_item = dynamic_cast (&automation_items.back ()); pan_automation_item->set_active ((!for_selection || _editor.get_selection().tracks.size() == 1) && (!pan_tracks.empty() && string_is_affirmative (pan_tracks.front()->gui_property ("visible")))); diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 848298c8b8..1621697335 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -496,22 +496,22 @@ AutomationTimeAxisView::build_display_menu () as_items.push_back (CheckMenuElem (S_("Automation|Manual"), sigc::bind ( sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state), (AutoState) ARDOUR::Off))); - auto_off_item = dynamic_cast(&as_items.back()); + auto_off_item = dynamic_cast(&as_items.back()); as_items.push_back (CheckMenuElem (_("Play"), sigc::bind ( sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state), (AutoState) Play))); - auto_play_item = dynamic_cast(&as_items.back()); + auto_play_item = dynamic_cast(&as_items.back()); as_items.push_back (CheckMenuElem (_("Write"), sigc::bind ( sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state), (AutoState) Write))); - auto_write_item = dynamic_cast(&as_items.back()); + auto_write_item = dynamic_cast(&as_items.back()); as_items.push_back (CheckMenuElem (_("Touch"), sigc::bind ( sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state), (AutoState) Touch))); - auto_touch_item = dynamic_cast(&as_items.back()); + auto_touch_item = dynamic_cast(&as_items.back()); items.push_back (MenuElem (_("State"), *auto_state_menu)); @@ -531,13 +531,13 @@ AutomationTimeAxisView::build_display_menu () am_items.push_back (RadioMenuElem (group, _("Discrete"), sigc::bind ( sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation), AutomationList::Discrete))); - mode_discrete_item = dynamic_cast(&am_items.back()); + mode_discrete_item = dynamic_cast(&am_items.back()); mode_discrete_item->set_active (s == AutomationList::Discrete); am_items.push_back (RadioMenuElem (group, _("Linear"), sigc::bind ( sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation), AutomationList::Linear))); - mode_line_item = dynamic_cast(&am_items.back()); + mode_line_item = dynamic_cast(&am_items.back()); mode_line_item->set_active (s == AutomationList::Linear); items.push_back (MenuElem (_("Mode"), *auto_mode_menu)); diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 3bca0ad935..6dee565287 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -858,14 +858,14 @@ Editor::build_marker_menu (Location* loc) items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &Editor::marker_menu_rename))); items.push_back (CheckMenuElem (_("Lock"))); - CheckMenuItem* lock_item = static_cast (&items.back()); + Gtk::CheckMenuItem* lock_item = static_cast (&items.back()); if (loc->locked ()) { lock_item->set_active (); } lock_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_lock)); items.push_back (CheckMenuElem (_("Glue to Bars and Beats"))); - CheckMenuItem* glue_item = static_cast (&items.back()); + Gtk::CheckMenuItem* glue_item = static_cast (&items.back()); if (loc->position_lock_style() == MusicTime) { glue_item->set_active (); } diff --git a/gtk2_ardour/main_clock.cc b/gtk2_ardour/main_clock.cc index c9361f6091..36b398ee44 100644 --- a/gtk2_ardour/main_clock.cc +++ b/gtk2_ardour/main_clock.cc @@ -49,7 +49,7 @@ MainClock::build_ops_menu () MenuList& ops_items = ops_menu->items(); ops_items.push_back (SeparatorElem ()); ops_items.push_back (CheckMenuElem (_("Display delta to edit cursor"), sigc::mem_fun (*this, &MainClock::display_delta_to_edit_cursor))); - CheckMenuItem* c = dynamic_cast (&ops_items.back()); + Gtk::CheckMenuItem* c = dynamic_cast (&ops_items.back()); if (_primary) { if (ARDOUR::Config->get_primary_clock_delta_edit_cursor ()) { ARDOUR::Config->set_primary_clock_delta_edit_cursor (false); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index a4ffc442a3..a8fc9c3e60 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -665,7 +665,7 @@ MidiTimeAxisView::add_channel_command_menu_item (Menu_Helpers::MenuList& items, } } - CheckMenuItem* cmi = static_cast(&chn_items.back()); + Gtk::CheckMenuItem* cmi = static_cast(&chn_items.back()); _channel_command_menu_map[fully_qualified_param] = cmi; cmi->set_active (visible); } @@ -697,7 +697,7 @@ MidiTimeAxisView::add_channel_command_menu_item (Menu_Helpers::MenuList& items, } } - CheckMenuItem* cmi = static_cast(&items.back()); + Gtk::CheckMenuItem* cmi = static_cast(&items.back()); _channel_command_menu_map[fully_qualified_param] = cmi; cmi->set_active (visible); @@ -739,7 +739,7 @@ MidiTimeAxisView::add_single_channel_controller_item(Menu_Helpers::MenuList& ctl } } - CheckMenuItem* cmi = static_cast(&ctl_items.back()); + Gtk::CheckMenuItem* cmi = static_cast(&ctl_items.back()); _controller_menu_map[fully_qualified_param] = cmi; cmi->set_active (visible); @@ -795,7 +795,7 @@ MidiTimeAxisView::add_multi_channel_controller_item(Menu_Helpers::MenuList& ctl_ } } - CheckMenuItem* cmi = static_cast(&chn_items.back()); + Gtk::CheckMenuItem* cmi = static_cast(&chn_items.back()); _controller_menu_map[fully_qualified_param] = cmi; cmi->set_active (visible); } diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 98b208f317..17d714fd50 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -1472,7 +1472,7 @@ MixerStrip::build_route_ops_menu () items.push_back (SeparatorElem()); items.push_back (CheckMenuElem (_("Active"))); - CheckMenuItem* i = dynamic_cast (&items.back()); + Gtk::CheckMenuItem* i = dynamic_cast (&items.back()); i->set_active (_route->active()); i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), !_route->active(), false)); @@ -1482,7 +1482,7 @@ MixerStrip::build_route_ops_menu () items.push_back (SeparatorElem()); items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection))); - denormal_menu_item = dynamic_cast (&items.back()); + denormal_menu_item = dynamic_cast (&items.back()); denormal_menu_item->set_active (_route->denormal_protection()); if (!Profile->get_sae()) { diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index 181664bb4e..a5ed0c7aee 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -382,7 +382,7 @@ PannerUI::build_pan_menu () items.clear (); items.push_back (CheckMenuElem (_("Bypass"), sigc::mem_fun(*this, &PannerUI::pan_bypass_toggle))); - bypass_menu_item = static_cast (&items.back()); + bypass_menu_item = static_cast (&items.back()); /* set state first, connect second */ diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index bac415d72f..d406b8ed01 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -508,7 +508,7 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t) items.push_back (MenuElem (_("Rescan"), sigc::mem_fun (*this, &PortMatrix::setup_all_ports))); items.push_back (CheckMenuElem (_("Show individual ports"), sigc::mem_fun (*this, &PortMatrix::toggle_show_only_bundles))); - CheckMenuItem* i = dynamic_cast (&items.back()); + Gtk::CheckMenuItem* i = dynamic_cast (&items.back()); _inhibit_toggle_show_only_bundles = true; i->set_active (!_show_only_bundles); _inhibit_toggle_show_only_bundles = false; diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 495845d2d4..c119a1d824 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -381,7 +381,7 @@ ProcessorEntry::build_controls_menu () for (list::iterator i = _controls.begin(); i != _controls.end(); ++i) { items.push_back (CheckMenuElem ((*i)->name ())); - CheckMenuItem* c = dynamic_cast (&items.back ()); + Gtk::CheckMenuItem* c = dynamic_cast (&items.back ()); c->set_active ((*i)->visible ()); c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i)); } diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index b0fec293cf..a113fe9db8 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -694,7 +694,7 @@ RouteTimeAxisView::build_display_menu () } items.push_back (CheckMenuElem (_("Active"))); - CheckMenuItem* i = dynamic_cast (&items.back()); + Gtk::CheckMenuItem* i = dynamic_cast (&items.back()); bool click_sets_active = true; if (active > 0 && inactive == 0) { i->set_active (true); @@ -2038,12 +2038,12 @@ RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr p for (std::set::const_iterator i = automatable.begin(); i != automatable.end(); ++i) { ProcessorAutomationNode* pan; - CheckMenuItem* mitem; + Gtk::CheckMenuItem* mitem; string name = processor->describe_parameter (*i); items.push_back (CheckMenuElem (name)); - mitem = dynamic_cast (&items.back()); + mitem = dynamic_cast (&items.back()); _subplugin_menu_map[*i] = mitem; diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index bf14719d70..43b97bb648 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -779,7 +779,7 @@ RouteUI::build_record_menu () MenuList& items = record_menu->items(); items.push_back (CheckMenuElem (_("Step Entry"), sigc::mem_fun (*this, &RouteUI::toggle_step_edit))); - step_edit_item = dynamic_cast (&items.back()); + step_edit_item = dynamic_cast (&items.back()); if (_route->record_enabled()) { step_edit_item->set_sensitive (false); @@ -1201,20 +1201,20 @@ RouteUI::build_solo_menu (void) solo_menu = new Menu; solo_menu->set_name ("ArdourContextMenu"); MenuList& items = solo_menu->items(); - CheckMenuItem* check; + Gtk::CheckMenuItem* check; - check = new CheckMenuItem(_("Solo Isolate")); + check = new Gtk::CheckMenuItem(_("Solo Isolate")); check->set_active (_route->solo_isolated()); check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_isolated), check)); items.push_back (CheckMenuElem(*check)); - solo_isolated_check = dynamic_cast(&items.back()); + solo_isolated_check = dynamic_cast(&items.back()); check->show_all(); - check = new CheckMenuItem(_("Solo Safe")); + check = new Gtk::CheckMenuItem(_("Solo Safe")); check->set_active (_route->solo_safe()); check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_safe), check)); items.push_back (CheckMenuElem(*check)); - solo_safe_check = dynamic_cast(&items.back()); + solo_safe_check = dynamic_cast(&items.back()); check->show_all(); //items.push_back (SeparatorElem()); @@ -1232,25 +1232,25 @@ RouteUI::build_mute_menu(void) MenuList& items = mute_menu->items(); - pre_fader_mute_check = manage (new CheckMenuItem(_("Pre Fader"))); + pre_fader_mute_check = manage (new Gtk::CheckMenuItem(_("Pre Fader"))); init_mute_menu(MuteMaster::PreFader, pre_fader_mute_check); pre_fader_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::PreFader, pre_fader_mute_check)); items.push_back (CheckMenuElem(*pre_fader_mute_check)); pre_fader_mute_check->show_all(); - post_fader_mute_check = manage (new CheckMenuItem(_("Post Fader"))); + post_fader_mute_check = manage (new Gtk::CheckMenuItem(_("Post Fader"))); init_mute_menu(MuteMaster::PostFader, post_fader_mute_check); post_fader_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::PostFader, post_fader_mute_check)); items.push_back (CheckMenuElem(*post_fader_mute_check)); post_fader_mute_check->show_all(); - listen_mute_check = manage (new CheckMenuItem(_("Control Outs"))); + listen_mute_check = manage (new Gtk::CheckMenuItem(_("Control Outs"))); init_mute_menu(MuteMaster::Listen, listen_mute_check); listen_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::Listen, listen_mute_check)); items.push_back (CheckMenuElem(*listen_mute_check)); listen_mute_check->show_all(); - main_mute_check = manage (new CheckMenuItem(_("Main Outs"))); + main_mute_check = manage (new Gtk::CheckMenuItem(_("Main Outs"))); init_mute_menu(MuteMaster::Main, main_mute_check); main_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::Main, main_mute_check)); items.push_back (CheckMenuElem(*main_mute_check)); @@ -1263,7 +1263,7 @@ RouteUI::build_mute_menu(void) } void -RouteUI::init_mute_menu(MuteMaster::MutePoint mp, CheckMenuItem* check) +RouteUI::init_mute_menu(MuteMaster::MutePoint mp, Gtk::CheckMenuItem* check) { check->set_active (_route->mute_points() & mp); } @@ -1953,7 +1953,7 @@ RouteUI::invert_press (GdkEventButton* ev) for (uint32_t i = 0; i < N; ++i) { items.push_back (CheckMenuElem (string_compose (X_("Ø%1"), i + 1), sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_menu_toggled), i))); - CheckMenuItem* e = dynamic_cast (&items.back ()); + Gtk::CheckMenuItem* e = dynamic_cast (&items.back ()); ++_i_am_the_modifier; e->set_active (_route->phase_invert (i)); --_i_am_the_modifier; -- cgit v1.2.3 From aa29b3b44cdcb0032f75998e6a8bec43d6e690df Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 22:05:06 -0400 Subject: Work around DELETE defined via windows.h --- gtk2_ardour/bundle_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/bundle_manager.cc b/gtk2_ardour/bundle_manager.cc index c7754f69cc..035046c10b 100644 --- a/gtk2_ardour/bundle_manager.cc +++ b/gtk2_ardour/bundle_manager.cc @@ -286,7 +286,7 @@ BundleManager::BundleManager (Session* session) edit_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::EDIT, Gtk::ICON_SIZE_BUTTON))); edit_button.signal_clicked().connect (sigc::mem_fun (*this, &BundleManager::edit_clicked)); buttons->pack_start (edit_button, false, false); - delete_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::DELETE, Gtk::ICON_SIZE_BUTTON))); + delete_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::StockID(GTK_STOCK_DELETE), Gtk::ICON_SIZE_BUTTON))); delete_button.signal_clicked().connect (sigc::mem_fun (*this, &BundleManager::delete_clicked)); buttons->pack_start (delete_button, false, false); -- cgit v1.2.3 From 32320ec31dbc75d7566806308ebe2e72807a162a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 22:06:20 -0400 Subject: Add windows equivalent of hack in timefx --- gtk2_ardour/editor_timefx.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index 2f0b09ed17..e43dae9e2b 100644 --- a/gtk2_ardour/editor_timefx.cc +++ b/gtk2_ardour/editor_timefx.cc @@ -402,9 +402,12 @@ Editor::timefx_thread (void *arg) by the GUI ... */ +#ifdef WIN32 + Sleep(2000); +#else struct timespec t = { 2, 0 }; nanosleep (&t, 0); - +#endif return 0; } -- cgit v1.2.3 From 981e7e7fbb17662ab6081f731d91d53a9738adc9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 22:07:25 -0400 Subject: Use Glib::usleep in export_dialog.cc for portability --- gtk2_ardour/export_dialog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/export_dialog.cc b/gtk2_ardour/export_dialog.cc index a64acd1680..8916806a15 100644 --- a/gtk2_ardour/export_dialog.cc +++ b/gtk2_ardour/export_dialog.cc @@ -328,7 +328,7 @@ ExportDialog::show_progress () if (gtk_events_pending()) { gtk_main_iteration (); } else { - usleep (10000); + Glib::usleep (10000); } } -- cgit v1.2.3 From f3858b193210973b9b74b5c7bdbc3e89aef48f93 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 22:34:16 -0400 Subject: undef SearchPath where needed as it is defined via windows.h --- gtk2_ardour/about.cc | 4 ++++ gtk2_ardour/keyboard.cc | 4 ++++ gtk2_ardour/mixer_actor.cc | 4 ++++ gtk2_ardour/step_entry.cc | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/gtk2_ardour/about.cc b/gtk2_ardour/about.cc index 6255bfa108..b2dac67379 100644 --- a/gtk2_ardour/about.cc +++ b/gtk2_ardour/about.cc @@ -40,6 +40,10 @@ #include "i18n.h" +#ifdef SearchPath +#undef SearchPath +#endif + using namespace Gtk; using namespace Gdk; using namespace std; diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index 98ffab1160..75a96ec98b 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -28,6 +28,10 @@ #include "i18n.h" +#ifdef SearchPath +#undef SearchPath +#endif + using namespace std; using namespace Gtk; using namespace PBD; diff --git a/gtk2_ardour/mixer_actor.cc b/gtk2_ardour/mixer_actor.cc index d7a1149a4b..8a90a3a1dd 100644 --- a/gtk2_ardour/mixer_actor.cc +++ b/gtk2_ardour/mixer_actor.cc @@ -35,6 +35,10 @@ #include "i18n.h" +#ifdef SearchPath +#undef SearchPath +#endif + using namespace ARDOUR; using namespace Gtk; using namespace PBD; diff --git a/gtk2_ardour/step_entry.cc b/gtk2_ardour/step_entry.cc index fd53fd55ff..27ec3b4059 100644 --- a/gtk2_ardour/step_entry.cc +++ b/gtk2_ardour/step_entry.cc @@ -36,6 +36,10 @@ #include "i18n.h" +#ifdef SearchPath +#undef SearchPath +#endif + using namespace std; using namespace Gtk; using namespace Glib; -- cgit v1.2.3 From e4ab2ffbfbe12cea63e1046b37184ddf32d9ba47 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 22:34:59 -0400 Subject: Don't install signal handler for SIGPIPE in windows --- gtk2_ardour/main.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 01678ed080..ef96423fb5 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -516,9 +516,11 @@ int main (int argc, char *argv[]) PBD::ID::init (); +#ifndef WIN32 if (::signal (SIGPIPE, sigpipe_handler)) { cerr << _("Cannot xinstall SIGPIPE error handler") << endl; } +#endif try { ui = new ARDOUR_UI (&argc, &argv, localedir); -- cgit v1.2.3 From ff825cd8bdc1aaddee6b31977b554a1fc3e04029 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:19:03 -0400 Subject: Include pbd/localtime_r.h for mingw build --- gtk2_ardour/midi_tracer.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk2_ardour/midi_tracer.cc b/gtk2_ardour/midi_tracer.cc index 70d7c24da6..1fc50c103f 100644 --- a/gtk2_ardour/midi_tracer.cc +++ b/gtk2_ardour/midi_tracer.cc @@ -23,6 +23,8 @@ #include #include +#include "pbd/localtime_r.h" + #include "midi++/parser.h" #include "midi++/manager.h" -- cgit v1.2.3 From aa4dd3443ffd3cb4639c69dc72214a3f5b758071 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:19:32 -0400 Subject: Include pbd/timersub.h for mingw build --- gtk2_ardour/midi_tracer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk2_ardour/midi_tracer.cc b/gtk2_ardour/midi_tracer.cc index 1fc50c103f..e447c59f3b 100644 --- a/gtk2_ardour/midi_tracer.cc +++ b/gtk2_ardour/midi_tracer.cc @@ -24,6 +24,7 @@ #include #include "pbd/localtime_r.h" +#include "pbd/timersub.h" #include "midi++/parser.h" #include "midi++/manager.h" -- cgit v1.2.3 From 745501b6f3ad93cda419d2d9f56d212e34b80c17 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:20:01 -0400 Subject: Fix for small identifier being defined on windows/mingw --- gtk2_ardour/panner2d.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/panner2d.cc b/gtk2_ardour/panner2d.cc index 64d83ab162..395cd2f5dd 100644 --- a/gtk2_ardour/panner2d.cc +++ b/gtk2_ardour/panner2d.cc @@ -390,7 +390,7 @@ Panner2d::on_expose_event (GdkEventExpose *event) { CartesianVector c; cairo_t* cr; - bool small = (height <= large_size_threshold); + bool small_size = (height <= large_size_threshold); const double diameter = radius*2.0; cr = gdk_cairo_create (get_window()->gobj()); @@ -473,7 +473,7 @@ Panner2d::on_expose_event (GdkEventExpose *event) cairo_select_font_face (cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); - if (small) { + if (small_size) { arc_radius = 4.0; } else { cairo_set_font_size (cr, 10); @@ -498,10 +498,10 @@ Panner2d::on_expose_event (GdkEventExpose *event) cairo_set_source_rgba (cr, 0.517, 0.772, 0.882, 1.0); cairo_stroke (cr); - if (!small && !signal->text.empty()) { + if (!small_size && !signal->text.empty()) { cairo_set_source_rgb (cr, 0.517, 0.772, 0.882); /* the +/- adjustments are a hack to try to center the text in the circle */ - if (small) { + if (small_size) { cairo_move_to (cr, c.x - 1, c.y + 1); } else { cairo_move_to (cr, c.x - 4, c.y + 4); @@ -535,7 +535,7 @@ Panner2d::on_expose_event (GdkEventExpose *event) cairo_move_to (cr, c.x, c.y); cairo_save (cr); cairo_rotate (cr, -(speaker->position.azi/360.0) * (2.0 * M_PI)); - if (small) { + if (small_size) { cairo_scale (cr, 0.8, 0.8); } else { cairo_scale (cr, 1.2, 1.2); @@ -553,7 +553,7 @@ Panner2d::on_expose_event (GdkEventExpose *event) cairo_fill (cr); cairo_restore (cr); - if (!small) { + if (!small_size) { cairo_set_font_size (cr, 16); /* move the text in just a bit */ -- cgit v1.2.3 From a0ada1f233acc153f92e86e3cb73d34b009c82d0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:20:45 -0400 Subject: Assume no filesystem links on windows --- gtk2_ardour/sfdb_ui.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index e8db9d4939..482a3b61b7 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -1463,6 +1463,9 @@ SoundFileOmega::check_info (const vector& paths, bool& same_size, bool& bool SoundFileOmega::check_link_status (const Session* s, const vector& paths) { +#ifdef WIN32 + return false; +#else std::string tmpdir(Glib::build_filename (s->session_directory().sound_path(), "linktest")); bool ret = false; @@ -1492,6 +1495,7 @@ SoundFileOmega::check_link_status (const Session* s, const vector& paths out: rmdir (tmpdir.c_str()); return ret; +#endif } SoundFileChooser::SoundFileChooser (string title, ARDOUR::Session* s) -- cgit v1.2.3 From eddcc868ba7786a7039edd1a96acbcac83499007 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:26:54 -0400 Subject: Disable non-realtime midi ports in windows build - THIS NEEDS FIXING --- libs/ardour/midi_ui.cc | 2 ++ libs/midi++2/jack_midi_port.cc | 6 ++++++ libs/midi++2/midi++/jack_midi_port.h | 10 +++++++++- libs/midi++2/midi++/port.h | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc index 78da32e427..82261b58ec 100644 --- a/libs/ardour/midi_ui.cc +++ b/libs/ardour/midi_ui.cc @@ -104,7 +104,9 @@ MidiControlUI::midi_input_handler (IOCondition ioc, MIDI::Port* port) if (ioc & IO_IN) { +#ifndef WIN32 CrossThreadChannel::drain (port->selectable()); +#endif DEBUG_TRACE (DEBUG::MidiIO, string_compose ("data available on %1\n", port->name())); framepos_t now = _session.engine().frame_time(); diff --git a/libs/midi++2/jack_midi_port.cc b/libs/midi++2/jack_midi_port.cc index 57ca2b3629..3220ca5b55 100644 --- a/libs/midi++2/jack_midi_port.cc +++ b/libs/midi++2/jack_midi_port.cc @@ -58,7 +58,9 @@ JackMIDIPort::JackMIDIPort (string const & name, Flags flags, jack_client_t* jac , _last_write_timestamp (0) , output_fifo (512) , input_fifo (1024) +#ifndef WIN32 , xthread (true) +#endif { assert (jack_client); init (name, flags); @@ -73,7 +75,9 @@ JackMIDIPort::JackMIDIPort (const XMLNode& node, jack_client_t* jack_client) , _last_write_timestamp (0) , output_fifo (512) , input_fifo (1024) +#ifndef WIN32 , xthread (true) +#endif { assert (jack_client); @@ -170,7 +174,9 @@ JackMIDIPort::cycle_start (pframes_t nframes) } if (event_count) { +#ifndef WIN32 xthread.wakeup (); +#endif } } } diff --git a/libs/midi++2/midi++/jack_midi_port.h b/libs/midi++2/midi++/jack_midi_port.h index a8859387a4..f91c7dab83 100644 --- a/libs/midi++2/midi++/jack_midi_port.h +++ b/libs/midi++2/midi++/jack_midi_port.h @@ -57,7 +57,13 @@ class JackMIDIPort : public Port { int write (const byte *msg, size_t msglen, timestamp_t timestamp); int read (byte *buf, size_t bufsize); void drain (int check_interval_usecs); - int selectable () const { return xthread.selectable(); } + int selectable () const { +#ifdef WIN32 + return false; +#else + return xthread.selectable(); +#endif + } pframes_t nframes_this_cycle() const { return _nframes_this_cycle; } @@ -80,7 +86,9 @@ private: RingBuffer< Evoral::Event > output_fifo; Evoral::EventRingBuffer input_fifo; Glib::Threads::Mutex output_fifo_lock; +#ifndef WIN32 CrossThreadChannel xthread; +#endif int create_port (); diff --git a/libs/midi++2/midi++/port.h b/libs/midi++2/midi++/port.h index 439760115c..d4f03b593e 100644 --- a/libs/midi++2/midi++/port.h +++ b/libs/midi++2/midi++/port.h @@ -27,7 +27,9 @@ #include #include "pbd/xml++.h" +#ifndef WIN32 #include "pbd/crossthread.h" +#endif #include "pbd/signals.h" #include "pbd/ringbuffer.h" -- cgit v1.2.3 From 5dca8270eb589cc60c756e09bd02ce323805b741 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:27:56 -0400 Subject: Use PBD::GlibSemaphore on windows to signal peak --- gtk2_ardour/audio_region_editor.cc | 30 ++++++++++++++++++++++++++---- gtk2_ardour/audio_region_editor.h | 10 ++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index 2aeb2dbe60..03d3e47264 100644 --- a/gtk2_ardour/audio_region_editor.cc +++ b/gtk2_ardour/audio_region_editor.cc @@ -54,7 +54,9 @@ AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr : RegionEditor (s, r) , _audio_region (r) , gain_adjustment(accurate_coefficient_to_dB(_audio_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0) +#ifndef WIN32 , _peak_channel (false) +#endif { Gtk::HBox* b = Gtk::manage (new Gtk::HBox); @@ -91,7 +93,7 @@ AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr PeakAmplitudeFound.connect (_peak_amplitude_connection, invalidator (*this), boost::bind (&AudioRegionEditor::peak_amplitude_found, this, _1), gui_context ()); pthread_create_and_store (X_("peak-amplitude"), &_peak_amplitude_thread_handle, _peak_amplitude_thread, this); - _peak_channel.deliver ('c'); + signal_peak_thread (); } AudioRegionEditor::~AudioRegionEditor () @@ -112,7 +114,7 @@ AudioRegionEditor::region_changed (const PBD::PropertyChange& what_changed) if (what_changed.contains (ARDOUR::Properties::start) || what_changed.contains (ARDOUR::Properties::length)) { /* ask the peak thread to run again */ - _peak_channel.deliver ('c'); + signal_peak_thread (); } } void @@ -133,13 +135,33 @@ AudioRegionEditor::gain_adjustment_changed () } } +void +AudioRegionEditor::signal_peak_thread () +{ +#ifdef WIN32 + m_peak_sem.post (); +#else + _peak_channel.deliver ('c'); +#endif +} + +void +AudioRegionEditor::wait_for_signal () +{ +#ifdef WIN32 + m_peak_sem.wait (); +#else + char msg; + _peak_channel.receive (msg); +#endif +} + void AudioRegionEditor::peak_amplitude_thread () { while (1) { /* await instructions to run */ - char msg; - _peak_channel.receive (msg); + wait_for_signal (); /* compute peak amplitude and signal the fact */ PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */ diff --git a/gtk2_ardour/audio_region_editor.h b/gtk2_ardour/audio_region_editor.h index dd65a3fb31..0d9292b483 100644 --- a/gtk2_ardour/audio_region_editor.h +++ b/gtk2_ardour/audio_region_editor.h @@ -37,7 +37,11 @@ #include #include "pbd/signals.h" +#ifdef WIN32 +#include "pbd/glib_semaphore.h" +#else #include "pbd/crossthread.h" +#endif #include "audio_clock.h" #include "ardour_dialog.h" @@ -74,11 +78,17 @@ class AudioRegionEditor : public RegionEditor Gtk::Label _peak_amplitude_label; Gtk::Entry _peak_amplitude; + void signal_peak_thread (); + void wait_for_signal (); pthread_t _peak_amplitude_thread_handle; void peak_amplitude_found (double); PBD::Signal1 PeakAmplitudeFound; PBD::ScopedConnection _peak_amplitude_connection; +#ifdef WIN32 + PBD::GlibSemaphore m_peak_sem; +#else CrossThreadChannel _peak_channel; +#endif }; #endif /* __gtk_ardour_audio_region_edit_h__ */ -- cgit v1.2.3 From 9db936ac26ae1cca325e0158e33fa7f0fff8eb7e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:30:27 -0400 Subject: Don't call pango_ft2* functions on windows --- gtk2_ardour/utils.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index eb3f4ab55d..66f87abd9c 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -707,7 +707,9 @@ set_pango_fontsize () /* FT2 rendering - used by GnomeCanvas, sigh */ +#ifndef WIN32 pango_ft2_font_map_set_resolution ((PangoFT2FontMap*) pango_ft2_font_map_new(), val/1024, val/1024); +#endif /* Cairo rendering, in case there is any */ -- cgit v1.2.3 From 18b50193854dc07bb392651c4708032c5c701345 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:38:17 -0400 Subject: disable pingback on win32, until we have a replacement for utsname stuff (system ID) --- gtk2_ardour/pingback.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gtk2_ardour/pingback.cc b/gtk2_ardour/pingback.cc index dea7f52f01..ccec81cba7 100644 --- a/gtk2_ardour/pingback.cc +++ b/gtk2_ardour/pingback.cc @@ -23,7 +23,10 @@ #include #include +#ifndef WIN32 #include +#endif + #include #include @@ -70,6 +73,7 @@ struct ping_call { static void* _pingback (void *arg) { +#ifndef WIN32 ping_call* cm = static_cast (arg); CURL* c; struct utsname utb; @@ -158,6 +162,8 @@ _pingback (void *arg) curl_easy_cleanup (c); delete cm; +#endif /* WIN32 */ + return 0; } -- cgit v1.2.3 From ad89d1e0311c556256ac76509e25f72e035290fc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:44:58 -0400 Subject: Use custom comparator in threadmap for pthread impl with mingw --- libs/pbd/pbd/abstract_ui.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/pbd/pbd/abstract_ui.h b/libs/pbd/pbd/abstract_ui.h index fb09dee5c2..905074c474 100644 --- a/libs/pbd/pbd/abstract_ui.h +++ b/libs/pbd/pbd/abstract_ui.h @@ -56,8 +56,22 @@ class AbstractUI : public BaseUI , ui (uir) {} }; typedef typename RequestBuffer::rw_vector RequestBufferVector; + +#if defined(__MINGW32__) + + struct pthread_cmp + { + bool operator() (const ptw32_handle_t& thread1, const ptw32_handle_t& thread2) + { + return thread1.p < thread2.p; + } + }; + typedef typename std::map::iterator RequestBufferMapIterator; + typedef std::map RequestBufferMap; +#else typedef typename std::map::iterator RequestBufferMapIterator; typedef std::map RequestBufferMap; +#endif RequestBufferMap request_buffers; static Glib::Threads::Private per_thread_request_buffer; -- cgit v1.2.3 From 40f49b85ac00d6f36985bda4b87fc5db45ed4433 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 08:45:27 -0400 Subject: Work around DELETE defined via windows.h --- gtk2_ardour/patch_change_dialog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/patch_change_dialog.cc b/gtk2_ardour/patch_change_dialog.cc index 2ecfd4bdd7..081604344c 100644 --- a/gtk2_ardour/patch_change_dialog.cc +++ b/gtk2_ardour/patch_change_dialog.cc @@ -117,7 +117,7 @@ PatchChangeDialog::PatchChangeDialog ( add_button (Stock::CANCEL, RESPONSE_CANCEL); add_button (ok, RESPONSE_ACCEPT); if (allow_delete) { - add_button (Stock::DELETE, RESPONSE_REJECT); + add_button (Gtk::StockID(GTK_STOCK_DELETE), RESPONSE_REJECT); } set_default_response (RESPONSE_ACCEPT); -- cgit v1.2.3 From 57066732ca4289bfb44650e49da32c87085287f0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 16:43:50 -0400 Subject: Use pthread_name instead of pthread_self for portability --- libs/ardour/ltc_slave.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ltc_slave.cc b/libs/ardour/ltc_slave.cc index 8d08fd6bb5..e9be71d98e 100644 --- a/libs/ardour/ltc_slave.cc +++ b/libs/ardour/ltc_slave.cc @@ -19,11 +19,11 @@ */ #include #include -#include #include #include #include "pbd/error.h" +#include "pbd/pthread_utils.h" #include "ardour/debug.h" #include "ardour/slave.h" @@ -432,7 +432,7 @@ LTC_Slave::speed_and_position (double& speed, framepos_t& pos) frameoffset_t skip = now - (monotonic_cnt + nframes); monotonic_cnt = now; - DEBUG_TRACE (DEBUG::LTC, string_compose ("speed_and_position - TID:%1 | latency: %2 | skip %3\n", ::pthread_self(), ltc_slave_latency.max, skip)); + DEBUG_TRACE (DEBUG::LTC, string_compose ("speed_and_position - TID:%1 | latency: %2 | skip %3\n", pthread_name(), ltc_slave_latency.max, skip)); if (last_timestamp == 0) { engine_dll_initstate = 0; -- cgit v1.2.3 From 3be0f0aa0bc8f9c20e0204ba8b7b03d78b425f5f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 16:44:03 -0400 Subject: Use pthread_name instead of pthread_self for portability --- libs/ardour/mtc_slave.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc index 14ca928905..db98664292 100644 --- a/libs/ardour/mtc_slave.cc +++ b/libs/ardour/mtc_slave.cc @@ -23,6 +23,7 @@ #include #include "pbd/error.h" +#include "pbd/pthread_utils.h" #include "midi++/port.h" #include "ardour/debug.h" @@ -305,7 +306,7 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full, framepos_t now) a locate command via MMC. */ - //DEBUG_TRACE (DEBUG::MTC, string_compose ("MTC::update_mtc_time - TID:%1\n", ::pthread_self())); + //DEBUG_TRACE (DEBUG::MTC, string_compose ("MTC::update_mtc_time - TID:%1\n", pthread_name())); TimecodeFormat tc_format; bool reset_tc = true; @@ -421,7 +422,7 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full, framepos_t now) now, timecode, mtc_frame, was_full, speedup_due_to_tc_mismatch)); if (was_full || outside_window (mtc_frame)) { - DEBUG_TRACE (DEBUG::MTC, string_compose ("update_mtc_time: full TC or outside window. - TID:%1\n", ::pthread_self())); + DEBUG_TRACE (DEBUG::MTC, string_compose ("update_mtc_time: full TC or outside window. - TID:%1\n", pthread_name())); session.request_locate (mtc_frame, false); session.request_transport_speed (0); update_mtc_status (MIDI::MTC_Stopped); @@ -485,7 +486,7 @@ MTC_Slave::update_mtc_status (MIDI::MTC_Status status) /* XXX !!! thread safety ... called from MIDI I/O context * on locate (via ::update_mtc_time()) */ - DEBUG_TRACE (DEBUG::MTC, string_compose("MTC_Slave::update_mtc_status - TID:%1\n", ::pthread_self())); + DEBUG_TRACE (DEBUG::MTC, string_compose("MTC_Slave::update_mtc_status - TID:%1\n", pthread_name())); return; // why was this fn needed anyway ? it just messes up things -> use reset. busy_guard1++; -- cgit v1.2.3 From 48f8863b2cb5ad4628ff6eef33cb8796e4773068 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 16:44:37 -0400 Subject: Use g_mkstemp in audiographer for portability --- libs/audiographer/audiographer/sndfile/tmp_file.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/audiographer/audiographer/sndfile/tmp_file.h b/libs/audiographer/audiographer/sndfile/tmp_file.h index 8655fd7191..facb872abf 100644 --- a/libs/audiographer/audiographer/sndfile/tmp_file.h +++ b/libs/audiographer/audiographer/sndfile/tmp_file.h @@ -4,6 +4,9 @@ #include #include +#include +#include + #include "sndfile_writer.h" #include "sndfile_reader.h" @@ -18,7 +21,7 @@ class TmpFile : public SndfileWriter, public SndfileReader /// \a filename_template must match the requirements for mkstemp, i.e. end in "XXXXXX" TmpFile (char * filename_template, int format, ChannelCount channels, framecnt_t samplerate) - : SndfileHandle (mkstemp(filename_template), true, SndfileBase::ReadWrite, format, channels, samplerate) + : SndfileHandle (g_mkstemp(filename_template), true, SndfileBase::ReadWrite, format, channels, samplerate) , filename (filename_template) {} -- cgit v1.2.3 From 550eeecc63eb4a20fcff0799e9ab7e7ac9b7a294 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 16:44:59 -0400 Subject: Add header include required by mingw compiler --- libs/pbd/pbd/floating.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/pbd/pbd/floating.h b/libs/pbd/pbd/floating.h index 105a976637..6daef5d4aa 100644 --- a/libs/pbd/pbd/floating.h +++ b/libs/pbd/pbd/floating.h @@ -26,6 +26,8 @@ #ifndef __libpbd__floating_h__ #define __libpbd__floating_h__ +#include + #include namespace PBD { -- cgit v1.2.3 From ccdc6fcd6af6a5daa76fe5205acfe6c340673d80 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 16:55:40 -0400 Subject: Add DEBUG_TRACE output to file utility functions in libpbd --- libs/pbd/debug.cc | 1 + libs/pbd/file_utils.cc | 28 +++++++++++++++++++--------- libs/pbd/pbd/debug.h | 1 + 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/libs/pbd/debug.cc b/libs/pbd/debug.cc index 51d4d1e871..fba457c83e 100644 --- a/libs/pbd/debug.cc +++ b/libs/pbd/debug.cc @@ -49,6 +49,7 @@ uint64_t PBD::DEBUG::FileManager = PBD::new_debug_bit ("filemanager"); uint64_t PBD::DEBUG::Pool = PBD::new_debug_bit ("pool"); uint64_t PBD::DEBUG::EventLoop = PBD::new_debug_bit ("eventloop"); uint64_t PBD::DEBUG::AbstractUI = PBD::new_debug_bit ("abstractui"); +uint64_t PBD::DEBUG::FileUtils = PBD::new_debug_bit ("fileutils"); uint64_t PBD::debug_bits = 0x0; diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index 01c2fe286a..1a32377ff6 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -35,6 +35,7 @@ #include "pbd/compose.h" #include "pbd/file_utils.h" +#include "pbd/debug.h" #include "pbd/error.h" #include "pbd/pathscanner.h" #include "pbd/stl_delete.h" @@ -80,6 +81,11 @@ find_matching_files_in_directory (const std::string& directory, std::string full_path(directory); full_path = Glib::build_filename (full_path, *file_iter); + DEBUG_TRACE ( + DEBUG::FileUtils, + string_compose("Found file %1\n", full_path) + ); + result.push_back(full_path); } } @@ -117,24 +123,28 @@ find_file_in_search_path(const SearchPath& search_path, if (tmp.size() == 0) { + DEBUG_TRACE ( + DEBUG::FileUtils, + string_compose("No file matching %1 found in Path: %2\n", filename, search_path.to_string()) + ); return false; } -#if 0 if (tmp.size() != 1) { - info << string_compose - ( - "Found more than one file matching %1 in search path %2", - filename, - search_path () - ) - << endmsg; + DEBUG_TRACE ( + DEBUG::FileUtils, + string_compose("Found more that one file matching %1 in Path: %2\n", filename, search_path.to_string()) + ); } -#endif result = tmp.front(); + DEBUG_TRACE ( + DEBUG::FileUtils, + string_compose("Found file %1 in Path: %2\n", filename, search_path.to_string()) + ); + return true; } diff --git a/libs/pbd/pbd/debug.h b/libs/pbd/pbd/debug.h index 989cd42dd1..704c9d0dad 100644 --- a/libs/pbd/pbd/debug.h +++ b/libs/pbd/pbd/debug.h @@ -43,6 +43,7 @@ namespace PBD { extern uint64_t Pool; extern uint64_t EventLoop; extern uint64_t AbstractUI; + extern uint64_t FileUtils; } } -- cgit v1.2.3 From 1fd2412f5be9a96e5015f81d5c89d88ce730f9c1 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 16:56:12 -0400 Subject: Add config/data filesystem paths to search on windows --- libs/ardour/filesystem_paths.cc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index 73bfaff137..4c7e996e46 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -86,14 +86,30 @@ user_config_directory () std::string ardour_dll_directory () { +#ifdef WIN32 + std::string dll_dir_path(g_win32_get_package_installation_directory_of_module(NULL)); + dll_dir_path = Glib::build_filename (dll_dir_path, "lib"); + return Glib::build_filename (dll_dir_path, "ardour3"); +#else std::string s = Glib::getenv("ARDOUR_DLL_PATH"); if (s.empty()) { std::cerr << _("ARDOUR_DLL_PATH not set in environment - exiting\n"); ::exit (1); } return s; +#endif } +#ifdef WIN32 +SearchPath +windows_search_path () +{ + std::string dll_dir_path(g_win32_get_package_installation_directory_of_module(NULL)); + dll_dir_path = Glib::build_filename (dll_dir_path, "share"); + return Glib::build_filename (dll_dir_path, "ardour3"); +} +#endif + SearchPath ardour_config_search_path () { @@ -101,7 +117,9 @@ ardour_config_search_path () if (search_path.empty()) { search_path += user_config_directory(); - +#ifdef WIN32 + search_path += windows_search_path (); +#else std::string s = Glib::getenv("ARDOUR_CONFIG_PATH"); if (s.empty()) { std::cerr << _("ARDOUR_CONFIG_PATH not set in environment - exiting\n"); @@ -109,6 +127,7 @@ ardour_config_search_path () } search_path += SearchPath (s); +#endif } return search_path; @@ -121,7 +140,9 @@ ardour_data_search_path () if (search_path.empty()) { search_path += user_config_directory(); - +#ifdef WIN32 + search_path += windows_search_path (); +#else std::string s = Glib::getenv("ARDOUR_DATA_PATH"); if (s.empty()) { std::cerr << _("ARDOUR_DATA_PATH not set in environment - exiting\n"); @@ -129,6 +150,7 @@ ardour_data_search_path () } search_path += SearchPath (s); +#endif } return search_path; -- cgit v1.2.3 From 6542ce76d0740ccd505fd9326a7a4b2d737af663 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 16:57:04 -0400 Subject: Don't use trylock in assertions on windows as it will fail glib uses TryEnterCriticalSection on windows which will return true if the lock as able to be locked *or* is already locked by the current thread. --- libs/ardour/io.cc | 6 ++++++ libs/ardour/port_insert.cc | 2 ++ libs/ardour/route.cc | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index cdb8a4693c..4e080b06d8 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -395,7 +395,9 @@ IO::disconnect (void* src) int IO::ensure_ports_locked (ChanCount count, bool clear, bool& changed) { +#ifndef WIN32 assert (!AudioEngine::instance()->process_lock().trylock()); +#endif boost::shared_ptr port; @@ -466,7 +468,9 @@ IO::ensure_ports_locked (ChanCount count, bool clear, bool& changed) int IO::ensure_ports (ChanCount count, bool clear, void* src) { +#ifndef WIN32 assert (!AudioEngine::instance()->process_lock().trylock()); +#endif bool changed = false; @@ -501,7 +505,9 @@ IO::ensure_ports (ChanCount count, bool clear, void* src) int IO::ensure_io (ChanCount count, bool clear, void* src) { +#ifndef WIN32 assert (!AudioEngine::instance()->process_lock().trylock()); +#endif return ensure_ports (count, clear, src); } diff --git a/libs/ardour/port_insert.cc b/libs/ardour/port_insert.cc index c13927449a..cf33f1b932 100644 --- a/libs/ardour/port_insert.cc +++ b/libs/ardour/port_insert.cc @@ -250,7 +250,9 @@ PortInsert::signal_latency() const bool PortInsert::configure_io (ChanCount in, ChanCount out) { +#ifndef WIN32 assert (!AudioEngine::instance()->process_lock().trylock()); +#endif /* for an insert, processor input corresponds to IO output, and vice versa */ diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index e87cb4b03f..c6f588a79c 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1612,7 +1612,9 @@ Route::reset_instrument_info () int Route::configure_processors (ProcessorStreams* err) { +#ifndef WIN32 assert (!AudioEngine::instance()->process_lock().trylock()); +#endif if (!_in_configure_processors) { Glib::Threads::RWLock::WriterLock lm (_processor_lock); @@ -1682,7 +1684,9 @@ Route::try_configure_processors_unlocked (ChanCount in, ProcessorStreams* err) int Route::configure_processors_unlocked (ProcessorStreams* err) { +#ifndef WIN32 assert (!AudioEngine::instance()->process_lock().trylock()); +#endif if (_in_configure_processors) { return 0; -- cgit v1.2.3 From e8ecd327326b48655a5e8af69203f7f6587ec4e8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:00:18 -0400 Subject: Add test for Glib::Mutex::trylock Behaviour of this method is different on WIN32 --- libs/pbd/test/testrunner.cc | 4 ++++ libs/pbd/wscript | 1 + 2 files changed, 5 insertions(+) diff --git a/libs/pbd/test/testrunner.cc b/libs/pbd/test/testrunner.cc index 1512ebd024..ea8f0aa115 100644 --- a/libs/pbd/test/testrunner.cc +++ b/libs/pbd/test/testrunner.cc @@ -4,11 +4,15 @@ #include #include #include +#include #include "scalar_properties.h" + int main () { + Glib::thread_init(); + ScalarPropertiesTest::make_property_quarks (); CppUnit::TestResult testresult; diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 797f6e2cad..2f93887e62 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -144,6 +144,7 @@ def build(bld): testobj.source = ''' test/testrunner.cc test/xpath.cc + test/mutex_test.cc test/scalar_properties.cc test/signals_test.cc test/convert_test.cc -- cgit v1.2.3 From 2e2c22ad3c0af34b311024b1f8cb4571c1e3c48f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:01:47 -0400 Subject: Fix saving sessions on windows by using g_rename instead of ::rename --- libs/ardour/session_state.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 7ccaca1a27..b66969176c 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -807,9 +807,9 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot } else { - if (::rename (tmp_path.c_str(), xml_path.c_str()) != 0) { - error << string_compose (_("could not rename temporary session file %1 to %2"), - tmp_path, xml_path) << endmsg; + if (g_rename (tmp_path.c_str(), xml_path.c_str()) != 0) { + error << string_compose (_("could not rename temporary session file %1 to %2 (%3)"), + tmp_path, xml_path, g_strerror(errno)) << endmsg; if (g_remove (tmp_path.c_str()) != 0) { error << string_compose(_("Could not remove temporary session file at path \"%1\" (%2)"), tmp_path, g_strerror (errno)) << endmsg; -- cgit v1.2.3 From 868b06efd65d59af023e37ab63d283c522feb121 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:10:11 -0400 Subject: Revert "Fix saving sessions on windows by using g_rename instead of ::rename" This reverts commit 2e2c22ad3c0af34b311024b1f8cb4571c1e3c48f. --- libs/ardour/session_state.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index b66969176c..7ccaca1a27 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -807,9 +807,9 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot } else { - if (g_rename (tmp_path.c_str(), xml_path.c_str()) != 0) { - error << string_compose (_("could not rename temporary session file %1 to %2 (%3)"), - tmp_path, xml_path, g_strerror(errno)) << endmsg; + if (::rename (tmp_path.c_str(), xml_path.c_str()) != 0) { + error << string_compose (_("could not rename temporary session file %1 to %2"), + tmp_path, xml_path) << endmsg; if (g_remove (tmp_path.c_str()) != 0) { error << string_compose(_("Could not remove temporary session file at path \"%1\" (%2)"), tmp_path, g_strerror (errno)) << endmsg; -- cgit v1.2.3 From ac16da8ea69482c104ab32bfddb35ab319572216 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:33:30 -0400 Subject: Fix saving sessions on windows by using g_rename instead of ::rename --- libs/ardour/session_state.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 7ccaca1a27..de573e61b6 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -807,9 +807,9 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot } else { - if (::rename (tmp_path.c_str(), xml_path.c_str()) != 0) { - error << string_compose (_("could not rename temporary session file %1 to %2"), - tmp_path, xml_path) << endmsg; + if (::g_rename (tmp_path.c_str(), xml_path.c_str()) != 0) { + error << string_compose (_("could not rename temporary session file %1 to %2 (%3)"), + tmp_path, xml_path, g_strerror(errno)) << endmsg; if (g_remove (tmp_path.c_str()) != 0) { error << string_compose(_("Could not remove temporary session file at path \"%1\" (%2)"), tmp_path, g_strerror (errno)) << endmsg; -- cgit v1.2.3 From 1bd570c27638d98154dea117a19433e6029b2316 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:39:55 -0400 Subject: Replace conditional peak debugging with DEBUG_TRACE macro usage Also add some extra debugging info --- libs/ardour/ardour/debug.h | 1 + libs/ardour/audiosource.cc | 88 +++++++++++++++------------------------------- libs/ardour/debug.cc | 1 + 3 files changed, 30 insertions(+), 60 deletions(-) diff --git a/libs/ardour/ardour/debug.h b/libs/ardour/ardour/debug.h index 202d0cc424..ae18e59c04 100644 --- a/libs/ardour/ardour/debug.h +++ b/libs/ardour/ardour/debug.h @@ -34,6 +34,7 @@ namespace PBD { extern uint64_t SnapBBT; extern uint64_t Configuration; extern uint64_t Latency; + extern uint64_t Peaks; extern uint64_t Processors; extern uint64_t ProcessThreads; extern uint64_t Graph; diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index da9be81007..ec2b912357 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -41,6 +41,8 @@ #include "i18n.h" +#include "ardour/debug.h" + using namespace std; using namespace ARDOUR; using namespace PBD; @@ -212,6 +214,8 @@ AudioSource::initialize_peakfile (string audio_path) peakpath = peak_path (audio_path); + DEBUG_TRACE(DEBUG::Peaks, string_compose ("Initialize Peakfile %1 for Audio file %2\n", peakpath, audio_path)); + /* if the peak file should be there, but isn't .... */ if (!empty() && !Glib::file_test (peakpath.c_str(), Glib::FILE_TEST_EXISTS)) { @@ -226,7 +230,7 @@ AudioSource::initialize_peakfile (string audio_path) return -1; } - /* peakfile does not exist */ + DEBUG_TRACE(DEBUG::Peaks, string_compose("Peakfile %1 does not exist\n", peakpath)); _peaks_built = false; @@ -235,7 +239,7 @@ AudioSource::initialize_peakfile (string audio_path) /* we found it in the peaks dir, so check it out */ if (statbuf.st_size == 0 || (statbuf.st_size < (off_t) ((length(_timeline_position) / _FPP) * sizeof (PeakData)))) { - // empty + DEBUG_TRACE(DEBUG::Peaks, string_compose("Peakfile %1 is empty\n", peakpath)); _peaks_built = false; } else { // Check if the audio file has changed since the peakfile was built. @@ -247,6 +251,7 @@ AudioSource::initialize_peakfile (string audio_path) /* no audio path - nested source or we can't read it or ... whatever, use the peakfile as-is. */ + DEBUG_TRACE(DEBUG::Peaks, string_compose("Error when calling stat on Peakfile %1\n", peakpath)); _peaks_built = true; _peak_byte_max = statbuf.st_size; @@ -325,18 +330,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t expected_peaks = (cnt / (double) samples_per_file_peak); scale = npeaks/expected_peaks; -#undef DEBUG_READ_PEAKS -#ifdef DEBUG_READ_PEAKS - cerr << "======>RP: npeaks = " << npeaks - << " start = " << start - << " cnt = " << cnt - << " len = " << _length - << " samples_per_visual_peak =" << samples_per_visual_peak - << " expected was " << expected_peaks << " ... scale = " << scale - << " PD ptr = " << peaks - <RP: npeaks = %1 start = %2 cnt = %3 len = %4 samples_per_visual_peak = %5 expected was %6 ... scale = %7 PD ptr = %8\n" + , npeaks, start, cnt, _length, samples_per_visual_peak, expected_peaks, scale, peaks)); /* fix for near-end-of-file conditions */ @@ -352,9 +347,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t if (npeaks == cnt) { -#ifdef DEBUG_READ_PEAKS - cerr << "RAW DATA\n"; -#endif + DEBUG_TRACE (DEBUG::Peaks, "RAW DATA\n"); + /* no scaling at all, just get the sample data and duplicate it for both max and min peak values. */ @@ -388,27 +382,15 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t return -1; } -#ifdef DEBUG_READ_PEAKS - cerr << "DIRECT PEAKS\n"; -#endif + DEBUG_TRACE (DEBUG::Peaks, "DIRECT PEAKS\n"); #ifndef WIN32 nread = ::pread (peakfile_fd, peaks, sizeof (PeakData)* npeaks, first_peak_byte); #endif if (nread != sizeof (PeakData) * npeaks) { - cerr << "AudioSource[" - << _name - << "]: cannot read peaks from peakfile! (read only " - << nread - << " not " - << npeaks - << "at sample " - << start - << " = byte " - << first_peak_byte - << ')' - << endl; + DEBUG_TRACE (DEBUG::Peaks, string_compose ("[%1]: Cannot read peaks from peakfile! (read only %2 not %3 at sample %4 = byte %5 )\n" + , _name, nread, npeaks, start, first_peak_byte)); delete peakfile_descriptor; return -1; } @@ -426,9 +408,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t if (scale < 1.0) { -#ifdef DEBUG_READ_PEAKS - cerr << "DOWNSAMPLE\n"; -#endif + DEBUG_TRACE (DEBUG::Peaks, "DOWNSAMPLE\n"); + /* the caller wants: - more frames-per-peak (lower resolution) than the peakfile, or to put it another way, @@ -475,9 +456,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t tnp = min ((framecnt_t)(_length/samples_per_file_peak - current_stored_peak), (framecnt_t) expected_peaks); to_read = min (chunksize, tnp); -#ifdef DEBUG_READ_PEAKS - cerr << "read " << sizeof (PeakData) * to_read << " from peakfile @ " << start_byte << endl; -#endif + DEBUG_TRACE (DEBUG::Peaks, string_compose ("reading %1 bytes from peakfile @ %2\n" + , sizeof (PeakData) * to_read, start_byte)); #ifndef WIN32 if ((nread = ::pread (peakfile_fd, staging, sizeof (PeakData) * to_read, start_byte)) @@ -485,20 +465,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t off_t fend = lseek (peakfile_fd, 0, SEEK_END); - cerr << "AudioSource[" - << _name - << "]: cannot read peak data from peakfile (" - << (nread / sizeof(PeakData)) - << " peaks instead of " - << to_read - << ") (" - << strerror (errno) - << ')' - << " at start_byte = " << start_byte - << " _length = " << _length << " versus len = " << fend - << " expected maxpeaks = " << (_length - current_frame)/samples_per_file_peak - << " npeaks was " << npeaks - << endl; + DEBUG_TRACE (DEBUG::Peaks, string_compose ("[%1]: cannot read peak data from peakfile (%2 peaks instead of %3) (%4) at start_byte = %5 _length = %6 versus len = %7 expected maxpeaks = %8 npeaks was %9" + , _name, (nread / sizeof(PeakData)), to_read, g_strerror (errno), start_byte, _length, fend, ((_length - current_frame)/samples_per_file_peak), npeaks)); goto out; } #endif @@ -536,9 +504,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t } else { -#ifdef DEBUG_READ_PEAKS - cerr << "UPSAMPLE\n"; -#endif + DEBUG_TRACE (DEBUG::Peaks, "UPSAMPLE\n"); + /* the caller wants - less frames-per-peak (more resolution) @@ -627,15 +594,11 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t delete [] staging; delete [] raw_staging; -#ifdef DEBUG_READ_PEAKS - cerr << "RP DONE\n"; -#endif + DEBUG_TRACE (DEBUG::Peaks, "READPEAKS DONE\n"); return ret; } -#undef DEBUG_PEAK_BUILD - int AudioSource::build_peaks_from_scratch () { @@ -643,6 +606,8 @@ AudioSource::build_peaks_from_scratch () const framecnt_t bufsize = 65536; // 256kB per disk read for mono data is about ideal + DEBUG_TRACE (DEBUG::Peaks, "Building peaks from scratch\n"); + int ret = -1; { @@ -692,6 +657,7 @@ AudioSource::build_peaks_from_scratch () out: if (ret) { + DEBUG_TRACE (DEBUG::Peaks, string_compose("Could not write peak data, attempting to remove peakfile %1\n", peakpath)); unlink (peakpath.c_str()); } @@ -879,6 +845,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame off_t target_length = blocksize * ((first_peak_byte + blocksize + 1) / blocksize); if (endpos < target_length) { + DEBUG_TRACE(DEBUG::Peaks, string_compose ("Truncating Peakfile %1\n", peakpath)); if (ftruncate (_peakfile_fd, target_length)) { /* error doesn't actually matter so continue on without testing */ } @@ -925,6 +892,7 @@ AudioSource::truncate_peakfile () off_t end = lseek (_peakfile_fd, 0, SEEK_END); if (end > _peak_byte_max) { + DEBUG_TRACE(DEBUG::Peaks, string_compose ("Truncating Peakfile %1\n", peakpath)); if (ftruncate (_peakfile_fd, _peak_byte_max)) { error << string_compose (_("could not truncate peakfile %1 to %2 (error: %3)"), peakpath, _peak_byte_max, errno) << endmsg; diff --git a/libs/ardour/debug.cc b/libs/ardour/debug.cc index afd5da2169..51115001cb 100644 --- a/libs/ardour/debug.cc +++ b/libs/ardour/debug.cc @@ -31,6 +31,7 @@ uint64_t PBD::DEBUG::MidiDiskstreamIO = PBD::new_debug_bit ("mididiskstreamio"); uint64_t PBD::DEBUG::SnapBBT = PBD::new_debug_bit ("snapbbt"); uint64_t PBD::DEBUG::Configuration = PBD::new_debug_bit ("configuration"); uint64_t PBD::DEBUG::Latency = PBD::new_debug_bit ("latency"); +uint64_t PBD::DEBUG::Peaks = PBD::new_debug_bit ("peaks"); uint64_t PBD::DEBUG::Processors = PBD::new_debug_bit ("processors"); uint64_t PBD::DEBUG::ProcessThreads = PBD::new_debug_bit ("processthreads"); uint64_t PBD::DEBUG::Graph = PBD::new_debug_bit ("graph"); -- cgit v1.2.3 From f754e1c0bbda7917dcfca600fc7ca77a76ea1286 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:40:42 -0400 Subject: Use boost::scoped_ptr to control scope of peakfile descriptor --- libs/ardour/audiosource.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index ec2b912357..e3f101d9d6 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -30,6 +30,8 @@ #include #include +#include + #include #include @@ -324,7 +326,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t PeakData* staging = 0; Sample* raw_staging = 0; - FdFileDescriptor* peakfile_descriptor = new FdFileDescriptor (peakpath, false, 0664); + boost::scoped_ptr peakfile_descriptor(new FdFileDescriptor (peakpath, false, 0664)); int peakfile_fd = -1; expected_peaks = (cnt / (double) samples_per_file_peak); @@ -365,7 +367,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t peaks[i].min = raw_staging[i]; } - delete peakfile_descriptor; delete [] raw_staging; return 0; } @@ -378,7 +379,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t if ((peakfile_fd = peakfile_descriptor->allocate ()) < 0) { error << string_compose(_("AudioSource: cannot open peakpath (a) \"%1\" (%2)"), peakpath, strerror (errno)) << endmsg; - delete peakfile_descriptor; return -1; } @@ -391,7 +391,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t if (nread != sizeof (PeakData) * npeaks) { DEBUG_TRACE (DEBUG::Peaks, string_compose ("[%1]: Cannot read peaks from peakfile! (read only %2 not %3 at sample %4 = byte %5 )\n" , _name, nread, npeaks, start, first_peak_byte)); - delete peakfile_descriptor; return -1; } @@ -399,7 +398,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t memset (&peaks[npeaks], 0, sizeof (PeakData) * zero_fill); } - delete peakfile_descriptor; return 0; } @@ -443,7 +441,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t if ((peakfile_fd = peakfile_descriptor->allocate ()) < 0) { error << string_compose(_("AudioSource: cannot open peakpath (b) \"%1\" (%2)"), peakpath, strerror (errno)) << endmsg; - delete peakfile_descriptor; delete [] staging; return 0; } @@ -589,8 +586,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t } out: - delete peakfile_descriptor; - delete [] staging; delete [] raw_staging; -- cgit v1.2.3 From b84d032b3a25f6b3522ac179495e927ae886ca48 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:41:48 -0400 Subject: Use boost::scoped_array in AudioSource::read_peaks --- libs/ardour/audiosource.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index e3f101d9d6..720cb481be 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -324,7 +325,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t framecnt_t zero_fill = 0; int ret = -1; PeakData* staging = 0; - Sample* raw_staging = 0; boost::scoped_ptr peakfile_descriptor(new FdFileDescriptor (peakpath, false, 0664)); int peakfile_fd = -1; @@ -355,9 +355,9 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t both max and min peak values. */ - Sample* raw_staging = new Sample[cnt]; + boost::scoped_array raw_staging(new Sample[cnt]); - if (read_unlocked (raw_staging, start, cnt) != cnt) { + if (read_unlocked (raw_staging.get(), start, cnt) != cnt) { error << _("cannot read sample data for unscaled peak computation") << endmsg; return -1; } @@ -367,7 +367,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t peaks[i].min = raw_staging[i]; } - delete [] raw_staging; return 0; } @@ -517,7 +516,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t framecnt_t i = 0; framecnt_t nvisual_peaks = 0; framecnt_t chunksize = (framecnt_t) min (cnt, (framecnt_t) 4096); - raw_staging = new Sample[chunksize]; + boost::scoped_array raw_staging(new Sample[chunksize]); framepos_t frame_pos = start; double pixel_pos = floor (frame_pos / samples_per_visual_peak); @@ -542,14 +541,14 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t this loop early */ - memset (raw_staging, 0, sizeof (Sample) * chunksize); + memset (raw_staging.get(), 0, sizeof (Sample) * chunksize); } else { to_read = min (chunksize, (_length - current_frame)); - if ((frames_read = read_unlocked (raw_staging, current_frame, to_read)) == 0) { + if ((frames_read = read_unlocked (raw_staging.get(), current_frame, to_read)) == 0) { error << string_compose(_("AudioSource[%1]: peak read - cannot read %2 samples at offset %3 of %4 (%5)"), _name, to_read, current_frame, _length, strerror (errno)) << endmsg; @@ -587,7 +586,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t out: delete [] staging; - delete [] raw_staging; DEBUG_TRACE (DEBUG::Peaks, "READPEAKS DONE\n"); -- cgit v1.2.3 From e5cc56a52303da563c98bae271ddcd9c07a5a22f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:42:34 -0400 Subject: Use boost::scoped_array for controlling scope of peak data in AudioSource::read_peaks --- libs/ardour/audiosource.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 720cb481be..f3b6926c00 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -324,7 +324,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t uint32_t nread; framecnt_t zero_fill = 0; int ret = -1; - PeakData* staging = 0; boost::scoped_ptr peakfile_descriptor(new FdFileDescriptor (peakpath, false, 0664)); int peakfile_fd = -1; @@ -419,7 +418,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t const framecnt_t chunksize = (framecnt_t) min (expected_peaks, 65536.0); - staging = new PeakData[chunksize]; + boost::scoped_array staging(new PeakData[chunksize]); /* compute the rounded up frame position */ @@ -440,7 +439,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t if ((peakfile_fd = peakfile_descriptor->allocate ()) < 0) { error << string_compose(_("AudioSource: cannot open peakpath (b) \"%1\" (%2)"), peakpath, strerror (errno)) << endmsg; - delete [] staging; return 0; } @@ -456,7 +454,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t , sizeof (PeakData) * to_read, start_byte)); #ifndef WIN32 - if ((nread = ::pread (peakfile_fd, staging, sizeof (PeakData) * to_read, start_byte)) + if ((nread = ::pread (peakfile_fd, staging.get(), sizeof (PeakData) * to_read, start_byte)) != sizeof (PeakData) * to_read) { off_t fend = lseek (peakfile_fd, 0, SEEK_END); @@ -585,7 +583,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t } out: - delete [] staging; DEBUG_TRACE (DEBUG::Peaks, "READPEAKS DONE\n"); -- cgit v1.2.3 From ebdf73a077013a6afa19ef5bf5ef84c0db39fe69 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:43:00 -0400 Subject: Remove use of goto in AudioSource::read_peaks --- libs/ardour/audiosource.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index f3b6926c00..c9b80e7a5c 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -323,7 +323,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t int32_t to_read; uint32_t nread; framecnt_t zero_fill = 0; - int ret = -1; boost::scoped_ptr peakfile_descriptor(new FdFileDescriptor (peakpath, false, 0664)); int peakfile_fd = -1; @@ -461,7 +460,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t DEBUG_TRACE (DEBUG::Peaks, string_compose ("[%1]: cannot read peak data from peakfile (%2 peaks instead of %3) (%4) at start_byte = %5 _length = %6 versus len = %7 expected maxpeaks = %8 npeaks was %9" , _name, (nread / sizeof(PeakData)), to_read, g_strerror (errno), start_byte, _length, fend, ((_length - current_frame)/samples_per_file_peak), npeaks)); - goto out; + return -1; } #endif i = 0; @@ -494,8 +493,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t memset (&peaks[npeaks], 0, sizeof (PeakData) * zero_fill); } - ret = 0; - } else { DEBUG_TRACE (DEBUG::Peaks, "UPSAMPLE\n"); @@ -550,7 +547,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t error << string_compose(_("AudioSource[%1]: peak read - cannot read %2 samples at offset %3 of %4 (%5)"), _name, to_read, current_frame, _length, strerror (errno)) << endmsg; - goto out; + return -1; } } @@ -578,15 +575,10 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t if (zero_fill) { memset (&peaks[npeaks], 0, sizeof (PeakData) * zero_fill); } - - ret = 0; } - out: - DEBUG_TRACE (DEBUG::Peaks, "READPEAKS DONE\n"); - - return ret; + return 0; } int -- cgit v1.2.3 From 90c2a1c69db04fd98f301330afa4d9656053821f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:43:36 -0400 Subject: Use boost::scoped_array in AudioSource::build_peaks_from_scratch --- libs/ardour/audiosource.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index c9b80e7a5c..30c1852de3 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -584,8 +584,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t int AudioSource::build_peaks_from_scratch () { - Sample* buf = 0; - const framecnt_t bufsize = 65536; // 256kB per disk read for mono data is about ideal DEBUG_TRACE (DEBUG::Peaks, "Building peaks from scratch\n"); @@ -605,20 +603,20 @@ AudioSource::build_peaks_from_scratch () framecnt_t cnt = _length; _peaks_built = false; - buf = new Sample[bufsize]; + boost::scoped_array buf(new Sample[bufsize]); while (cnt) { framecnt_t frames_to_read = min (bufsize, cnt); framecnt_t frames_read; - if ((frames_read = read_unlocked (buf, current_frame, frames_to_read)) != frames_to_read) { + if ((frames_read = read_unlocked (buf.get(), current_frame, frames_to_read)) != frames_to_read) { error << string_compose(_("%1: could not write read raw data for peak computation (%2)"), _name, strerror (errno)) << endmsg; done_with_peakfile_writes (false); goto out; } - if (compute_and_write_peaks (buf, current_frame, frames_read, true, false, _FPP)) { + if (compute_and_write_peaks (buf.get(), current_frame, frames_read, true, false, _FPP)) { break; } @@ -643,8 +641,6 @@ AudioSource::build_peaks_from_scratch () unlink (peakpath.c_str()); } - delete [] buf; - return ret; } -- cgit v1.2.3 From 394f2b3ca71ca324fe89fab7c1caae1bd55a9143 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Jul 2013 17:44:16 -0400 Subject: Use boost::scoped_array in AudioSource::compute_and_write_peaks --- libs/ardour/audiosource.cc | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 30c1852de3..35b7da2108 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -684,15 +684,13 @@ int AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, framecnt_t cnt, bool force, bool intermediate_peaks_ready, framecnt_t fpp) { - Sample* buf2 = 0; framecnt_t to_do; uint32_t peaks_computed; - PeakData* peakbuf = 0; - int ret = -1; framepos_t current_frame; framecnt_t frames_done; const size_t blocksize = (128 * 1024); off_t first_peak_byte; + boost::scoped_array buf2; if (_peakfile_descriptor == 0) { prepare_for_peakfile_writes (); @@ -718,7 +716,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame #ifndef WIN32 if (::pwrite (_peakfile_fd, &x, sizeof (PeakData), byte) != sizeof (PeakData)) { error << string_compose(_("%1: could not write peak file data (%2)"), _name, strerror (errno)) << endmsg; - goto out; + return -1; } #endif _peak_byte_max = max (_peak_byte_max, (off_t) (byte + sizeof(PeakData))); @@ -744,19 +742,19 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame /* make a new contiguous buffer containing leftovers and the new stuff */ to_do = cnt + peak_leftover_cnt; - buf2 = new Sample[to_do]; + buf2.reset(new Sample[to_do]); /* the remnants */ - memcpy (buf2, peak_leftovers, peak_leftover_cnt * sizeof (Sample)); + memcpy (buf2.get(), peak_leftovers, peak_leftover_cnt * sizeof (Sample)); /* the new stuff */ - memcpy (buf2+peak_leftover_cnt, buf, cnt * sizeof (Sample)); + memcpy (buf2.get()+peak_leftover_cnt, buf, cnt * sizeof (Sample)); /* no more leftovers */ peak_leftover_cnt = 0; /* use the temporary buffer */ - buf = buf2; + buf = buf2.get(); /* make sure that when we write into the peakfile, we startup where we left off */ @@ -766,7 +764,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame to_do = cnt; } - peakbuf = new PeakData[(to_do/fpp)+1]; + boost::scoped_array peakbuf(new PeakData[(to_do/fpp)+1]); peaks_computed = 0; current_frame = first_frame; frames_done = 0; @@ -831,9 +829,9 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame } #ifndef WIN32 - if (::pwrite (_peakfile_fd, peakbuf, sizeof (PeakData) * peaks_computed, first_peak_byte) != (ssize_t) (sizeof (PeakData) * peaks_computed)) { + if (::pwrite (_peakfile_fd, peakbuf.get(), sizeof (PeakData) * peaks_computed, first_peak_byte) != (ssize_t) (sizeof (PeakData) * peaks_computed)) { error << string_compose(_("%1: could not write peak file data (%2)"), _name, strerror (errno)) << endmsg; - goto out; + return -1; } #endif @@ -847,13 +845,7 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame } } - ret = 0; - - out: - delete [] peakbuf; - delete [] buf2; - - return ret; + return 0; } void -- cgit v1.2.3 From 13a0f14db71dd22b9a6c7f7039ebf6089144a7f8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 07:52:37 -0400 Subject: Use ::read instead of pread in AudioSource::read_peaks for portability This destroys the atomicity of pread() and thus suggests that we should do something else to ensure that multithread access to peakfiles (if it does in fact exist) is safe. OTOH, there may be no such thing, since they are designed for the GUI, which is single threaded (for now) --- libs/ardour/audiosource.cc | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 35b7da2108..776749fb57 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -370,8 +370,9 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t if (scale == 1.0) { + off_t offset = 0; off_t first_peak_byte = (start / samples_per_file_peak) * sizeof (PeakData); - + ssize_t bytes_to_read = sizeof (PeakData)* npeaks; /* open, read, close */ if ((peakfile_fd = peakfile_descriptor->allocate ()) < 0) { @@ -381,11 +382,16 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t DEBUG_TRACE (DEBUG::Peaks, "DIRECT PEAKS\n"); -#ifndef WIN32 - nread = ::pread (peakfile_fd, peaks, sizeof (PeakData)* npeaks, first_peak_byte); -#endif + offset = lseek (peakfile_fd, first_peak_byte, SEEK_SET); + + if (offset != first_peak_byte) { + error << string_compose(_("AudioSource: could not seek to correct location in peak file \"%1\" (%2)"), peakpath, strerror (errno)) << endmsg; + return -1; + } + + nread = ::read (peakfile_fd, peaks, bytes_to_read); - if (nread != sizeof (PeakData) * npeaks) { + if (nread != bytes_to_read) { DEBUG_TRACE (DEBUG::Peaks, string_compose ("[%1]: Cannot read peaks from peakfile! (read only %2 not %3 at sample %4 = byte %5 )\n" , _name, nread, npeaks, start, first_peak_byte)); return -1; @@ -448,13 +454,20 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t uint32_t start_byte = current_stored_peak * sizeof(PeakData); tnp = min ((framecnt_t)(_length/samples_per_file_peak - current_stored_peak), (framecnt_t) expected_peaks); to_read = min (chunksize, tnp); + ssize_t bytes_to_read = sizeof (PeakData) * to_read; DEBUG_TRACE (DEBUG::Peaks, string_compose ("reading %1 bytes from peakfile @ %2\n" - , sizeof (PeakData) * to_read, start_byte)); + , bytes_to_read, start_byte)); -#ifndef WIN32 - if ((nread = ::pread (peakfile_fd, staging.get(), sizeof (PeakData) * to_read, start_byte)) - != sizeof (PeakData) * to_read) { + + off_t offset = lseek (peakfile_fd, start_byte, SEEK_SET); + + if (offset != start_byte) { + error << string_compose(_("AudioSource: could not seek to correct location in peak file \"%1\" (%2)"), peakpath, strerror (errno)) << endmsg; + return -1; + } + + if ((nread = ::read (peakfile_fd, staging.get(), bytes_to_read)) != bytes_to_read) { off_t fend = lseek (peakfile_fd, 0, SEEK_END); @@ -462,7 +475,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t , _name, (nread / sizeof(PeakData)), to_read, g_strerror (errno), start_byte, _length, fend, ((_length - current_frame)/samples_per_file_peak), npeaks)); return -1; } -#endif i = 0; stored_peaks_read = nread / sizeof(PeakData); } -- cgit v1.2.3 From db3edc40184b8235df92fe44df066944bbd130aa Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 07:53:45 -0400 Subject: Use ::write instead of pwrite in AudioSource::compute_and_write_peaks for portability This destroys the atomicity of pwrite() and thus suggests that we should do something else to ensure that multithread access to peakfiles (if it does in fact exist) is safe. OTOH, there may be no such thing, since they are designed for the GUI, which is single threaded (for now) --- libs/ardour/audiosource.cc | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 776749fb57..ff92b8977d 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -725,12 +725,18 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame off_t byte = (peak_leftover_frame / fpp) * sizeof (PeakData); -#ifndef WIN32 - if (::pwrite (_peakfile_fd, &x, sizeof (PeakData), byte) != sizeof (PeakData)) { + off_t offset = lseek (_peakfile_fd, byte, SEEK_SET); + + if (offset != byte) { + error << string_compose(_("%1: could not seek in peak file data (%2)"), _name, strerror (errno)) << endmsg; + return -1; + } + + if (::write (_peakfile_fd, &x, sizeof (PeakData)) != sizeof (PeakData)) { error << string_compose(_("%1: could not write peak file data (%2)"), _name, strerror (errno)) << endmsg; return -1; } -#endif + _peak_byte_max = max (_peak_byte_max, (off_t) (byte + sizeof(PeakData))); { @@ -840,14 +846,24 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame } } -#ifndef WIN32 - if (::pwrite (_peakfile_fd, peakbuf.get(), sizeof (PeakData) * peaks_computed, first_peak_byte) != (ssize_t) (sizeof (PeakData) * peaks_computed)) { + + off_t offset = lseek(_peakfile_fd, first_peak_byte, SEEK_SET); + + if (offset != first_peak_byte) { + error << string_compose(_("%1: could not seek in peak file data (%2)"), _name, strerror (errno)) << endmsg; + return -1; + } + + ssize_t bytes_to_write = sizeof (PeakData) * peaks_computed; + + ssize_t bytes_written = ::write (_peakfile_fd, peakbuf.get(), bytes_to_write); + + if (bytes_written != bytes_to_write) { error << string_compose(_("%1: could not write peak file data (%2)"), _name, strerror (errno)) << endmsg; return -1; } -#endif - _peak_byte_max = max (_peak_byte_max, (off_t) (first_peak_byte + sizeof(PeakData)*peaks_computed)); + _peak_byte_max = max (_peak_byte_max, (off_t) (first_peak_byte + bytes_to_write)); if (frames_done) { Glib::Threads::Mutex::Lock lm (_peaks_ready_lock); -- cgit v1.2.3 From 5131b8300f26a9af790936389203fa94667aee67 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 07:54:29 -0400 Subject: Use g_open instead of ::open in PBD::FileManager g_open is a macro that evaluates to ::open on linux(and mac) so this is only a change for windows. --- libs/pbd/file_manager.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/pbd/file_manager.cc b/libs/pbd/file_manager.cc index e02bcc2b0d..0c79011af1 100644 --- a/libs/pbd/file_manager.cc +++ b/libs/pbd/file_manager.cc @@ -24,6 +24,9 @@ #include #include +#include +#include + #ifdef __APPLE__ #include #endif @@ -226,7 +229,7 @@ FdFileDescriptor::open () { /* we must have a lock on the FileManager's mutex */ - _fd = ::open (_path.c_str(), _writeable ? (O_RDWR | O_CREAT) : O_RDONLY, _mode); + _fd = ::g_open (_path.c_str(), _writeable ? (O_RDWR | O_CREAT) : O_RDONLY, _mode); return (_fd == -1); } -- cgit v1.2.3 From 542c4b024e8e06d4e4b55ae6dcf20c0bc4c5344d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 07:55:01 -0400 Subject: Don't use errno after g_file_test on windows --- libs/ardour/file_source.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc index 0921498186..06d4fb6175 100644 --- a/libs/ardour/file_source.cc +++ b/libs/ardour/file_source.cc @@ -496,13 +496,14 @@ FileSource::find_2X (Session& s, DataType type, const string& path, bool must_ex goto out; } +#ifndef WIN32 if (errno != ENOENT) { error << string_compose( _("Filesource: cannot check for existing file (%1): %2"), path, strerror (errno)) << endmsg; goto out; } - +#endif /* a new file */ isnew = true; ret = true; -- cgit v1.2.3 From f08d9591e6e16d81d71b8b81ff3c99d7f58c1f01 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 07:55:36 -0400 Subject: Fix reading and writing of files on windows in PBD::FileManager --- libs/pbd/file_manager.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libs/pbd/file_manager.cc b/libs/pbd/file_manager.cc index 0c79011af1..2cfa63ae39 100644 --- a/libs/pbd/file_manager.cc +++ b/libs/pbd/file_manager.cc @@ -228,8 +228,19 @@ bool FdFileDescriptor::open () { /* we must have a lock on the FileManager's mutex */ - - _fd = ::g_open (_path.c_str(), _writeable ? (O_RDWR | O_CREAT) : O_RDONLY, _mode); + + /* files must be opened with O_BINARY flag on windows + * or it treats the file as a text stream and puts in + * line endings in etc + */ +#ifdef WIN32 +#define WRITE_FLAGS O_RDWR | O_CREAT | O_BINARY +#define READ_FLAGS O_RDONLY | O_BINARY +#else +#define WRITE_FLAGS O_RDWR | O_CREAT +#define READ_FLAGS O_RDONLY +#endif + _fd = ::g_open (_path.c_str(), _writeable ? WRITE_FLAGS : READ_FLAGS, _mode); return (_fd == -1); } -- cgit v1.2.3 From 43f7813b248686bfa89600f91dccd83017dfe669 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 08:05:37 -0400 Subject: Fix portability of Session::source_search_path --- gtk2_ardour/ardour_ui.cc | 4 +-- gtk2_ardour/ardour_ui.h | 2 +- gtk2_ardour/missing_file_dialog.cc | 17 +++++++--- libs/ardour/ardour/file_source.h | 2 +- libs/ardour/ardour/session.h | 2 +- libs/ardour/file_source.cc | 31 ++++++----------- libs/ardour/session.cc | 69 +++++++++++++------------------------- 7 files changed, 53 insertions(+), 74 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index e3655a0d7a..91dbd999df 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -288,7 +288,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) /* and ambiguous files */ - ARDOUR::FileSource::AmbiguousFileName.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::ambiguous_file, this, _1, _2, _3)); + ARDOUR::FileSource::AmbiguousFileName.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::ambiguous_file, this, _1, _2)); /* lets get this party started */ @@ -4050,7 +4050,7 @@ ARDOUR_UI::missing_file (Session*s, std::string str, DataType type) } int -ARDOUR_UI::ambiguous_file (std::string file, std::string /*path*/, std::vector hits) +ARDOUR_UI::ambiguous_file (std::string file, std::vector hits) { AmbiguousFileDialog dialog (file, hits); diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 5817293b29..7a8a0193f1 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -713,7 +713,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void fontconfig_dialog (); int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type); - int ambiguous_file (std::string file, std::string path, std::vector hits); + int ambiguous_file (std::string file, std::vector hits); bool click_button_clicked (GdkEventButton *); diff --git a/gtk2_ardour/missing_file_dialog.cc b/gtk2_ardour/missing_file_dialog.cc index c7cb7f5edc..b1e2081a1d 100644 --- a/gtk2_ardour/missing_file_dialog.cc +++ b/gtk2_ardour/missing_file_dialog.cc @@ -19,12 +19,17 @@ #include "pbd/compose.h" #include "pbd/replace_all.h" #include "pbd/strsplit.h" +#include "pbd/search_path.h" #include "ardour/session.h" #include "missing_file_dialog.h" #include "i18n.h" +#ifdef SearchPath +#undef SearchPath +#endif + using namespace Gtk; using namespace std; using namespace ARDOUR; @@ -56,14 +61,18 @@ MissingFileDialog::MissingFileDialog (Session* s, const std::string& path, DataT break; } - string dirstr; + vector source_dirs = s->source_search_path (type); + vector::iterator i = source_dirs.begin(); + ostringstream oss; + oss << *i << endl; - dirstr = s->source_search_path (type); - replace_all (dirstr, ":", "\n"); + while (++i != source_dirs.end()) { + oss << *i << endl; + } msg.set_justify (JUSTIFY_CENTER); msg.set_markup (string_compose (_("%1 cannot find the %2 file\n\n%3\n\nin any of these folders:\n\n\ -%4\n\n"), PROGRAM_NAME, typestr, Glib::Markup::escape_text(path), Glib::Markup::escape_text (dirstr))); +%4\n\n"), PROGRAM_NAME, typestr, Glib::Markup::escape_text(path), Glib::Markup::escape_text (oss.str()))); HBox* hbox = manage (new HBox); hbox->pack_start (msg, false, true); diff --git a/libs/ardour/ardour/file_source.h b/libs/ardour/ardour/file_source.h index 5898d04f0a..52dca18feb 100644 --- a/libs/ardour/ardour/file_source.h +++ b/libs/ardour/ardour/file_source.h @@ -79,7 +79,7 @@ public: virtual void set_path (const std::string&); - static PBD::Signal3 > AmbiguousFileName; + static PBD::Signal2 > AmbiguousFileName; protected: FileSource (Session& session, DataType type, diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index a149224607..85866f99a5 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -820,7 +820,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void request_resume_timecode_transmission (); bool timecode_transmission_suspended () const; - std::string source_search_path(DataType) const; + std::vector source_search_path(DataType) const; void ensure_search_path_includes (const std::string& path, DataType type); std::list unknown_processors () const; diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc index 06d4fb6175..c7b03cbdb7 100644 --- a/libs/ardour/file_source.cc +++ b/libs/ardour/file_source.cc @@ -51,7 +51,7 @@ using namespace ARDOUR; using namespace PBD; using namespace Glib; -PBD::Signal3 > FileSource::AmbiguousFileName; +PBD::Signal2 > FileSource::AmbiguousFileName; FileSource::FileSource (Session& session, DataType type, const string& path, const string& origin, Source::Flag flag) : Source(session, type, path, flag) @@ -240,19 +240,15 @@ FileSource::find (Session& s, DataType type, const string& path, bool must_exist isnew = false; if (!Glib::path_is_absolute (path)) { - vector dirs; vector hits; string fullpath; + std::vector dirs = s.source_search_path (type); - string search_path = s.source_search_path (type); - - if (search_path.length() == 0) { + if (dirs.size() == 0) { error << _("FileSource: search path not set") << endmsg; goto out; } - split (search_path, dirs, ':'); - hits.clear (); for (vector::iterator i = dirs.begin(); i != dirs.end(); ++i) { @@ -296,7 +292,7 @@ FileSource::find (Session& s, DataType type, const string& path, bool must_exist /* more than one match: ask the user */ - int which = FileSource::AmbiguousFileName (path, search_path, de_duped_hits).get_value_or (-1); + int which = FileSource::AmbiguousFileName (path, de_duped_hits).get_value_or (-1); if (which < 0) { goto out; @@ -310,8 +306,7 @@ FileSource::find (Session& s, DataType type, const string& path, bool must_exist if (must_exist) { error << string_compose( - _("Filesource: cannot find required file (%1): while searching %2"), - path, search_path) << endmsg; + _("Filesource: cannot find required file (%1)"), path) << endmsg; goto out; } else { isnew = true; @@ -357,8 +352,6 @@ bool FileSource::find_2X (Session& s, DataType type, const string& path, bool must_exist, bool& isnew, uint16_t& chan, string& found_path) { - string search_path = s.source_search_path (type); - string pathstr = path; string::size_type pos; bool ret = false; @@ -369,18 +362,17 @@ FileSource::find_2X (Session& s, DataType type, const string& path, bool must_ex /* non-absolute pathname: find pathstr in search path */ - vector dirs; + vector dirs = s.source_search_path (type); + int cnt; string fullpath; string keeppath; - if (search_path.length() == 0) { + if (dirs.size() == 0) { error << _("FileSource: search path not set") << endmsg; goto out; } - split (search_path, dirs, ':'); - cnt = 0; for (vector::iterator i = dirs.begin(); i != dirs.end(); ++i) { @@ -437,16 +429,15 @@ FileSource::find_2X (Session& s, DataType type, const string& path, bool must_ex if (cnt > 1) { error << string_compose ( - _("FileSource: \"%1\" is ambigous when searching %2\n\t"), - pathstr, search_path) << endmsg; + _("FileSource: \"%1\" is ambigous when searching\n\t"), pathstr) << endmsg; goto out; } else if (cnt == 0) { if (must_exist) { error << string_compose( - _("Filesource: cannot find required file (%1): while searching %2"), - pathstr, search_path) << endmsg; + _("Filesource: cannot find required file (%1): while searching") + , pathstr) << endmsg; goto out; } else { isnew = true; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 914c6a9a77..476682158f 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -44,8 +44,8 @@ #include "pbd/stacktrace.h" #include "pbd/file_utils.h" #include "pbd/convert.h" -#include "pbd/strsplit.h" #include "pbd/unwind.h" +#include "pbd/search_path.h" #include "ardour/amp.h" #include "ardour/analyser.h" @@ -94,6 +94,10 @@ #include "i18n.h" +#ifdef SearchPath +#undef SearchPath +#endif + namespace ARDOUR { class MidiSource; class Processor; @@ -4420,18 +4424,18 @@ Session::end_time_changed (framepos_t old) } } -string +std::vector Session::source_search_path (DataType type) const { - vector s; + SearchPath sp; if (session_dirs.size() == 1) { switch (type) { case DataType::AUDIO: - s.push_back (_session_dir->sound_path()); + sp.push_back (_session_dir->sound_path()); break; case DataType::MIDI: - s.push_back (_session_dir->midi_path()); + sp.push_back (_session_dir->midi_path()); break; } } else { @@ -4439,10 +4443,10 @@ Session::source_search_path (DataType type) const SessionDirectory sdir (i->path); switch (type) { case DataType::AUDIO: - s.push_back (sdir.sound_path()); + sp.push_back (sdir.sound_path()); break; case DataType::MIDI: - s.push_back (sdir.midi_path()); + sp.push_back (sdir.midi_path()); break; } } @@ -4451,49 +4455,30 @@ Session::source_search_path (DataType type) const if (type == DataType::AUDIO) { const string sound_path_2X = _session_dir->sound_path_2X(); if (Glib::file_test (sound_path_2X, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_DIR)) { - if (find (s.begin(), s.end(), sound_path_2X) == s.end()) { - s.push_back (sound_path_2X); + if (find (sp.begin(), sp.end(), sound_path_2X) == sp.end()) { + sp.push_back (sound_path_2X); } } } - /* now check the explicit (possibly user-specified) search path - */ - - vector dirs; + // now check the explicit (possibly user-specified) search path switch (type) { case DataType::AUDIO: - split (config.get_audio_search_path (), dirs, ':'); + sp += SearchPath(config.get_audio_search_path ()); break; case DataType::MIDI: - split (config.get_midi_search_path (), dirs, ':'); + sp += SearchPath(config.get_midi_search_path ()); break; } - for (vector::iterator i = dirs.begin(); i != dirs.end(); ++i) { - if (find (s.begin(), s.end(), *i) == s.end()) { - s.push_back (*i); - } - } - - string search_path; - - for (vector::iterator si = s.begin(); si != s.end(); ++si) { - if (!search_path.empty()) { - search_path += ':'; - } - search_path += *si; - } - - return search_path; + return sp; } void Session::ensure_search_path_includes (const string& path, DataType type) { - string search_path; - vector dirs; + SearchPath sp; if (path == ".") { return; @@ -4501,16 +4486,14 @@ Session::ensure_search_path_includes (const string& path, DataType type) switch (type) { case DataType::AUDIO: - search_path = config.get_audio_search_path (); + sp += SearchPath(config.get_audio_search_path ()); break; case DataType::MIDI: - search_path = config.get_midi_search_path (); + sp += SearchPath (config.get_midi_search_path ()); break; } - split (search_path, dirs, ':'); - - for (vector::iterator i = dirs.begin(); i != dirs.end(); ++i) { + for (vector::iterator i = sp.begin(); i != sp.end(); ++i) { /* No need to add this new directory if it has the same inode as an existing one; checking inode rather than name prevents duplicated directories when we are using symlinks. @@ -4522,18 +4505,14 @@ Session::ensure_search_path_includes (const string& path, DataType type) } } - if (!search_path.empty()) { - search_path += ':'; - } - - search_path += path; + sp += path; switch (type) { case DataType::AUDIO: - config.set_audio_search_path (search_path); + config.set_audio_search_path (sp.to_string()); break; case DataType::MIDI: - config.set_midi_search_path (search_path); + config.set_midi_search_path (sp.to_string()); break; } } -- cgit v1.2.3 From c00e03cced06703acdf32331c92b9f533d9c3ece Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 08:06:09 -0400 Subject: Don't include jack/weakjack.h header when compiling for windows --- libs/ardour/ardour/audioengine.h | 3 +++ libs/ardour/audioengine.cc | 2 -- libs/ardour/port.cc | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 363238baad..10400c41d7 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -37,7 +37,10 @@ #include "pbd/signals.h" #include "pbd/stacktrace.h" +#ifndef WIN32 #include +#endif + #include #include #include diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 690012e529..a69e98283e 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -31,8 +31,6 @@ #include "pbd/unknown_type.h" #include "pbd/epa.h" -#include - #include "midi++/port.h" #include "midi++/jack_midi_port.h" #include "midi++/mmc.h" diff --git a/libs/ardour/port.cc b/libs/ardour/port.cc index 3473b73617..a1eacca96e 100644 --- a/libs/ardour/port.cc +++ b/libs/ardour/port.cc @@ -21,7 +21,9 @@ #include "libardour-config.h" #endif +#ifndef WIN32 #include // so that we can test for new functions at runtime +#endif #include "pbd/compose.h" #include "pbd/error.h" -- cgit v1.2.3 From 49edb904849af2e4519a2b7a670bd9834bb753ab Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 08:06:39 -0400 Subject: Add ladspa directory name to directory names --- libs/ardour/ardour/directory_names.h | 1 + libs/ardour/directory_names.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/libs/ardour/ardour/directory_names.h b/libs/ardour/ardour/directory_names.h index 9f7c778d33..cb4701d336 100644 --- a/libs/ardour/ardour/directory_names.h +++ b/libs/ardour/ardour/directory_names.h @@ -36,6 +36,7 @@ extern const char* const export_formats_dir_name; extern const char* const templates_dir_name; extern const char* const route_templates_dir_name; extern const char* const surfaces_dir_name; +extern const char* const ladspa_dir_name; extern const char* const user_config_dir_name; extern const char* const panner_dir_name; diff --git a/libs/ardour/directory_names.cc b/libs/ardour/directory_names.cc index 0632c6f8f2..6fb15eaabd 100644 --- a/libs/ardour/directory_names.cc +++ b/libs/ardour/directory_names.cc @@ -36,6 +36,7 @@ const char* const export_formats_dir_name = X_("export"); const char* const templates_dir_name = X_("templates"); const char* const route_templates_dir_name = X_("route_templates"); const char* const surfaces_dir_name = X_("surfaces"); +const char* const ladspa_dir_name = X_("ladspa"); const char* const panner_dir_name = X_("panners"); /* these should end up using variants of PROGRAM_NAME */ -- cgit v1.2.3 From 2c7a1179c627a35a47665c807ae82162bb838a9c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 08:07:12 -0400 Subject: Fix finding panner modules on windows by looking for files with *.dll extension --- libs/ardour/panner_manager.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/ardour/panner_manager.cc b/libs/ardour/panner_manager.cc index 06fc42aab9..4e4ad7fe4d 100644 --- a/libs/ardour/panner_manager.cc +++ b/libs/ardour/panner_manager.cc @@ -71,6 +71,7 @@ PannerManager::discover_panners () Glib::PatternSpec so_extension_pattern("*.so"); Glib::PatternSpec dylib_extension_pattern("*.dylib"); + Glib::PatternSpec dll_extension_pattern("*.dll"); find_matching_files_in_search_path (panner_search_path (), so_extension_pattern, panner_modules); @@ -78,6 +79,9 @@ PannerManager::discover_panners () find_matching_files_in_search_path (panner_search_path (), dylib_extension_pattern, panner_modules); + find_matching_files_in_search_path (panner_search_path (), + dll_extension_pattern, panner_modules); + DEBUG_TRACE (DEBUG::Panning, string_compose (_("looking for panners in %1"), panner_search_path().to_string())); for (vector::iterator i = panner_modules.begin(); i != panner_modules.end(); ++i) { -- cgit v1.2.3 From 5bc4e54b7da3eb139d699c6e371d43540c69b519 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 08:08:09 -0400 Subject: Add ARDOUR::ladspa_search_path function to get LADSPA module directories --- libs/ardour/ardour/ladspa_search_path.h | 39 +++++++++++++++++++++++ libs/ardour/ladspa_search_path.cc | 55 +++++++++++++++++++++++++++++++++ libs/ardour/wscript | 1 + 3 files changed, 95 insertions(+) create mode 100644 libs/ardour/ardour/ladspa_search_path.h create mode 100644 libs/ardour/ladspa_search_path.cc diff --git a/libs/ardour/ardour/ladspa_search_path.h b/libs/ardour/ardour/ladspa_search_path.h new file mode 100644 index 0000000000..791bba9188 --- /dev/null +++ b/libs/ardour/ardour/ladspa_search_path.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2011 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef ARDOUR_LADSPA_SEARCH_PATH_INCLUDED +#define ARDOUR_LADSPA_SEARCH_PATH_INCLUDED + +#include "pbd/search_path.h" + +namespace ARDOUR { + + /** + * return a SearchPath containing directories in which to look for + * LADSPA plugins. + * + * If LADSPA_PATH is defined then the SearchPath returned + * will contain the directories specified in it as well as the + * user and system directories. + */ + PBD::SearchPath ladspa_search_path (); + +} // namespace ARDOUR + +#endif diff --git a/libs/ardour/ladspa_search_path.cc b/libs/ardour/ladspa_search_path.cc new file mode 100644 index 0000000000..7b675d081d --- /dev/null +++ b/libs/ardour/ladspa_search_path.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 2011 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include + +#include "ardour/ladspa_search_path.h" +#include "ardour/directory_names.h" +#include "ardour/filesystem_paths.h" + +namespace { + const char * const ladspa_env_variable_name = "LADSPA_PATH"; +} // anonymous + +using namespace PBD; + +namespace ARDOUR { + +SearchPath +ladspa_search_path () +{ + SearchPath spath_env (Glib::getenv(ladspa_env_variable_name)); + + SearchPath spath (user_config_directory ()); + + spath += ardour_dll_directory (); + spath.add_subdirectory_to_paths (ladspa_dir_name); + +#ifndef WIN32 + spath.push_back ("/usr/local/lib64/ladspa"); + spath.push_back ("/usr/local/lib/ladspa"); + spath.push_back ("/usr/lib64/ladspa"); + spath.push_back ("/usr/lib/ladspa"); + spath.push_back ("/Library/Audio/Plug-Ins/LADSPA"); +#endif + + return spath_env + spath; +} + +} // namespace ARDOUR diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 4e7e23aa1a..94f2445859 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -101,6 +101,7 @@ libardour_sources = [ 'jack_slave.cc', 'kmeterdsp.cc', 'ladspa_plugin.cc', + 'ladspa_search_path.cc', 'location.cc', 'location_importer.cc', 'ltc_slave.cc', -- cgit v1.2.3 From 83e05ec0ec236f4dc327935377206966836027eb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 12:38:03 -0400 Subject: Use ARDOUR::ladspa_search_path and PBD::find_matching_files to find LADSPA modules --- libs/ardour/ardour/plugin_manager.h | 3 - libs/ardour/ladspa_search_path.cc | 6 ++ libs/ardour/plugin_manager.cc | 109 +++++++++++------------------------- 3 files changed, 40 insertions(+), 78 deletions(-) diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index a7a5703690..2464368ae7 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -51,7 +51,6 @@ class PluginManager : public boost::noncopyable { void refresh (); - int add_ladspa_directory (std::string dirpath); int add_windows_vst_directory (std::string dirpath); int add_lxvst_directory (std::string dirpath); @@ -103,7 +102,6 @@ class PluginManager : public boost::noncopyable { std::map rdf_type; - std::string ladspa_path; std::string windows_vst_path; std::string lxvst_path; @@ -127,7 +125,6 @@ class PluginManager : public boost::noncopyable { int lxvst_discover_from_path (std::string path); int lxvst_discover (std::string path); - int ladspa_discover_from_path (std::string path); int ladspa_discover (std::string path); std::string get_ladspa_category (uint32_t id); diff --git a/libs/ardour/ladspa_search_path.cc b/libs/ardour/ladspa_search_path.cc index 7b675d081d..6ecc1557a3 100644 --- a/libs/ardour/ladspa_search_path.cc +++ b/libs/ardour/ladspa_search_path.cc @@ -19,6 +19,8 @@ #include +#include "pbd/pathexpand.h" + #include "ardour/ladspa_search_path.h" #include "ardour/directory_names.h" #include "ardour/filesystem_paths.h" @@ -46,6 +48,10 @@ ladspa_search_path () spath.push_back ("/usr/local/lib/ladspa"); spath.push_back ("/usr/lib64/ladspa"); spath.push_back ("/usr/lib/ladspa"); +#endif + +#ifdef __APPLE__ + spath.push_back (expand_path ("~/Library/Audio/Plug-Ins/LADSPA")); spath.push_back ("/Library/Audio/Plug-Ins/LADSPA"); #endif diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 6ea0292872..8d4e625876 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -45,9 +45,11 @@ #endif //LXVST_SUPPORT #include +#include #include "pbd/pathscanner.h" #include "pbd/whitespace.h" +#include "pbd/file_utils.h" #include "ardour/debug.h" #include "ardour/filesystem_paths.h" @@ -57,6 +59,12 @@ #include "ardour/plugin_manager.h" #include "ardour/rc_configuration.h" +#ifdef SearchPath +#undef SearchPath +#endif + +#include "ardour/ladspa_search_path.h" + #ifdef LV2_SUPPORT #include "ardour/lv2_plugin.h" #endif @@ -79,6 +87,8 @@ #include "i18n.h" +#include "ardour/debug.h" + using namespace ARDOUR; using namespace PBD; using namespace std; @@ -128,10 +138,6 @@ PluginManager::PluginManager () } #endif /* Native LinuxVST support*/ - if ((s = getenv ("LADSPA_PATH"))) { - ladspa_path = s; - } - if ((s = getenv ("VST_PATH"))) { windows_vst_path = s; } else if ((s = getenv ("VST_PLUGINS"))) { @@ -200,91 +206,38 @@ PluginManager::refresh () void PluginManager::ladspa_refresh () { - if (_ladspa_plugin_info) + if (_ladspa_plugin_info) { _ladspa_plugin_info->clear (); - else + } else { _ladspa_plugin_info = new ARDOUR::PluginInfoList (); - - static const char *standard_paths[] = { - "/usr/local/lib64/ladspa", - "/usr/local/lib/ladspa", - "/usr/lib64/ladspa", - "/usr/lib/ladspa", - "/Library/Audio/Plug-Ins/LADSPA", - "" - }; + } /* allow LADSPA_PATH to augment, not override standard locations */ /* Only add standard locations to ladspa_path if it doesn't * already contain them. Check for trailing G_DIR_SEPARATOR too. */ + + vector ladspa_modules; - int i; - for (i = 0; standard_paths[i][0]; i++) { - size_t found = ladspa_path.find(standard_paths[i]); - if (found != ladspa_path.npos) { - switch (ladspa_path[found + strlen(standard_paths[i])]) { - case ':' : - case '\0': - continue; - case G_DIR_SEPARATOR : - if (ladspa_path[found + strlen(standard_paths[i]) + 1] == ':' || - ladspa_path[found + strlen(standard_paths[i]) + 1] == '\0') { - continue; - } - } - } - if (!ladspa_path.empty()) - ladspa_path += ":"; - - ladspa_path += standard_paths[i]; - - } - - DEBUG_TRACE (DEBUG::PluginManager, string_compose ("LADSPA: search along: [%1]\n", ladspa_path)); - - ladspa_discover_from_path (ladspa_path); -} - - -int -PluginManager::add_ladspa_directory (string path) -{ - if (ladspa_discover_from_path (path) == 0) { - ladspa_path += ':'; - ladspa_path += path; - return 0; - } - return -1; -} - -static bool ladspa_filter (const string& str, void */*arg*/) -{ - /* Not a dotfile, has a prefix before a period, suffix is "so" */ - - return str[0] != '.' && (str.length() > 3 && str.find (".so") == (str.length() - 3)); -} + DEBUG_TRACE (DEBUG::PluginManager, string_compose ("LADSPA: search along: [%1]\n", ladspa_search_path().to_string())); -int -PluginManager::ladspa_discover_from_path (string /*path*/) -{ - PathScanner scanner; - vector *plugin_objects; - vector::iterator x; - int ret = 0; + Glib::PatternSpec so_extension_pattern("*.so"); + Glib::PatternSpec dylib_extension_pattern("*.dylib"); + Glib::PatternSpec dll_extension_pattern("*.dll"); - plugin_objects = scanner (ladspa_path, ladspa_filter, 0, false, true); + find_matching_files_in_search_path (ladspa_search_path (), + so_extension_pattern, ladspa_modules); - if (plugin_objects) { - for (x = plugin_objects->begin(); x != plugin_objects->end (); ++x) { - ladspa_discover (**x); - } + find_matching_files_in_search_path (ladspa_search_path (), + dylib_extension_pattern, ladspa_modules); + + find_matching_files_in_search_path (ladspa_search_path (), + dll_extension_pattern, ladspa_modules); - vector_delete (plugin_objects); + for (vector::iterator i = ladspa_modules.begin(); i != ladspa_modules.end(); ++i) { + ladspa_discover (*i); } - - return ret; } static bool rdf_filter (const string &str, void* /*arg*/) @@ -370,6 +323,8 @@ PluginManager::add_lrdf_data (const string &path) int PluginManager::ladspa_discover (string path) { + DEBUG_TRACE (DEBUG::PluginManager, string_compose ("Checking for LADSPA plugin at %1\n", path)); + Glib::Module module(path); const LADSPA_Descriptor *descriptor; LADSPA_Descriptor_Function dfunc; @@ -390,6 +345,8 @@ PluginManager::ladspa_discover (string path) dfunc = (LADSPA_Descriptor_Function)func; + DEBUG_TRACE (DEBUG::PluginManager, string_compose ("LADSPA plugin found at %1\n", path)); + for (uint32_t i = 0; ; ++i) { if ((descriptor = dfunc (i)) == 0) { break; @@ -443,6 +400,8 @@ PluginManager::ladspa_discover (string path) if(!found){ _ladspa_plugin_info->push_back (info); } + + DEBUG_TRACE (DEBUG::PluginManager, string_compose ("Found LADSPA plugin, name: %1, Inputs: %2, Outputs: %3\n", info->name, info->n_inputs, info->n_outputs)); } // GDB WILL NOT LIKE YOU IF YOU DO THIS -- cgit v1.2.3 From 81dbc20bacfe1566065ada3cf49ec98939a609b1 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 12:40:06 -0400 Subject: Add basic test for PluginManager and LADSPA plugins --- libs/ardour/test/plugins_test.cc | 54 ++++++++++++++++++++++++++++++++++++++++ libs/ardour/test/plugins_test.h | 12 +++++++++ libs/ardour/wscript | 2 ++ 3 files changed, 68 insertions(+) create mode 100644 libs/ardour/test/plugins_test.cc create mode 100644 libs/ardour/test/plugins_test.h diff --git a/libs/ardour/test/plugins_test.cc b/libs/ardour/test/plugins_test.cc new file mode 100644 index 0000000000..362a56df7f --- /dev/null +++ b/libs/ardour/test/plugins_test.cc @@ -0,0 +1,54 @@ +#include + +#include "ardour/plugin_manager.h" +#include "ardour/ladspa_search_path.h" + +#include "plugins_test.h" +#include "test_common.h" + +CPPUNIT_TEST_SUITE_REGISTRATION (PluginsTest); + +using namespace std; +using namespace ARDOUR; +using namespace PBD; + +void +print_plugin_info (PluginInfoPtr pp) +{ + cout << "LADSPA Plugin, name " << pp->name + << ", category " << pp->category + << ", creator " << pp->creator + << ", path " << pp->path + << ", n_inputs " << pp->n_inputs.n_audio () + << ", n_outputs " << pp->n_outputs.n_audio () + << endl; + +} + +void +PluginsTest::test () +{ + PluginManager& pm = PluginManager::instance (); + + pm.refresh (); + + SearchPath ladspa_paths(ladspa_search_path ()); + + cout << "Number of Ladspa paths found: " << ladspa_paths.size () << endl; + + for (vector::iterator i = ladspa_paths.begin (); i != ladspa_paths.end(); ++i) + { + cout << "LADSPA search path includes: " << *i << endl; + } + + PluginInfoList& ladspa_list = pm.ladspa_plugin_info (); + + cout << "Number of Ladspa plugins found: " << ladspa_list.size () << endl; + + for (PluginInfoList::iterator i = ladspa_list.begin (); i != ladspa_list.end(); ++i) + { + print_plugin_info (*i); + } + + +} diff --git a/libs/ardour/test/plugins_test.h b/libs/ardour/test/plugins_test.h new file mode 100644 index 0000000000..1503b2bde2 --- /dev/null +++ b/libs/ardour/test/plugins_test.h @@ -0,0 +1,12 @@ +#include +#include + +class PluginsTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (PluginsTest); + CPPUNIT_TEST (test); + CPPUNIT_TEST_SUITE_END (); + +public: + void test (); +}; diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 94f2445859..256ff1c6c0 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -481,6 +481,7 @@ def build(bld): create_ardour_test_program(bld, obj.includes, 'framepos_minus_beats', 'test_framepos_minus_beats', ['test/framepos_minus_beats_test.cc']) create_ardour_test_program(bld, obj.includes, 'playlist_equivalent_regions', 'test_playlist_equivalent_regions', ['test/playlist_equivalent_regions_test.cc']) create_ardour_test_program(bld, obj.includes, 'playlist_layering', 'test_playlist_layering', ['test/playlist_layering_test.cc']) + create_ardour_test_program(bld, obj.includes, 'plugins_test', 'test_plugins', ['test/plugins_test.cc']) create_ardour_test_program(bld, obj.includes, 'region_naming', 'test_region_naming', ['test/region_naming_test.cc']) create_ardour_test_program(bld, obj.includes, 'control_surface', 'test_control_surfaces', ['test/control_surfaces_test.cc']) create_ardour_test_program(bld, obj.includes, 'mtdm_test', 'test_mtdm', ['test/mtdm_test.cc']) @@ -498,6 +499,7 @@ def build(bld): test/framepos_minus_beats_test.cc test/playlist_equivalent_regions_test.cc test/playlist_layering_test.cc + test/plugins_test.cc test/region_naming_test.cc test/control_surfaces_test.cc test/mtdm_test.cc -- cgit v1.2.3 From ea0e42dee748e67feaeb84c7fe407f69c6cf740b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 12:40:34 -0400 Subject: Use g_stat in AudioSource::touch_peakfile for portability --- libs/ardour/audiosource.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index ff92b8977d..fc1cc23fa0 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -30,8 +30,11 @@ #include #include -#include +#include +#include + #include +#include #include #include @@ -179,7 +182,7 @@ AudioSource::touch_peakfile () { struct stat statbuf; - if (stat (peakpath.c_str(), &statbuf) != 0 || statbuf.st_size == 0) { + if (g_stat (peakpath.c_str(), &statbuf) != 0 || statbuf.st_size == 0) { return; } -- cgit v1.2.3 From dca2774508a577bd817a80db9b80f056d95190f1 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 12:41:01 -0400 Subject: Use g_utime for portability in AudioSource::touch_peakfile --- libs/ardour/audiosource.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index fc1cc23fa0..93a1c6ceb5 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -191,7 +191,7 @@ AudioSource::touch_peakfile () tbuf.actime = statbuf.st_atime; tbuf.modtime = time ((time_t) 0); - utime (peakpath.c_str(), &tbuf); + g_utime (peakpath.c_str(), &tbuf); } int -- cgit v1.2.3 From 4a8aadbbdf7e93d4c237c33ee6b79b212aa868b2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 12:41:24 -0400 Subject: Use g_rename in AudioSource::rename_peakfile for portability --- libs/ardour/audiosource.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 93a1c6ceb5..92d35ab1d3 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -202,7 +202,7 @@ AudioSource::rename_peakfile (string newpath) string oldpath = peakpath; if (Glib::file_test (oldpath, Glib::FILE_TEST_EXISTS)) { - if (rename (oldpath.c_str(), newpath.c_str()) != 0) { + if (g_rename (oldpath.c_str(), newpath.c_str()) != 0) { error << string_compose (_("cannot rename peakfile for %1 from %2 to %3 (%4)"), _name, oldpath, newpath, strerror (errno)) << endmsg; return -1; } -- cgit v1.2.3 From 3e1c66f946fe90033277cbab2681a705fb987acb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 12:41:53 -0400 Subject: Use g_stat in AudioSource::initialize_peakfile for portability --- libs/ardour/audiosource.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 92d35ab1d3..d8c25b0200 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -228,7 +228,7 @@ AudioSource::initialize_peakfile (string audio_path) peakpath = find_broken_peakfile (peakpath, audio_path); } - if (stat (peakpath.c_str(), &statbuf)) { + if (g_stat (peakpath.c_str(), &statbuf)) { if (errno != ENOENT) { /* it exists in the peaks dir, but there is some kind of error */ -- cgit v1.2.3 From a8647faca7d60ba6404239f2ebcff1631028fbad Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 12:46:35 -0400 Subject: Add JACK utility functions in libardour and test This contains much of the code present in the GUI EngineDialog class but refactored with some added windows bits. --- libs/ardour/ardour/jack_utils.h | 261 ++++++++++ libs/ardour/jack_utils.cc | 947 ++++++++++++++++++++++++++++++++++++ libs/ardour/test/jack_utils_test.cc | 315 ++++++++++++ libs/ardour/test/jack_utils_test.h | 33 ++ libs/ardour/wscript | 14 +- 5 files changed, 1568 insertions(+), 2 deletions(-) create mode 100644 libs/ardour/ardour/jack_utils.h create mode 100644 libs/ardour/jack_utils.cc create mode 100644 libs/ardour/test/jack_utils_test.cc create mode 100644 libs/ardour/test/jack_utils_test.h diff --git a/libs/ardour/ardour/jack_utils.h b/libs/ardour/ardour/jack_utils.h new file mode 100644 index 0000000000..353724f079 --- /dev/null +++ b/libs/ardour/ardour/jack_utils.h @@ -0,0 +1,261 @@ +/* + Copyright (C) 2011 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include + +#include +#include +#include + +namespace ARDOUR { + + // Names for the drivers on all possible systems + extern const char * const portaudio_driver_name; + extern const char * const coreaudio_driver_name; + extern const char * const alsa_driver_name; + extern const char * const oss_driver_name; + extern const char * const freebob_driver_name; + extern const char * const ffado_driver_name; + extern const char * const netjack_driver_name; + extern const char * const dummy_driver_name; + + /** + * Get a list of possible JACK audio driver names based on platform + */ + void get_jack_audio_driver_names (std::vector& driver_names); + + /** + * Get the default JACK audio driver based on platform + */ + void get_jack_default_audio_driver_name (std::string& driver_name); + + /** + * Get a list of possible JACK midi driver names based on platform + */ + void get_jack_midi_system_names (const std::string& driver, std::vector& driver_names); + + /** + * Get the default JACK midi driver based on platform + */ + void get_jack_default_midi_system_name (const std::string& driver_name, std::string& midi_system); + + /** + * Get a list of possible samplerates supported be JACK + */ + void get_jack_sample_rate_strings (std::vector& sample_rates); + + /** + * @return The default samplerate + */ + std::string get_jack_default_sample_rate (); + + /** + * @return true if sample rate string was able to be converted + */ + bool get_jack_sample_rate_value_from_string (const std::string& srs, uint32_t& srv); + + /** + * Get a list of possible period sizes supported be JACK + */ + void get_jack_period_size_strings (std::vector& samplerates); + + /** + * @return The default period size + */ + std::string get_jack_default_period_size (); + + /** + * @return true if period size string was able to be converted + */ + bool get_jack_period_size_value_from_string (const std::string& pss, uint32_t& psv); + + /** + * These are driver specific I think, so it may require a driver arg + * in future + */ + void get_jack_dither_mode_strings (const std::string& driver, std::vector& dither_modes); + + /** + * @return The default dither mode + */ + std::string get_jack_default_dither_mode (const std::string& driver); + + /** + * @return Estimate of latency + * + * API matches current use in GUI + */ + std::string get_jack_latency_string (std::string samplerate, float periods, std::string period_size); + + /** + * @return true if a JACK server is running + */ + bool jack_server_running (); + + /** + * Key being a readable name to display in a GUI + * Value being name used in a jack commandline + */ + typedef std::map device_map_t; + + /** + * Use library specific code to find out what what devices exist for a given + * driver that might work in JACK. There is no easy way to find out what + * modules the JACK server supports so guess based on platform. For instance + * portaudio is cross-platform but we only return devices if built for + * windows etc + */ + void get_jack_alsa_device_names (device_map_t& devices); + void get_jack_portaudio_device_names (device_map_t& devices); + void get_jack_coreaudio_device_names (device_map_t& devices); + void get_jack_oss_device_names (device_map_t& devices); + void get_jack_freebob_device_names (device_map_t& devices); + void get_jack_ffado_device_names (device_map_t& devices); + void get_jack_netjack_device_names (device_map_t& devices); + void get_jack_dummy_device_names (device_map_t& devices); + + /* + * @return true if there were devices found for the driver + * + * @param driver The driver name returned by get_jack_audio_driver_names + * @param devices The map used to insert the drivers into, devices will be cleared before + * adding the available drivers + */ + bool get_jack_device_names_for_audio_driver (const std::string& driver, device_map_t& devices); + + /* + * @return a list of readable device names for a specific driver. + */ + std::vector get_jack_device_names_for_audio_driver (const std::string& driver); + + /** + * @return true if the driver supports playback and recording + * on separate devices + */ + bool get_jack_audio_driver_supports_two_devices (const std::string& driver); + + bool get_jack_audio_driver_supports_latency_adjustment (const std::string& driver); + + bool get_jack_audio_driver_supports_setting_period_count (const std::string& driver); + + /** + * The possible names to use to try and find servers, this includes + * any file extensions like .exe on Windows + * + * @return true if the JACK application names for this platform could be guessed + */ + bool get_jack_server_application_names (std::vector& server_names); + + /** + * Sets the PATH environment variable to contain directories likely to contain + * JACK servers so that if the JACK server is auto-started it can find the server + * executable. + * + * This is only modifies PATH on the mac at the moment. + */ + void set_path_env_for_jack_autostart (const std::vector&); + + /** + * Get absolute paths to directories that might contain JACK servers on the system + * + * @return true if !server_paths.empty() + */ + bool get_jack_server_dir_paths (std::vector& server_dir_paths); + + /** + * Get absolute paths to JACK servers on the system + * + * @return true if a server was found + */ + bool get_jack_server_paths (const std::vector& server_dir_paths, + const std::vector& server_names, + std::vector& server_paths); + + + bool get_jack_server_paths (std::vector& server_paths); + + /** + * Get absolute path to default JACK server + */ + bool get_jack_default_server_path (std::string& server_path); + + /** + * @return The name of the jack server config file + */ + std::string get_jack_server_config_file_name (); + + std::string get_jack_server_user_config_dir_path (); + + std::string get_jack_server_user_config_file_path (); + + bool write_jack_config_file (const std::string& config_file_path, const std::string& command_line); + + struct JackCommandLineOptions { + + // see implementation for defaults + JackCommandLineOptions (); + + //operator bool + //operator ostream + + std::string server_path; + uint32_t timeout; + bool no_mlock; + uint32_t ports_max; + bool realtime; + uint32_t priority; + bool unlock_gui_libs; + bool verbose; + bool temporary; + bool playback_only; + bool capture_only; + std::string driver; + std::string input_device; + std::string output_device; + uint32_t num_periods; + uint32_t period_size; + uint32_t samplerate; + uint32_t input_latency; + uint32_t output_latency; + bool hardware_metering; + bool hardware_monitoring; + std::string dither_mode; + bool force16_bit; + bool soft_mode; + std::string midi_driver; + }; + + /** + * @return true if able to build a valid command line based on options + */ + bool get_jack_command_line_string (const JackCommandLineOptions& options, std::string& command_line); + + /** + * We don't need this at the moment because the gui stores all its settings + */ + //std::string get_jack_command_line_from_config_file (const std::string& config_file_path); + + /** + * Temporary for WIN32 only as jack_client_open doesn't start the server on that platform + * + * @return true if server was able to be started + */ + bool start_jack_server (const std::string& command_line); + +} diff --git a/libs/ardour/jack_utils.cc b/libs/ardour/jack_utils.cc new file mode 100644 index 0000000000..29f7ca4f3e --- /dev/null +++ b/libs/ardour/jack_utils.cc @@ -0,0 +1,947 @@ +/* + Copyright (C) 2010 Paul Davis + Copyright (C) 2011 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifdef WAF_BUILD +#include "libardour-config.h" +#endif + +#ifdef HAVE_ALSA +#include +#endif + +#ifdef __APPLE__ +#include +#include +#include +#include +#endif + +#ifdef HAVE_PORTAUDIO +#include +#endif + +#include + +#include + +#include + +#include + +#include "pbd/epa.h" +#include "pbd/error.h" +#include "pbd/convert.h" +#include "pbd/file_utils.h" +#include "pbd/search_path.h" + +#include "ardour/jack_utils.h" + +#ifdef __APPLE +#include +#endif + +#include "i18n.h" + +using namespace std; +using namespace PBD; + +namespace ARDOUR { + // The pretty driver names + const char * const portaudio_driver_name = X_("Portaudio"); + const char * const coreaudio_driver_name = X_("CoreAudio"); + const char * const alsa_driver_name = X_("ALSA"); + const char * const oss_driver_name = X_("OSS"); + const char * const freebob_driver_name = X_("FreeBoB"); + const char * const ffado_driver_name = X_("FFADO"); + const char * const netjack_driver_name = X_("NetJACK"); + const char * const dummy_driver_name = X_("Dummy"); +} + +namespace { + + // The real driver names + const char * const portaudio_driver_command_line_name = X_("portaudio"); + const char * const coreaudio_driver_command_line_name = X_("coreaudio"); + const char * const alsa_driver_command_line_name = X_("alsa"); + const char * const oss_driver_command_line_name = X_("oss"); + const char * const freebob_driver_command_line_name = X_("freebob"); + const char * const ffado_driver_command_line_name = X_("firewire"); + const char * const netjack_driver_command_line_name = X_("netjack"); + const char * const dummy_driver_command_line_name = X_("dummy"); + + // should we provide more "pretty" names like above? + const char * const alsaseq_midi_driver_name = X_("seq"); + const char * const alsaraw_midi_driver_name = X_("raw"); + const char * const winmme_midi_driver_name = X_("winmme"); + const char * const coremidi_midi_driver_name = X_("coremidi"); + + // this should probably be translated + const char * const default_device_name = X_("Default"); +} + +std::string +get_none_string () +{ + return _("None"); +} + +void +ARDOUR::get_jack_audio_driver_names (vector& audio_driver_names) +{ +#ifdef WIN32 + audio_driver_names.push_back (portaudio_driver_name); +#elif __APPLE__ + audio_driver_names.push_back (coreaudio_driver_name); +#else +#ifdef HAVE_ALSA + audio_driver_names.push_back (alsa_driver_name); +#endif + audio_driver_names.push_back (oss_driver_name); + audio_driver_names.push_back (freebob_driver_name); + audio_driver_names.push_back (ffado_driver_name); +#endif + audio_driver_names.push_back (netjack_driver_name); + audio_driver_names.push_back (dummy_driver_name); +} + +void +ARDOUR::get_jack_default_audio_driver_name (string& audio_driver_name) +{ + vector drivers; + get_jack_audio_driver_names (drivers); + audio_driver_name = drivers.front (); +} + +void +ARDOUR::get_jack_midi_system_names (const string& driver, vector& midi_system_names) +{ + midi_system_names.push_back (get_none_string ()); +#ifdef WIN32 + midi_system_names.push_back (winmme_midi_driver_name); +#elif __APPLE__ + midi_system_names.push_back (coreaudio_midi_driver_name); +#else +#ifdef HAVE_ALSA + if (driver == alsa_driver_name) { + midi_system_names.push_back (alsaseq_midi_driver_name); + midi_system_names.push_back (alsaraw_midi_driver_name); + } +#endif +#endif +} + +void +ARDOUR::get_jack_default_midi_system_name (const string& driver, string& midi_system_name) +{ + vector drivers; + get_jack_midi_system_names (driver, drivers); + midi_system_name = drivers.front (); +} + +void +ARDOUR::get_jack_sample_rate_strings (vector& samplerates) +{ + // do these really need to be translated? + samplerates.push_back (_("8000Hz")); + samplerates.push_back (_("22050Hz")); + samplerates.push_back (_("44100Hz")); + samplerates.push_back (_("48000Hz")); + samplerates.push_back (_("88200Hz")); + samplerates.push_back (_("96000Hz")); + samplerates.push_back (_("192000Hz")); +} + +string +ARDOUR::get_jack_default_sample_rate () +{ + return _("48000Hz"); +} + +void +ARDOUR::get_jack_period_size_strings (std::vector& period_sizes) +{ + period_sizes.push_back ("32"); + period_sizes.push_back ("64"); + period_sizes.push_back ("128"); + period_sizes.push_back ("256"); + period_sizes.push_back ("512"); + period_sizes.push_back ("1024"); + period_sizes.push_back ("2048"); + period_sizes.push_back ("4096"); + period_sizes.push_back ("8192"); +} + +string +ARDOUR::get_jack_default_period_size () +{ + return "1024"; +} + +void +ARDOUR::get_jack_dither_mode_strings (const string& driver, vector& dither_modes) +{ + dither_modes.push_back (get_none_string ()); + + if (driver == alsa_driver_name ) { + dither_modes.push_back (_("Triangular")); + dither_modes.push_back (_("Rectangular")); + dither_modes.push_back (_("Shaped")); + } +} + +string +ARDOUR::get_jack_default_dither_mode (const string& driver) +{ + return get_none_string (); +} + +string +ARDOUR::get_jack_latency_string (string samplerate, float periods, string period_size) +{ + uint32_t rate = atoi (samplerate); + float psize = atof (period_size); + + char buf[32]; + snprintf (buf, sizeof(buf), "%.1fmsec", (periods * psize) / (rate/1000.0)); + + return buf; +} + +bool +get_jack_command_line_audio_driver_name (const string& driver_name, string& command_line_name) +{ + using namespace ARDOUR; + if (driver_name == portaudio_driver_name) { + command_line_name = portaudio_driver_command_line_name; + return true; + } else if (driver_name == coreaudio_driver_name) { + command_line_name = coreaudio_driver_command_line_name; + return true; + } else if (driver_name == alsa_driver_name) { + command_line_name = alsa_driver_command_line_name; + return true; + } else if (driver_name == oss_driver_name) { + command_line_name = oss_driver_command_line_name; + return true; + } else if (driver_name == freebob_driver_name) { + command_line_name = freebob_driver_command_line_name; + return true; + } else if (driver_name == ffado_driver_name) { + command_line_name = ffado_driver_command_line_name; + return true; + } else if (driver_name == netjack_driver_name) { + command_line_name = netjack_driver_command_line_name; + return true; + } else if (driver_name == dummy_driver_name) { + command_line_name = dummy_driver_command_line_name; + return true; + } + return false; +} + +bool +get_jack_command_line_audio_device_name (const string& driver_name, + const string& device_name, string& command_line_device_name) +{ + using namespace ARDOUR; + device_map_t devices; + + get_jack_device_names_for_audio_driver (driver_name, devices); + + for (device_map_t::const_iterator i = devices.begin (); i != devices.end(); ++i) { + if (i->first == device_name) { + command_line_device_name = i->second; + return true; + } + } + return false; +} + +bool +get_jack_command_line_dither_mode (const string& dither_mode, string& command_line_dither_mode) +{ + using namespace ARDOUR; + + if (dither_mode == _("Triangular")) { + command_line_dither_mode = "triangular"; + return true; + } else if (dither_mode == _("Rectangular")) { + command_line_dither_mode = "rectangular"; + return true; + } else if (dither_mode == _("Shaped")) { + command_line_dither_mode = "shaped"; + return true; + } + + return false; +} + +bool +ARDOUR::jack_server_running () +{ + EnvironmentalProtectionAgency* global_epa = EnvironmentalProtectionAgency::get_global_epa (); + boost::scoped_ptr current_epa; + + /* revert all environment settings back to whatever they were when ardour started + */ + + if (global_epa) { + current_epa.reset (new EnvironmentalProtectionAgency(true)); /* will restore settings when we leave scope */ + global_epa->restore (); + } + + jack_status_t status; + jack_client_t* c = jack_client_open ("ardourprobe", JackNoStartServer, &status); + + if (status == 0) { + jack_client_close (c); + return true; + } + return false; + +} + +void +ARDOUR::get_jack_alsa_device_names (device_map_t& devices) +{ +#ifdef HAVE_ALSA + snd_ctl_t *handle; + snd_ctl_card_info_t *info; + snd_pcm_info_t *pcminfo; + snd_ctl_card_info_alloca(&info); + snd_pcm_info_alloca(&pcminfo); + string devname; + int cardnum = -1; + int device = -1; + + while (snd_card_next (&cardnum) >= 0 && cardnum >= 0) { + + devname = "hw:"; + devname += PBD::to_string (cardnum, std::dec); + + if (snd_ctl_open (&handle, devname.c_str(), 0) >= 0 && snd_ctl_card_info (handle, info) >= 0) { + + while (snd_ctl_pcm_next_device (handle, &device) >= 0 && device >= 0) { + + snd_pcm_info_set_device (pcminfo, device); + snd_pcm_info_set_subdevice (pcminfo, 0); + snd_pcm_info_set_stream (pcminfo, SND_PCM_STREAM_PLAYBACK); + + if (snd_ctl_pcm_info (handle, pcminfo) >= 0) { + devname += ','; + devname += PBD::to_string (device, std::dec); + devices.insert (std::make_pair (snd_pcm_info_get_name (pcminfo), devname)); + } + } + + snd_ctl_close(handle); + } + } +#endif +} + +#ifdef __APPLE__ +static OSStatus +getDeviceUIDFromID( AudioDeviceID id, char *name, size_t nsize) +{ + UInt32 size = sizeof(CFStringRef); + CFStringRef UI; + OSStatus res = AudioDeviceGetProperty(id, 0, false, + kAudioDevicePropertyDeviceUID, &size, &UI); + if (res == noErr) + CFStringGetCString(UI,name,nsize,CFStringGetSystemEncoding()); + CFRelease(UI); + return res; +} +#endif + +void +ARDOUR::get_jack_coreaudio_device_names (device_map_t& devices) +{ +#ifdef __APPLE__ + // Find out how many Core Audio devices are there, if any... + // (code snippet gently "borrowed" from St?hane Letz jackdmp;) + OSStatus err; + Boolean isWritable; + UInt32 outSize = sizeof(isWritable); + + err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, + &outSize, &isWritable); + if (err == noErr) { + // Calculate the number of device available... + int numCoreDevices = outSize / sizeof(AudioDeviceID); + // Make space for the devices we are about to get... + AudioDeviceID *coreDeviceIDs = new AudioDeviceID [numCoreDevices]; + err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, + &outSize, (void *) coreDeviceIDs); + if (err == noErr) { + // Look for the CoreAudio device name... + char coreDeviceName[256]; + UInt32 nameSize; + + for (int i = 0; i < numCoreDevices; i++) { + + nameSize = sizeof (coreDeviceName); + + /* enforce duplex devices only */ + + err = AudioDeviceGetPropertyInfo(coreDeviceIDs[i], + 0, true, kAudioDevicePropertyStreams, + &outSize, &isWritable); + + if (err != noErr || outSize == 0) { + continue; + } + + err = AudioDeviceGetPropertyInfo(coreDeviceIDs[i], + 0, false, kAudioDevicePropertyStreams, + &outSize, &isWritable); + + if (err != noErr || outSize == 0) { + continue; + } + + err = AudioDeviceGetPropertyInfo(coreDeviceIDs[i], + 0, true, kAudioDevicePropertyDeviceName, + &outSize, &isWritable); + if (err == noErr) { + err = AudioDeviceGetProperty(coreDeviceIDs[i], + 0, true, kAudioDevicePropertyDeviceName, + &nameSize, (void *) coreDeviceName); + if (err == noErr) { + char drivername[128]; + + // this returns the unique id for the device + // that must be used on the commandline for jack + + if (getDeviceUIDFromID(coreDeviceIDs[i], drivername, sizeof (drivername)) == noErr) { + devices.insert (make_pair (coreDeviceName, drivername)); + } + } + } + } + } + delete [] coreDeviceIDs; + } +#endif +} + +void +ARDOUR::get_jack_portaudio_device_names (device_map_t& devices) +{ +#ifdef HAVE_PORTAUDIO + if (Pa_Initialize() != paNoError) { + return; + } + + for (PaDeviceIndex i = 0; i < Pa_GetDeviceCount (); ++i) { + string api_name; + string readable_name; + string jack_device_name; + const PaDeviceInfo* device_info = Pa_GetDeviceInfo(i); + + if (device_info != NULL) { // it should never be ? + api_name = Pa_GetHostApiInfo (device_info->hostApi)->name; + readable_name = api_name + " " + device_info->name; + jack_device_name = api_name + "::" + device_info->name; + devices.insert (make_pair (readable_name, jack_device_name)); + } + } + Pa_Terminate(); +#endif +} + +void +ARDOUR::get_jack_oss_device_names (device_map_t& devices) +{ + devices.insert (make_pair (default_device_name, default_device_name)); +} + +void +ARDOUR::get_jack_freebob_device_names (device_map_t& devices) +{ + devices.insert (make_pair (default_device_name, default_device_name)); +} + +void +ARDOUR::get_jack_ffado_device_names (device_map_t& devices) +{ + devices.insert (make_pair (default_device_name, default_device_name)); +} + +void +ARDOUR::get_jack_netjack_device_names (device_map_t& devices) +{ + devices.insert (make_pair (default_device_name, default_device_name)); +} + +void +ARDOUR::get_jack_dummy_device_names (device_map_t& devices) +{ + devices.insert (make_pair (default_device_name, default_device_name)); +} + +bool +ARDOUR::get_jack_device_names_for_audio_driver (const string& driver_name, device_map_t& devices) +{ + devices.clear(); + + if (driver_name == portaudio_driver_name) { + get_jack_portaudio_device_names (devices); + } else if (driver_name == coreaudio_driver_name) { + get_jack_coreaudio_device_names (devices); + } else if (driver_name == alsa_driver_name) { + get_jack_alsa_device_names (devices); + } else if (driver_name == oss_driver_name) { + get_jack_oss_device_names (devices); + } else if (driver_name == freebob_driver_name) { + get_jack_freebob_device_names (devices); + } else if (driver_name == ffado_driver_name) { + get_jack_ffado_device_names (devices); + } else if (driver_name == netjack_driver_name) { + get_jack_netjack_device_names (devices); + } else if (driver_name == dummy_driver_name) { + get_jack_dummy_device_names (devices); + } + + return !devices.empty(); +} + + +std::vector +ARDOUR::get_jack_device_names_for_audio_driver (const string& driver_name) +{ + std::vector readable_names; + device_map_t devices; + + get_jack_device_names_for_audio_driver (driver_name, devices); + + for (device_map_t::const_iterator i = devices.begin (); i != devices.end(); ++i) { + readable_names.push_back (i->first); + } + + return readable_names; +} + +bool +ARDOUR::get_jack_audio_driver_supports_two_devices (const string& driver) +{ + return (driver == alsa_driver_name || driver == oss_driver_name); +} + +bool +ARDOUR::get_jack_audio_driver_supports_latency_adjustment (const string& driver) +{ + return (driver == alsa_driver_name || driver == coreaudio_driver_name || + driver == ffado_driver_name || driver == portaudio_driver_name); +} + +bool +ARDOUR::get_jack_audio_driver_supports_setting_period_count (const string& driver) +{ + return !(driver == dummy_driver_name || driver == coreaudio_driver_name || + driver == portaudio_driver_name); +} + +bool +ARDOUR::get_jack_server_application_names (std::vector& server_names) +{ +#ifdef WIN32 + server_names.push_back ("jackd.exe"); +#else + server_names.push_back ("jackd"); + server_names.push_back ("jackdmp"); +#endif + return !server_names.empty(); +} + +void +ARDOUR::set_path_env_for_jack_autostart (const vector& dirs) +{ +#ifdef __APPLE__ + // push it back into the environment so that auto-started JACK can find it. + // XXX why can't we just expect OS X users to have PATH set correctly? we can't ... + setenv ("PATH", SearchPath(dirs).to_string(), 1); +#endif +} + +bool +ARDOUR::get_jack_server_dir_paths (vector& server_dir_paths) +{ +#ifdef __APPLE__ + /* this magic lets us finds the path to the OSX bundle, and then + we infer JACK's location from there + */ + + char execpath[MAXPATHLEN+1]; + uint32_t pathsz = sizeof (execpath); + + _NSGetExecutablePath (execpath, &pathsz); + + server_dir_paths.push_back (Glib::path_get_dirname (execpath)); +#endif + + SearchPath sp(string(g_getenv("PATH"))); + +#ifdef WIN32 + gchar *install_dir = g_win32_get_package_installation_directory_of_module (NULL); + if (install_dir) { + sp.push_back (install_dir); + g_free (install_dir); + } + // don't try and use a system wide JACK install yet. +#else + if (sp.empty()) { + sp.push_back ("/usr/bin"); + sp.push_back ("/bin"); + sp.push_back ("/usr/local/bin"); + sp.push_back ("/opt/local/bin"); + } +#endif + + std::copy (sp.begin(), sp.end(), std::back_inserter(server_dir_paths)); + + return !server_dir_paths.empty(); +} + +bool +ARDOUR::get_jack_server_paths (const vector& server_dir_paths, + const vector& server_names, + vector& server_paths) +{ + for (vector::const_iterator i = server_names.begin(); i != server_names.end(); ++i) { + find_matching_files_in_directories (server_dir_paths, Glib::PatternSpec(*i), server_paths); + } + return !server_paths.empty(); +} + +bool +ARDOUR::get_jack_server_paths (vector& server_paths) +{ + vector server_dirs; + + if (!get_jack_server_dir_paths (server_dirs)) { + return false; + } + + vector server_names; + + if (!get_jack_server_application_names (server_names)) { + return false; + } + + if (!get_jack_server_paths (server_dirs, server_names, server_paths)) { + return false; + } + + return !server_paths.empty(); +} + +bool +ARDOUR::get_jack_default_server_path (std::string& server_path) +{ + vector server_paths; + + if (!get_jack_server_paths (server_paths)) { + return false; + } + + server_path = server_paths.front (); + return true; +} + +string +quote_string (const string& str) +{ + return "\"" + str + "\""; +} + +ARDOUR::JackCommandLineOptions::JackCommandLineOptions () + : server_path () + , timeout(0) + , no_mlock(false) + , ports_max(128) + , realtime(true) + , priority(0) + , unlock_gui_libs(false) + , verbose(false) + , temporary(true) + , driver() + , input_device() + , output_device() + , num_periods(2) + , period_size(1024) + , samplerate(48000) + , input_latency(0) + , output_latency(0) + , hardware_metering(false) + , hardware_monitoring(false) + , dither_mode() + , force16_bit(false) + , soft_mode(false) + , midi_driver() +{ + +} + +bool +ARDOUR::get_jack_command_line_string (const JackCommandLineOptions& options, string& command_line) +{ + vector args; + + args.push_back (options.server_path); + +#ifdef WIN32 + // must use sync mode on windows + args.push_back ("-S"); + + // this needs to be added now on windows + if (!options.midi_driver.empty () && options.midi_driver != get_none_string ()) { + args.push_back ("-X"); + args.push_back (options.midi_driver); + } +#endif + + if (options.timeout) { + args.push_back ("-t"); + args.push_back (to_string (options.timeout, std::dec)); + } + + if (options.no_mlock) { + args.push_back ("-m"); + } + + args.push_back ("-p"); + args.push_back (to_string(options.ports_max, std::dec)); + + if (options.realtime) { + args.push_back ("-R"); + if (options.priority != 0) { + args.push_back ("-P"); + args.push_back (to_string(options.priority, std::dec)); + } + } else { + args.push_back ("-r"); + } + + if (options.unlock_gui_libs) { + args.push_back ("-u"); + } + + if (options.verbose) { + args.push_back ("-v"); + } + +#ifndef WIN32 + if (options.temporary) { + args.push_back ("-T"); + } +#endif + + string command_line_driver_name; + + if (!get_jack_command_line_audio_driver_name (options.driver, command_line_driver_name)) { + return false; + } + + args.push_back ("-d"); + args.push_back (command_line_driver_name); + + if (options.output_device.empty() && options.input_device.empty()) { + return false; + } + + string command_line_input_device_name; + string command_line_output_device_name; + + if (!get_jack_command_line_audio_device_name (options.driver, + options.input_device, command_line_input_device_name)) + { + return false; + } + + if (!get_jack_command_line_audio_device_name (options.driver, + options.output_device, command_line_output_device_name)) + { + return false; + } + + if (options.input_device.empty()) { + // playback only + if (options.output_device.empty()) { + return false; + } + args.push_back ("-P"); + } else if (options.output_device.empty()) { + // capture only + if (options.input_device.empty()) { + return false; + } + args.push_back ("-C"); + } else if (options.input_device != options.output_device) { + // capture and playback on two devices if supported + if (get_jack_audio_driver_supports_two_devices (options.driver)) { + args.push_back ("-C"); + args.push_back (command_line_input_device_name); + args.push_back ("-P"); + args.push_back (command_line_output_device_name); + } else { + return false; + } + } + + if (get_jack_audio_driver_supports_setting_period_count (options.driver)) { + args.push_back ("-n"); + args.push_back (to_string (options.num_periods, std::dec)); + } + + args.push_back ("-r"); + args.push_back (to_string (options.samplerate, std::dec)); + + args.push_back ("-p"); + args.push_back (to_string (options.period_size, std::dec)); + + if (get_jack_audio_driver_supports_latency_adjustment (options.driver)) { + if (options.input_latency) { + args.push_back ("-I"); + args.push_back (to_string (options.input_latency, std::dec)); + } + if (options.output_latency) { + args.push_back ("-0"); + args.push_back (to_string (options.output_latency, std::dec)); + } + } + + if (options.input_device == options.output_device && options.input_device != default_device_name) { + args.push_back ("-d"); + args.push_back (command_line_input_device_name); + } + + if (options.driver == alsa_driver_name) { + if (options.hardware_metering) { + args.push_back ("-M"); + } + if (options.hardware_monitoring) { + args.push_back ("-H"); + } + + string command_line_dither_mode; + if (get_jack_command_line_dither_mode (options.dither_mode, command_line_dither_mode)) { + args.push_back ("-z"); + args.push_back (command_line_dither_mode); + } + if (options.force16_bit) { + args.push_back ("-S"); + } + if (options.soft_mode) { + args.push_back ("-s"); + } + + if (!options.midi_driver.empty() && options.midi_driver != get_none_string ()) { + args.push_back ("-X"); + args.push_back (options.midi_driver); + } + } + + ostringstream oss; + + for (vector::const_iterator i = args.begin(); i != args.end();) { +#ifdef WIN32 + oss << quote_string (*i); +#else + oss << *i; +#endif + if (++i != args.end()) oss << ' '; + } + + command_line = oss.str(); + return true; +} + +string +ARDOUR::get_jack_server_config_file_name () +{ + return ".jackdrc"; +} + +std::string +ARDOUR::get_jack_server_user_config_dir_path () +{ + return Glib::get_home_dir (); +} + +std::string +ARDOUR::get_jack_server_user_config_file_path () +{ + return Glib::build_filename (get_jack_server_user_config_dir_path (), get_jack_server_config_file_name ()); +} + +bool +ARDOUR::write_jack_config_file (const std::string& config_file_path, const string& command_line) +{ + ofstream jackdrc (config_file_path.c_str()); + + if (!jackdrc) { + error << string_compose (_("cannot open JACK rc file %1 to store parameters"), config_file_path) << endmsg; + return false; + } + + jackdrc << command_line << endl; + jackdrc.close (); + return true; +} + +bool +ARDOUR::start_jack_server (const string& command_line) +{ +#ifdef WIN32 + STARTUPINFO si; + PROCESS_INFORMATION pi; + char * cmdline = g_strdup (command_line.c_str()); + + memset (&si, 0, sizeof (si)); + si.cb = sizeof (&si); + memset (&pi, 0, sizeof (pi)); + + if (!CreateProcess ( + NULL, // No module name, use command line + cmdline, + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // set handle inheritance to false + 0, // No creation flags + NULL, // Use parents environment block + NULL, // Use parents starting directory + &si, + &pi)) + { + error << string_compose ("cannot start JACK server: %s", g_win32_error_message (GetLastError ())) << endmsg; + } + + g_free (cmdline); + + // wait for 2 seconds for server to start + for (int i = 0; i < 8; ++i) { + Sleep (250); // 1/4 second + if (jack_server_running ()) return true; + } +#endif + return false; +} diff --git a/libs/ardour/test/jack_utils_test.cc b/libs/ardour/test/jack_utils_test.cc new file mode 100644 index 0000000000..ed80237f78 --- /dev/null +++ b/libs/ardour/test/jack_utils_test.cc @@ -0,0 +1,315 @@ + +#include + +#ifdef WIN32 +#include // only for Sleep +#endif + +#include + +#include "ardour/jack_utils.h" + +#include "jack_utils_test.h" + +CPPUNIT_TEST_SUITE_REGISTRATION (JackUtilsTest); + +using namespace std; +using namespace ARDOUR; + +void +JackUtilsTest::test_driver_names () +{ + vector driver_names; + + get_jack_audio_driver_names (driver_names); + + CPPUNIT_ASSERT(!driver_names.empty()); + + cout << endl; + cout << "Number of possible JACK Audio drivers found on this system: " << driver_names.size () << endl; + + for (vector::const_iterator i = driver_names.begin(); i != driver_names.end(); ++i) { + cout << "JACK Audio driver found: " << *i << endl; + } + + string default_audio_driver; + get_jack_default_audio_driver_name (default_audio_driver); + + cout << "The default audio driver on this system is: " << default_audio_driver << endl; + + driver_names.clear(); + + get_jack_midi_system_names (default_audio_driver, driver_names); + + CPPUNIT_ASSERT(!driver_names.empty()); + + cout << "Number of possible JACK MIDI drivers found on this system for default audio driver: " << driver_names.size () << endl; + + for (vector::const_iterator i = driver_names.begin(); i != driver_names.end(); ++i) { + cout << "JACK MIDI driver found: " << *i << endl; + } + + string default_midi_driver; + get_jack_default_midi_system_name (default_audio_driver, default_midi_driver); + + cout << "The default midi driver on this system is: " << default_midi_driver << endl; +} + +string +devices_string (const vector& devices) +{ + std::string str; + for (vector::const_iterator i = devices.begin(); i != devices.end();) { + str += *i; + if (++i != devices.end()) str += ", "; + } + return str; +} + +void +JackUtilsTest::test_device_names () +{ + vector driver_names; + + get_jack_audio_driver_names (driver_names); + + CPPUNIT_ASSERT(!driver_names.empty()); + + cout << endl; + + for (vector::const_iterator i = driver_names.begin(); i != driver_names.end(); ++i) { + string devices = devices_string (get_jack_device_names_for_audio_driver (*i)); + cout << "JACK Audio driver found: " << *i << " with devices: " << devices << endl; + } +} + +void +JackUtilsTest::test_samplerates () +{ + vector samplerates; + + get_jack_sample_rate_strings (samplerates); + cout << endl; + cout << "Number of possible Samplerates supported by JACK: " << samplerates.size () << endl; + + for (vector::const_iterator i = samplerates.begin(); i != samplerates.end(); ++i) { + cout << "Samplerate: " << *i << endl; + } +} + +void +JackUtilsTest::test_period_sizes () +{ + vector period_sizes; + + get_jack_period_size_strings (period_sizes); + cout << endl; + cout << "Number of possible Period sizes supported by JACK: " << period_sizes.size () << endl; + + for (vector::const_iterator i = period_sizes.begin(); i != period_sizes.end(); ++i) { + cout << "Period size: " << *i << endl; + } +} + +void +JackUtilsTest::test_dither_modes () +{ + vector driver_names; + + get_jack_audio_driver_names (driver_names); + + CPPUNIT_ASSERT(!driver_names.empty()); + + cout << endl; + + for (vector::const_iterator i = driver_names.begin(); i != driver_names.end(); ++i) { + vector dither_modes; + + get_jack_dither_mode_strings (*i, dither_modes); + cout << "Number of possible Dither Modes supported by JACK driver " << *i << + ": " << dither_modes.size () << endl; + for (vector::const_iterator j = dither_modes.begin(); j != dither_modes.end(); ++j) { + cout << "Dither Mode: " << *j << endl; + } + cout << endl; + } + +} + +void +JackUtilsTest::test_connect_server () +{ + cout << endl; + if (jack_server_running ()) { + cout << "Jack server running " << endl; + } else { + cout << "Jack server not running " << endl; + } +} + +void +JackUtilsTest::test_set_jack_path_env () +{ + cout << endl; + + bool path_env_set = false; + + string path_env = Glib::getenv ("PATH", path_env_set); + + if (path_env_set) { + cout << "PATH env set to: " << path_env << endl; + } else { + cout << "PATH env not set" << endl; + } + vector server_dirs; + get_jack_server_dir_paths (server_dirs); + set_path_env_for_jack_autostart (server_dirs); + + path_env_set = false; + + path_env = Glib::getenv ("PATH", path_env_set); + + CPPUNIT_ASSERT (path_env_set); + + cout << "After set_jack_path_env PATH env set to: " << path_env << endl; +} + +void +JackUtilsTest::test_server_paths () +{ + cout << endl; + + vector server_dirs; + + CPPUNIT_ASSERT (get_jack_server_dir_paths (server_dirs)); + + cout << "Number of Directories that may contain JACK servers: " << server_dirs.size () << endl; + + for (vector::const_iterator i = server_dirs.begin(); i != server_dirs.end(); ++i) { + cout << "JACK server directory path: " << *i << endl; + } + + vector server_names; + + CPPUNIT_ASSERT (get_jack_server_application_names (server_names)); + + cout << "Number of possible JACK server names on this system: " << server_names.size () << endl; + + for (vector::const_iterator i = server_names.begin(); i != server_names.end(); ++i) { + cout << "JACK server name: " << *i << endl; + } + + vector server_paths; + + CPPUNIT_ASSERT (get_jack_server_paths (server_dirs, server_names, server_paths)); + + cout << "Number of JACK servers on this system: " << server_paths.size () << endl; + + for (vector::const_iterator i = server_paths.begin(); i != server_paths.end(); ++i) { + cout << "JACK server path: " << *i << endl; + } + + vector server_paths2; + + CPPUNIT_ASSERT (get_jack_server_paths (server_paths2)); + + CPPUNIT_ASSERT (server_paths.size () == server_paths2.size ()); + + std::string default_server_path; + + CPPUNIT_ASSERT (get_jack_default_server_path (default_server_path)); + + cout << "The default JACK server on this system: " << default_server_path << endl; +} + +void +JackUtilsTest::test_config () +{ + +} + +void +JackUtilsTest::test_command_line () +{ + cout << endl; + + JackCommandLineOptions options; + + CPPUNIT_ASSERT (get_jack_default_server_path (options.server_path)); + + get_jack_default_audio_driver_name (options.driver); + + string command_line; + + // should fail, haven't set any device yet + CPPUNIT_ASSERT (!get_jack_command_line_string (options, command_line)); + + vector devices = get_jack_device_names_for_audio_driver (options.driver); + + if (!devices.empty()) { + options.input_device = devices.front (); + options.output_device = devices.front (); + } else { + cout << "No audio devices available using default JACK driver using Dummy driver" << endl; + options.driver = dummy_driver_name; + devices = get_jack_device_names_for_audio_driver (options.driver); + CPPUNIT_ASSERT (!devices.empty ()); + options.input_device = devices.front (); + options.output_device = devices.front (); + } + + options.input_device = devices.front (); + options.output_device = devices.front (); + + string midi_driver; + + get_jack_default_midi_system_name (options.driver, options.midi_driver); + + // this at least should create a valid jack command line + CPPUNIT_ASSERT (get_jack_command_line_string (options, command_line)); + + cout << "Default JACK command line: " << command_line << endl; +} + +void +JackUtilsTest::test_start_server () +{ +#ifdef WIN32 + cout << endl; + + JackCommandLineOptions options; + + CPPUNIT_ASSERT (get_jack_default_server_path (options.server_path)); + + cout << "Starting JACK server at path: " << options.server_path << endl; + + get_jack_default_audio_driver_name (options.driver); + + vector devices = get_jack_device_names_for_audio_driver (options.driver); + + if (!devices.empty()) { + options.input_device = devices.front (); + options.output_device = devices.front (); + } else { + cout << "No audio devices available using default JACK driver using Dummy driver" << endl; + options.driver = dummy_driver_name; + devices = get_jack_device_names_for_audio_driver (options.driver); + CPPUNIT_ASSERT (!devices.empty ()); + options.input_device = devices.front (); + options.output_device = devices.front (); + } + + string command_line; + // this at least should create a valid jack command line + CPPUNIT_ASSERT (get_jack_command_line_string (options, command_line)); + + cout << "Calling start_jack_server with command line: " << command_line << endl; + + CPPUNIT_ASSERT (start_jack_server (command_line)); + + // sleep for 10 seconds + Sleep (10*1000); + + CPPUNIT_ASSERT (jack_server_running ()); +#endif +} diff --git a/libs/ardour/test/jack_utils_test.h b/libs/ardour/test/jack_utils_test.h new file mode 100644 index 0000000000..6a42d1d015 --- /dev/null +++ b/libs/ardour/test/jack_utils_test.h @@ -0,0 +1,33 @@ + +#include +#include + +class JackUtilsTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (JackUtilsTest); + CPPUNIT_TEST (test_driver_names); + CPPUNIT_TEST (test_device_names); + CPPUNIT_TEST (test_samplerates); + CPPUNIT_TEST (test_period_sizes); + CPPUNIT_TEST (test_dither_modes); + CPPUNIT_TEST (test_connect_server); + CPPUNIT_TEST (test_set_jack_path_env); + CPPUNIT_TEST (test_server_paths); + CPPUNIT_TEST (test_config); + CPPUNIT_TEST (test_command_line); + CPPUNIT_TEST (test_start_server); + CPPUNIT_TEST_SUITE_END (); + +public: + void test_driver_names (); + void test_device_names (); + void test_samplerates (); + void test_period_sizes (); + void test_dither_modes (); + void test_connect_server (); + void test_set_jack_path_env (); + void test_server_paths (); + void test_config (); + void test_command_line (); + void test_start_server (); +}; diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 256ff1c6c0..3afd4ce552 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -2,6 +2,7 @@ from waflib.extras import autowaf as autowaf from waflib import Options import os +import sys import re import subprocess @@ -99,6 +100,7 @@ libardour_sources = [ 'io.cc', 'io_processor.cc', 'jack_slave.cc', + 'jack_utils.cc', 'kmeterdsp.cc', 'ladspa_plugin.cc', 'ladspa_search_path.cc', @@ -240,6 +242,12 @@ def configure(conf): atleast_version='0.3.2') autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.118.2') + if Options.options.dist_target == 'auto': + if re.search ("linux", sys.platform) != None: + autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA') + if Options.options.dist_target == 'mingw': + autowaf.check_pkg(conf, 'portaudio-2.0', uselib_store='PORTAUDIO', + atleast_version='19') autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML') autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', atleast_version='0.4.0') @@ -379,8 +387,8 @@ def build(bld): obj.name = 'ardour' obj.target = 'ardour' obj.uselib = ['GLIBMM','GTHREAD','AUBIO','SIGCPP','XML','UUID', - 'JACK','SNDFILE','SAMPLERATE','LRDF','AUDIOUNITS', - 'OSX','BOOST','CURL','DL'] + 'JACK', 'ALSA', 'PORTAUDIO', 'SNDFILE','SAMPLERATE','LRDF', + 'AUDIOUNITS', 'OSX','BOOST','CURL','DL'] obj.use = ['libpbd','libmidipp','libevoral','libvamphost', 'libvampplugin','libtaglib','librubberband', 'libaudiographer','libltc'] @@ -479,6 +487,7 @@ def build(bld): create_ardour_test_program(bld, obj.includes, 'framewalk_to_beats', 'test_framewalk_to_beats', ['test/framewalk_to_beats_test.cc']) create_ardour_test_program(bld, obj.includes, 'framepos_plus_beats', 'test_framepos_plus_beats', ['test/framepos_plus_beats_test.cc']) create_ardour_test_program(bld, obj.includes, 'framepos_minus_beats', 'test_framepos_minus_beats', ['test/framepos_minus_beats_test.cc']) + create_ardour_test_program(bld, obj.includes, 'jack_utils', 'test_jack_utils', ['test/jack_utils_test.cc']) create_ardour_test_program(bld, obj.includes, 'playlist_equivalent_regions', 'test_playlist_equivalent_regions', ['test/playlist_equivalent_regions_test.cc']) create_ardour_test_program(bld, obj.includes, 'playlist_layering', 'test_playlist_layering', ['test/playlist_layering_test.cc']) create_ardour_test_program(bld, obj.includes, 'plugins_test', 'test_plugins', ['test/plugins_test.cc']) @@ -497,6 +506,7 @@ def build(bld): test/framewalk_to_beats_test.cc test/framepos_plus_beats_test.cc test/framepos_minus_beats_test.cc + test/jack_utils_test.cc test/playlist_equivalent_regions_test.cc test/playlist_layering_test.cc test/plugins_test.cc -- cgit v1.2.3 From 020ca43ed04c5effc00dea055d9c227627c6a8b7 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 12:53:16 -0400 Subject: add and Update mutex test that is no longer necessary now that glib has been fixed --- libs/pbd/test/mutex_test.cc | 24 ++++++++++++++++++++++++ libs/pbd/test/mutex_test.h | 17 +++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 libs/pbd/test/mutex_test.cc create mode 100644 libs/pbd/test/mutex_test.h diff --git a/libs/pbd/test/mutex_test.cc b/libs/pbd/test/mutex_test.cc new file mode 100644 index 0000000000..52c36c4695 --- /dev/null +++ b/libs/pbd/test/mutex_test.cc @@ -0,0 +1,24 @@ +#include "mutex_test.h" + +CPPUNIT_TEST_SUITE_REGISTRATION (MutexTest); + +using namespace std; + +MutexTest::MutexTest () +{ +} + +void +MutexTest::testBasic () +{ + Glib::Threads::Mutex::Lock lm (m_mutex); + + CPPUNIT_ASSERT (lm.locked()); + + /* This will fail on POSIX systems but not on some older versions of glib + * on win32 as TryEnterCriticalSection is used and it will return true + * as CriticalSection is reentrant and fail the assertion. + */ + CPPUNIT_ASSERT (!m_mutex.trylock()); + +} diff --git a/libs/pbd/test/mutex_test.h b/libs/pbd/test/mutex_test.h new file mode 100644 index 0000000000..95b6ea3f65 --- /dev/null +++ b/libs/pbd/test/mutex_test.h @@ -0,0 +1,17 @@ +#include +#include +#include "glibmm/threads.h" + +class MutexTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (MutexTest); + CPPUNIT_TEST (testBasic); + CPPUNIT_TEST_SUITE_END (); + +public: + MutexTest (); + void testBasic (); + +private: + Glib::Threads::Mutex m_mutex; +}; -- cgit v1.2.3 From 94145732f3bd406ec75652117c02c8aaab6777ca Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:16:09 -0400 Subject: Build system changes to support mingw build target --- gtk2_ardour/wscript | 8 ++++++-- libs/ardour/wscript | 9 +++++---- libs/pbd/wscript | 6 ++++-- libs/surfaces/wscript | 2 +- libs/taglib/wscript | 1 + wscript | 39 ++++++++++++++++++++++++++++++++++----- 6 files changed, 51 insertions(+), 14 deletions(-) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index bb4e2035ec..429b8c2dbd 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -266,8 +266,9 @@ def configure(conf): 'gtk2_ardour', conf.env['MAJOR'], conf.env['MINOR'], 0) autowaf.configure(conf) - if re.search ("linux", sys.platform) != None: - autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA') + if Options.options.dist_target == 'auto': + if re.search ("linux", sys.platform) != None: + autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA') # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present @@ -418,6 +419,9 @@ def build(bld): 'libardour_cp', 'libgtkmm2ext', 'libtaglib' ] + if bld.env['build_target'] == 'mingw': + if bld.env['DEBUG'] == False: + obj.linkflags = ['-mwindows'] if sys.platform == 'darwin': obj.use += ' libappleutility' obj.defines = [ diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 3afd4ce552..0ea3eee036 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -238,8 +238,6 @@ def configure(conf): path_prefix + 'version.cc', 'libardour3', conf.env['MAJOR'], conf.env['MINOR'], 0) autowaf.configure(conf) - autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', - atleast_version='0.3.2') autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.118.2') if Options.options.dist_target == 'auto': @@ -249,8 +247,11 @@ def configure(conf): autowaf.check_pkg(conf, 'portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19') autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML') - autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', - atleast_version='0.4.0') + if Options.options.dist_target != 'mingw': + autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', + atleast_version='0.4.0') + autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', + atleast_version='0.3.2') autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE', atleast_version='0.1.0') autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 2f93887e62..800b7d3be2 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -38,7 +38,6 @@ libpbd_sources = [ 'controllable.cc', 'controllable_descriptor.cc', 'clear_dir.cc', - 'crossthread.cc', 'cpus.cc', 'debug.cc', 'enumwriter.cc', @@ -122,6 +121,9 @@ def build(bld): if bld.is_defined('DEBUG_RT_ALLOC'): obj.source += 'debug_rt_alloc.c' + if bld.env['build_target'] != 'mingw': + obj.source += 'crossthread.cc' + obj.export_includes = ['.'] obj.includes = ['.'] obj.name = 'libpbd' @@ -156,7 +158,7 @@ def build(bld): testobj.uselib = 'CPPUNIT XML SNDFILE' testobj.use = 'libpbd' testobj.name = 'libpbd-tests' - if sys.platform != 'darwin': + if sys.platform != 'darwin' and bld.env['build_target'] != 'mingw': testobj.linkflags = ['-lrt'] diff --git a/libs/surfaces/wscript b/libs/surfaces/wscript index e0e91af725..1b2948c50a 100644 --- a/libs/surfaces/wscript +++ b/libs/surfaces/wscript @@ -43,7 +43,7 @@ def configure(conf): #if Options.options.tranzport and conf.is_defined('HAVE_USB'): # conf.define('BUILD_TRANZPORT', 1) - if conf.check_cc (header_name='poll.h', define_name='BUILD_MACKIE'): + if conf.check_cc (header_name='poll.h', define_name='BUILD_MACKIE', mandatory=False): sub_config_and_use(conf, 'mackie') if autowaf.check_pkg (conf, 'liblo', mandatory=False, uselib_store="LO", atleast_version="0.24"): diff --git a/libs/taglib/wscript b/libs/taglib/wscript index a6994d6391..8e6fbbbe48 100644 --- a/libs/taglib/wscript +++ b/libs/taglib/wscript @@ -65,6 +65,7 @@ def build(bld): '''.split() obj.export_includes = ['.', 'taglib', 'taglib/toolkit'] obj.includes = include_dirs + obj.defines = ['MAKE_TAGLIB_LIB'] obj.name = 'libtaglib' obj.target = 'taglib' obj.vnum = LIBTAGLIB_LIB_VERSION diff --git a/wscript b/wscript index a6106c0aef..a2f470ef03 100644 --- a/wscript +++ b/wscript @@ -32,7 +32,6 @@ children = [ 'libs/timecode', 'libs/ardour', 'libs/gtkmm2ext', - 'libs/clearlooks-newer', 'libs/audiographer', 'gtk2_ardour', 'export', @@ -114,7 +113,7 @@ def set_compiler_flags (conf,opt): debug_flags = [ '-pg' ] if opt.backtrace: - if platform != 'darwin' and not is_clang: + if platform != 'darwin' and not is_clang and opt.dist_target != 'mingw': debug_flags = [ '-rdynamic' ] # Autodetect @@ -390,7 +389,7 @@ def options(opt): opt.add_option('--depstack-root', type='string', default='~', dest='depstack_root', help='Directory/folder where dependency stack trees (gtk, a3) can be found (defaults to ~)') opt.add_option('--dist-target', type='string', default='auto', dest='dist_target', - help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]') + help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard,mingw]') opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization', help='Build runtime checked assembler code (default)') opt.add_option('--no-fpu-optimization', action='store_false', dest='fpu_optimization') @@ -410,7 +409,7 @@ def options(opt): help='Compile with support for LV2 (if Lilv+Suil is available)') opt.add_option('--no-lv2', action='store_false', dest='lv2', help='Do not compile with support for LV2') - opt.add_option('--lxvst', action='store_true', default=lxvst_default, dest='lxvst', + opt.add_option('--lxvst', action='store_true', default=False, dest='lxvst', help='Compile with support for linuxVST plugins') opt.add_option('--nls', action='store_true', default=True, dest='nls', help='Enable i18n (native language support) (default)') @@ -606,7 +605,21 @@ def configure(conf): autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0') autowaf.check_pkg(conf, 'liblo', uselib_store='LO', atleast_version='0.26') - conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') + if Options.options.dist_target == 'mingw': + Options.options.fpu_optimization = False + conf.env.append_value('LIB', 'pthreadGC2') + # needed for at least libsmf + conf.check_cc(function_name='htonl', header_name='winsock2.h', lib='ws2_32') + conf.env.append_value('LIB', 'ws2_32') + # needed for mingw64 packages, not harmful on normal mingw build + conf.env.append_value('LIB', 'intl') + conf.check_cc(function_name='regcomp', header_name='regex.h', + lib='regex', uselib_store="REGEX", define_name='HAVE_REGEX_H') + # TODO put this only where it is needed + conf.env.append_value('LIB', 'regex') + + if Options.options.dist_target != 'mingw': + conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') # Tell everyone that this is a waf build @@ -659,6 +672,14 @@ def configure(conf): set_compiler_flags (conf, Options.options) + if sys.platform == 'darwin': + sub_config_and_use(conf, 'libs/appleutility') + elif Options.options.dist_target != 'mingw': + sub_config_and_use(conf, 'tools/sanity_check') + + if Options.options.dist_target != 'mingw': + sub_config_and_use(conf, 'libs/clearlooks-newer') + for i in children: sub_config_and_use(conf, i) @@ -742,6 +763,14 @@ def build(bld): autowaf.set_recursive() + if sys.platform == 'darwin': + bld.recurse('libs/appleutility') + elif bld.env['build_target'] != 'mingw': + bld.recurse('tools/sanity_check') + + if bld.env['build_target'] != 'mingw': + bld.recurse('libs/clearlooks-newer') + for i in children: bld.recurse(i) -- cgit v1.2.3 From fa09121a7f20ba424df5b9542564a467af63dc7a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:17:32 -0400 Subject: tweaks to mingw build environment --- tools/windows_packaging/mingw-env.sh | 4 ++-- wscript | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/windows_packaging/mingw-env.sh b/tools/windows_packaging/mingw-env.sh index c6747ae03b..37a575885f 100644 --- a/tools/windows_packaging/mingw-env.sh +++ b/tools/windows_packaging/mingw-env.sh @@ -5,12 +5,12 @@ BASE=$(dirname $BASE) # up one BASE=$(dirname $BASE) # up one more BASE=$(dirname $BASE) # up one more -HOST=i686-pc-mingw32 +HOST=i686-w64-mingw32 MINGW_ROOT=/usr/$HOST/sys-root/mingw export PKG_CONFIG_PREFIX=$MINGW_ROOT export PKG_CONFIG_LIBDIR=$MINGW_ROOT/lib/pkgconfig -export PKGCONFIG=mingw32-pkg-config +export PKGCONFIG=pkg-config export AR=$HOST-ar export RANLIB=$HOST-ranlib export CC=$HOST-gcc diff --git a/wscript b/wscript index a2f470ef03..044e56d12c 100644 --- a/wscript +++ b/wscript @@ -590,13 +590,6 @@ def configure(conf): autowaf.check_header(conf, 'cxx', 'jack/session.h', define="JACK_SESSION", mandatory = False) - conf.check_cxx(fragment = "#include \nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n", - execute = "1", - mandatory = True, - msg = 'Checking for boost library >= 1.39', - okmsg = 'ok', - errmsg = 'too old\nPlease install boost version 1.39 or higher.') - autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2') autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.2') autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0') @@ -621,6 +614,13 @@ def configure(conf): if Options.options.dist_target != 'mingw': conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') + conf.check_cxx(fragment = "#include \nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n", + execute = "1", + mandatory = True, + msg = 'Checking for boost library >= 1.39', + okmsg = 'ok', + errmsg = 'too old\nPlease install boost version 1.39 or higher.') + # Tell everyone that this is a waf build conf.env.append_value('CFLAGS', '-DWAF_BUILD') -- cgit v1.2.3 From 555174d510685a2ea2316f12c635c94f3f327370 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:20:48 -0400 Subject: Revert "tweaks to mingw build environment" This reverts commit fa09121a7f20ba424df5b9542564a467af63dc7a. --- tools/windows_packaging/mingw-env.sh | 4 ++-- wscript | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/windows_packaging/mingw-env.sh b/tools/windows_packaging/mingw-env.sh index 37a575885f..c6747ae03b 100644 --- a/tools/windows_packaging/mingw-env.sh +++ b/tools/windows_packaging/mingw-env.sh @@ -5,12 +5,12 @@ BASE=$(dirname $BASE) # up one BASE=$(dirname $BASE) # up one more BASE=$(dirname $BASE) # up one more -HOST=i686-w64-mingw32 +HOST=i686-pc-mingw32 MINGW_ROOT=/usr/$HOST/sys-root/mingw export PKG_CONFIG_PREFIX=$MINGW_ROOT export PKG_CONFIG_LIBDIR=$MINGW_ROOT/lib/pkgconfig -export PKGCONFIG=pkg-config +export PKGCONFIG=mingw32-pkg-config export AR=$HOST-ar export RANLIB=$HOST-ranlib export CC=$HOST-gcc diff --git a/wscript b/wscript index 044e56d12c..a2f470ef03 100644 --- a/wscript +++ b/wscript @@ -590,6 +590,13 @@ def configure(conf): autowaf.check_header(conf, 'cxx', 'jack/session.h', define="JACK_SESSION", mandatory = False) + conf.check_cxx(fragment = "#include \nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n", + execute = "1", + mandatory = True, + msg = 'Checking for boost library >= 1.39', + okmsg = 'ok', + errmsg = 'too old\nPlease install boost version 1.39 or higher.') + autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2') autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.2') autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0') @@ -614,13 +621,6 @@ def configure(conf): if Options.options.dist_target != 'mingw': conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') - conf.check_cxx(fragment = "#include \nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n", - execute = "1", - mandatory = True, - msg = 'Checking for boost library >= 1.39', - okmsg = 'ok', - errmsg = 'too old\nPlease install boost version 1.39 or higher.') - # Tell everyone that this is a waf build conf.env.append_value('CFLAGS', '-DWAF_BUILD') -- cgit v1.2.3 From 96ea407d1a308373fe3f375485fe4af2065419c0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:21:22 -0400 Subject: Revert "Build system changes to support mingw build target" This reverts commit 94145732f3bd406ec75652117c02c8aaab6777ca. --- gtk2_ardour/wscript | 8 ++------ libs/ardour/wscript | 9 ++++----- libs/pbd/wscript | 6 ++---- libs/surfaces/wscript | 2 +- libs/taglib/wscript | 1 - wscript | 39 +++++---------------------------------- 6 files changed, 14 insertions(+), 51 deletions(-) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 429b8c2dbd..bb4e2035ec 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -266,9 +266,8 @@ def configure(conf): 'gtk2_ardour', conf.env['MAJOR'], conf.env['MINOR'], 0) autowaf.configure(conf) - if Options.options.dist_target == 'auto': - if re.search ("linux", sys.platform) != None: - autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA') + if re.search ("linux", sys.platform) != None: + autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA') # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present @@ -419,9 +418,6 @@ def build(bld): 'libardour_cp', 'libgtkmm2ext', 'libtaglib' ] - if bld.env['build_target'] == 'mingw': - if bld.env['DEBUG'] == False: - obj.linkflags = ['-mwindows'] if sys.platform == 'darwin': obj.use += ' libappleutility' obj.defines = [ diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 0ea3eee036..3afd4ce552 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -238,6 +238,8 @@ def configure(conf): path_prefix + 'version.cc', 'libardour3', conf.env['MAJOR'], conf.env['MINOR'], 0) autowaf.configure(conf) + autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', + atleast_version='0.3.2') autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.118.2') if Options.options.dist_target == 'auto': @@ -247,11 +249,8 @@ def configure(conf): autowaf.check_pkg(conf, 'portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19') autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML') - if Options.options.dist_target != 'mingw': - autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', - atleast_version='0.4.0') - autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', - atleast_version='0.3.2') + autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', + atleast_version='0.4.0') autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE', atleast_version='0.1.0') autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 800b7d3be2..2f93887e62 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -38,6 +38,7 @@ libpbd_sources = [ 'controllable.cc', 'controllable_descriptor.cc', 'clear_dir.cc', + 'crossthread.cc', 'cpus.cc', 'debug.cc', 'enumwriter.cc', @@ -121,9 +122,6 @@ def build(bld): if bld.is_defined('DEBUG_RT_ALLOC'): obj.source += 'debug_rt_alloc.c' - if bld.env['build_target'] != 'mingw': - obj.source += 'crossthread.cc' - obj.export_includes = ['.'] obj.includes = ['.'] obj.name = 'libpbd' @@ -158,7 +156,7 @@ def build(bld): testobj.uselib = 'CPPUNIT XML SNDFILE' testobj.use = 'libpbd' testobj.name = 'libpbd-tests' - if sys.platform != 'darwin' and bld.env['build_target'] != 'mingw': + if sys.platform != 'darwin': testobj.linkflags = ['-lrt'] diff --git a/libs/surfaces/wscript b/libs/surfaces/wscript index 1b2948c50a..e0e91af725 100644 --- a/libs/surfaces/wscript +++ b/libs/surfaces/wscript @@ -43,7 +43,7 @@ def configure(conf): #if Options.options.tranzport and conf.is_defined('HAVE_USB'): # conf.define('BUILD_TRANZPORT', 1) - if conf.check_cc (header_name='poll.h', define_name='BUILD_MACKIE', mandatory=False): + if conf.check_cc (header_name='poll.h', define_name='BUILD_MACKIE'): sub_config_and_use(conf, 'mackie') if autowaf.check_pkg (conf, 'liblo', mandatory=False, uselib_store="LO", atleast_version="0.24"): diff --git a/libs/taglib/wscript b/libs/taglib/wscript index 8e6fbbbe48..a6994d6391 100644 --- a/libs/taglib/wscript +++ b/libs/taglib/wscript @@ -65,7 +65,6 @@ def build(bld): '''.split() obj.export_includes = ['.', 'taglib', 'taglib/toolkit'] obj.includes = include_dirs - obj.defines = ['MAKE_TAGLIB_LIB'] obj.name = 'libtaglib' obj.target = 'taglib' obj.vnum = LIBTAGLIB_LIB_VERSION diff --git a/wscript b/wscript index a2f470ef03..a6106c0aef 100644 --- a/wscript +++ b/wscript @@ -32,6 +32,7 @@ children = [ 'libs/timecode', 'libs/ardour', 'libs/gtkmm2ext', + 'libs/clearlooks-newer', 'libs/audiographer', 'gtk2_ardour', 'export', @@ -113,7 +114,7 @@ def set_compiler_flags (conf,opt): debug_flags = [ '-pg' ] if opt.backtrace: - if platform != 'darwin' and not is_clang and opt.dist_target != 'mingw': + if platform != 'darwin' and not is_clang: debug_flags = [ '-rdynamic' ] # Autodetect @@ -389,7 +390,7 @@ def options(opt): opt.add_option('--depstack-root', type='string', default='~', dest='depstack_root', help='Directory/folder where dependency stack trees (gtk, a3) can be found (defaults to ~)') opt.add_option('--dist-target', type='string', default='auto', dest='dist_target', - help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard,mingw]') + help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]') opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization', help='Build runtime checked assembler code (default)') opt.add_option('--no-fpu-optimization', action='store_false', dest='fpu_optimization') @@ -409,7 +410,7 @@ def options(opt): help='Compile with support for LV2 (if Lilv+Suil is available)') opt.add_option('--no-lv2', action='store_false', dest='lv2', help='Do not compile with support for LV2') - opt.add_option('--lxvst', action='store_true', default=False, dest='lxvst', + opt.add_option('--lxvst', action='store_true', default=lxvst_default, dest='lxvst', help='Compile with support for linuxVST plugins') opt.add_option('--nls', action='store_true', default=True, dest='nls', help='Enable i18n (native language support) (default)') @@ -605,21 +606,7 @@ def configure(conf): autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0') autowaf.check_pkg(conf, 'liblo', uselib_store='LO', atleast_version='0.26') - if Options.options.dist_target == 'mingw': - Options.options.fpu_optimization = False - conf.env.append_value('LIB', 'pthreadGC2') - # needed for at least libsmf - conf.check_cc(function_name='htonl', header_name='winsock2.h', lib='ws2_32') - conf.env.append_value('LIB', 'ws2_32') - # needed for mingw64 packages, not harmful on normal mingw build - conf.env.append_value('LIB', 'intl') - conf.check_cc(function_name='regcomp', header_name='regex.h', - lib='regex', uselib_store="REGEX", define_name='HAVE_REGEX_H') - # TODO put this only where it is needed - conf.env.append_value('LIB', 'regex') - - if Options.options.dist_target != 'mingw': - conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') + conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') # Tell everyone that this is a waf build @@ -672,14 +659,6 @@ def configure(conf): set_compiler_flags (conf, Options.options) - if sys.platform == 'darwin': - sub_config_and_use(conf, 'libs/appleutility') - elif Options.options.dist_target != 'mingw': - sub_config_and_use(conf, 'tools/sanity_check') - - if Options.options.dist_target != 'mingw': - sub_config_and_use(conf, 'libs/clearlooks-newer') - for i in children: sub_config_and_use(conf, i) @@ -763,14 +742,6 @@ def build(bld): autowaf.set_recursive() - if sys.platform == 'darwin': - bld.recurse('libs/appleutility') - elif bld.env['build_target'] != 'mingw': - bld.recurse('tools/sanity_check') - - if bld.env['build_target'] != 'mingw': - bld.recurse('libs/clearlooks-newer') - for i in children: bld.recurse(i) -- cgit v1.2.3 From 00ae5492f400c2a6662467c355066cfbffdcb29f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:43:17 -0400 Subject: (reapply with fixes) Build system changes to support mingw build target --- gtk2_ardour/wscript | 8 ++++++-- libs/ardour/wscript | 9 +++++---- libs/pbd/wscript | 6 ++++-- libs/surfaces/wscript | 2 +- libs/taglib/wscript | 1 + wscript | 37 +++++++++++++++++++++++++++++++++---- 6 files changed, 50 insertions(+), 13 deletions(-) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index bb4e2035ec..429b8c2dbd 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -266,8 +266,9 @@ def configure(conf): 'gtk2_ardour', conf.env['MAJOR'], conf.env['MINOR'], 0) autowaf.configure(conf) - if re.search ("linux", sys.platform) != None: - autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA') + if Options.options.dist_target == 'auto': + if re.search ("linux", sys.platform) != None: + autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA') # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present @@ -418,6 +419,9 @@ def build(bld): 'libardour_cp', 'libgtkmm2ext', 'libtaglib' ] + if bld.env['build_target'] == 'mingw': + if bld.env['DEBUG'] == False: + obj.linkflags = ['-mwindows'] if sys.platform == 'darwin': obj.use += ' libappleutility' obj.defines = [ diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 3afd4ce552..5e8b27d4ea 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -238,8 +238,6 @@ def configure(conf): path_prefix + 'version.cc', 'libardour3', conf.env['MAJOR'], conf.env['MINOR'], 0) autowaf.configure(conf) - autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', - atleast_version='0.3.2') autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.118.2') if Options.options.dist_target == 'auto': @@ -249,8 +247,11 @@ def configure(conf): autowaf.check_pkg(conf, 'portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19') autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML') - autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', - atleast_version='0.4.0') + if Options.options.dist_target != 'mingw': + autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', + atleast_version='0.4.0') + autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', + atleast_version='0.3.2') autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE', atleast_version='0.1.0') autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 2f93887e62..91d9b2c50b 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -38,7 +38,6 @@ libpbd_sources = [ 'controllable.cc', 'controllable_descriptor.cc', 'clear_dir.cc', - 'crossthread.cc', 'cpus.cc', 'debug.cc', 'enumwriter.cc', @@ -122,6 +121,9 @@ def build(bld): if bld.is_defined('DEBUG_RT_ALLOC'): obj.source += 'debug_rt_alloc.c' + if bld.env['build_target'] != 'mingw': + obj.source += [ 'crossthread.cc' ] + obj.export_includes = ['.'] obj.includes = ['.'] obj.name = 'libpbd' @@ -156,7 +158,7 @@ def build(bld): testobj.uselib = 'CPPUNIT XML SNDFILE' testobj.use = 'libpbd' testobj.name = 'libpbd-tests' - if sys.platform != 'darwin': + if sys.platform != 'darwin' and bld.env['build_target'] != 'mingw': testobj.linkflags = ['-lrt'] diff --git a/libs/surfaces/wscript b/libs/surfaces/wscript index e0e91af725..1b2948c50a 100644 --- a/libs/surfaces/wscript +++ b/libs/surfaces/wscript @@ -43,7 +43,7 @@ def configure(conf): #if Options.options.tranzport and conf.is_defined('HAVE_USB'): # conf.define('BUILD_TRANZPORT', 1) - if conf.check_cc (header_name='poll.h', define_name='BUILD_MACKIE'): + if conf.check_cc (header_name='poll.h', define_name='BUILD_MACKIE', mandatory=False): sub_config_and_use(conf, 'mackie') if autowaf.check_pkg (conf, 'liblo', mandatory=False, uselib_store="LO", atleast_version="0.24"): diff --git a/libs/taglib/wscript b/libs/taglib/wscript index a6994d6391..8e6fbbbe48 100644 --- a/libs/taglib/wscript +++ b/libs/taglib/wscript @@ -65,6 +65,7 @@ def build(bld): '''.split() obj.export_includes = ['.', 'taglib', 'taglib/toolkit'] obj.includes = include_dirs + obj.defines = ['MAKE_TAGLIB_LIB'] obj.name = 'libtaglib' obj.target = 'taglib' obj.vnum = LIBTAGLIB_LIB_VERSION diff --git a/wscript b/wscript index a6106c0aef..8599b41148 100644 --- a/wscript +++ b/wscript @@ -32,7 +32,6 @@ children = [ 'libs/timecode', 'libs/ardour', 'libs/gtkmm2ext', - 'libs/clearlooks-newer', 'libs/audiographer', 'gtk2_ardour', 'export', @@ -390,7 +389,7 @@ def options(opt): opt.add_option('--depstack-root', type='string', default='~', dest='depstack_root', help='Directory/folder where dependency stack trees (gtk, a3) can be found (defaults to ~)') opt.add_option('--dist-target', type='string', default='auto', dest='dist_target', - help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]') + help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard,mingw]') opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization', help='Build runtime checked assembler code (default)') opt.add_option('--no-fpu-optimization', action='store_false', dest='fpu_optimization') @@ -410,7 +409,7 @@ def options(opt): help='Compile with support for LV2 (if Lilv+Suil is available)') opt.add_option('--no-lv2', action='store_false', dest='lv2', help='Do not compile with support for LV2') - opt.add_option('--lxvst', action='store_true', default=lxvst_default, dest='lxvst', + opt.add_option('--lxvst', action='store_true', default=False, dest='lxvst', help='Compile with support for linuxVST plugins') opt.add_option('--nls', action='store_true', default=True, dest='nls', help='Enable i18n (native language support) (default)') @@ -606,7 +605,21 @@ def configure(conf): autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0') autowaf.check_pkg(conf, 'liblo', uselib_store='LO', atleast_version='0.26') - conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') + if Options.options.dist_target == 'mingw': + Options.options.fpu_optimization = False + conf.env.append_value('LIB', 'pthreadGC2') + # needed for at least libsmf + conf.check_cc(function_name='htonl', header_name='winsock2.h', lib='ws2_32') + conf.env.append_value('LIB', 'ws2_32') + # needed for mingw64 packages, not harmful on normal mingw build + conf.env.append_value('LIB', 'intl') + conf.check_cc(function_name='regcomp', header_name='regex.h', + lib='regex', uselib_store="REGEX", define_name='HAVE_REGEX_H') + # TODO put this only where it is needed + conf.env.append_value('LIB', 'regex') + + if Options.options.dist_target != 'mingw': + conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') # Tell everyone that this is a waf build @@ -659,6 +672,14 @@ def configure(conf): set_compiler_flags (conf, Options.options) + if sys.platform == 'darwin': + sub_config_and_use(conf, 'libs/appleutility') + elif Options.options.dist_target != 'mingw': + sub_config_and_use(conf, 'tools/sanity_check') + + if Options.options.dist_target != 'mingw': + sub_config_and_use(conf, 'libs/clearlooks-newer') + for i in children: sub_config_and_use(conf, i) @@ -742,6 +763,14 @@ def build(bld): autowaf.set_recursive() + if sys.platform == 'darwin': + bld.recurse('libs/appleutility') + elif bld.env['build_target'] != 'mingw': + bld.recurse('tools/sanity_check') + + if bld.env['build_target'] != 'mingw': + bld.recurse('libs/clearlooks-newer') + for i in children: bld.recurse(i) -- cgit v1.2.3 From 590e1fb45834caecd31cd1b668a2f7045edae40e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:43:47 -0400 Subject: Disable check for boost with mingw build --- wscript | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wscript b/wscript index 8599b41148..148b843a61 100644 --- a/wscript +++ b/wscript @@ -590,13 +590,6 @@ def configure(conf): autowaf.check_header(conf, 'cxx', 'jack/session.h', define="JACK_SESSION", mandatory = False) - conf.check_cxx(fragment = "#include \nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n", - execute = "1", - mandatory = True, - msg = 'Checking for boost library >= 1.39', - okmsg = 'ok', - errmsg = 'too old\nPlease install boost version 1.39 or higher.') - autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2') autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.2') autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0') @@ -621,6 +614,13 @@ def configure(conf): if Options.options.dist_target != 'mingw': conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL') + conf.check_cxx(fragment = "#include \nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n", + execute = "1", + mandatory = True, + msg = 'Checking for boost library >= 1.39', + okmsg = 'ok', + errmsg = 'too old\nPlease install boost version 1.39 or higher.') + # Tell everyone that this is a waf build conf.env.append_value('CFLAGS', '-DWAF_BUILD') -- cgit v1.2.3 From a2a7545ea18dc2318163e8588e8da3ab7d68b373 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:44:11 -0400 Subject: Update mingw environment to work with mingw-64 toolchain on F17 --- tools/windows_packaging/mingw-env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/windows_packaging/mingw-env.sh b/tools/windows_packaging/mingw-env.sh index c6747ae03b..37a575885f 100644 --- a/tools/windows_packaging/mingw-env.sh +++ b/tools/windows_packaging/mingw-env.sh @@ -5,12 +5,12 @@ BASE=$(dirname $BASE) # up one BASE=$(dirname $BASE) # up one more BASE=$(dirname $BASE) # up one more -HOST=i686-pc-mingw32 +HOST=i686-w64-mingw32 MINGW_ROOT=/usr/$HOST/sys-root/mingw export PKG_CONFIG_PREFIX=$MINGW_ROOT export PKG_CONFIG_LIBDIR=$MINGW_ROOT/lib/pkgconfig -export PKGCONFIG=mingw32-pkg-config +export PKGCONFIG=pkg-config export AR=$HOST-ar export RANLIB=$HOST-ranlib export CC=$HOST-gcc -- cgit v1.2.3 From 9b8a3a1ea46533819e17d02a39aaf84794d86db3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:45:00 -0400 Subject: Update mingw package script for Fedora 17 --- tools/windows_packaging/package.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/windows_packaging/package.sh b/tools/windows_packaging/package.sh index 2d7cb7d097..1270bc0cc5 100644 --- a/tools/windows_packaging/package.sh +++ b/tools/windows_packaging/package.sh @@ -96,7 +96,7 @@ libFLAC-8.dll libogg-0.dll libvorbis-0.dll libvorbisenc-2.dll -libffi-5.dll +libffi-6.dll libidn-11.dll libintl-8.dll libpango-1.0-0.dll @@ -105,7 +105,7 @@ libpangoft2-1.0-0.dll libpangomm-1.4-1.dll libpangowin32-1.0-0.dll libpixman-1-0.dll -libpng14-14.dll +libpng15-15.dll libsamplerate-0.dll libsigc-2.0-0.dll libsndfile-1.dll -- cgit v1.2.3 From f9549b6c5c56bc664a987c74d4491a143db6c4d6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 13:45:36 -0400 Subject: Update Pango modules file to work with Pango version in Fedora 17 --- tools/windows_packaging/pango.modules | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/tools/windows_packaging/pango.modules b/tools/windows_packaging/pango.modules index 70d300bc10..115c6a5fd8 100644 --- a/tools/windows_packaging/pango.modules +++ b/tools/windows_packaging/pango.modules @@ -3,33 +3,33 @@ # # ModulesPath = Z:\usr\i686-pc-mingw32\sys-root\mingw\lib\pango\1.6.0\modules # -"lib\\pango\\1.6.0\\modules\\pango-thai-fc.dll" ThaiScriptEngineFc PangoEngineShape PangoRenderFc thai:* lao:* -"lib\\pango\\1.6.0\\modules\\pango-basic-win32.dll" BasicScriptEngineWin32 PangoEngineShape PangoRenderWin32 common: -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" devaScriptEngineFc PangoEngineShape PangoRenderFc devanagari:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" bengScriptEngineFc PangoEngineShape PangoRenderFc bengali:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" guruScriptEngineFc PangoEngineShape PangoRenderFc gurmukhi:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" gujrScriptEngineFc PangoEngineShape PangoRenderFc gujarati:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" oryaScriptEngineFc PangoEngineShape PangoRenderFc oriya:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" tamlScriptEngineFc PangoEngineShape PangoRenderFc tamil:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" teluScriptEngineFc PangoEngineShape PangoRenderFc telugu:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" kndaScriptEngineFc PangoEngineShape PangoRenderFc kannada:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" mlymScriptEngineFc PangoEngineShape PangoRenderFc malayalam:* -"lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" sinhScriptEngineFc PangoEngineShape PangoRenderFc sinhala:* -"lib\\pango\\1.6.0\\modules\\pango-syriac-fc.dll" SyriacScriptEngineFc PangoEngineShape PangoRenderFc syriac:* -"lib\\pango\\1.6.0\\modules\\pango-khmer-fc.dll" KhmerScriptEngineFc PangoEngineShape PangoRenderFc khmer:* -"lib\\pango\\1.6.0\\modules\\pango-arabic-lang.dll" ArabicScriptEngineLang PangoEngineLang PangoRenderNone arabic:* -"lib\\pango\\1.6.0\\modules\\pango-basic-fc.dll" BasicScriptEngineFc PangoEngineShape PangoRenderFc latin:* cyrillic:* greek:* armenian:* georgian:* runic:* ogham:* bopomofo:* cherokee:* coptic:* deseret:* ethiopic:* gothic:* han:* hiragana:* katakana:* old-italic:* canadian-aboriginal:* yi:* braille:* cypriot:* limbu:* osmanya:* shavian:* linear-b:* ugaritic:* glagolitic:* cuneiform:* phoenician:* common: -"lib\\pango\\1.6.0\\modules\\pango-arabic-fc.dll" ArabicScriptEngineFc PangoEngineShape PangoRenderFc arabic:* nko:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" devaIndicScriptEngineLang PangoEngineLang PangoRenderNone devanagari:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" bengIndicScriptEngineLang PangoEngineLang PangoRenderNone bengali:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" guruIndicScriptEngineLang PangoEngineLang PangoRenderNone gurmukhi:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" gujrIndicScriptEngineLang PangoEngineLang PangoRenderNone gujarati:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" oryaIndicScriptEngineLang PangoEngineLang PangoRenderNone oriya:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" tamlIndicScriptEngineLang PangoEngineLang PangoRenderNone tamil:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" teluIndicScriptEngineLang PangoEngineLang PangoRenderNone telugu:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" kndaIndicScriptEngineLang PangoEngineLang PangoRenderNone kannada:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" mlymIndicScriptEngineLang PangoEngineLang PangoRenderNone malayalam:* -"lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" sinhIndicScriptEngineLang PangoEngineLang PangoRenderNone sinhala:* -"lib\\pango\\1.6.0\\modules\\pango-hebrew-fc.dll" HebrewScriptEngineFc PangoEngineShape PangoRenderFc hebrew:* -"lib\\pango\\1.6.0\\modules\\pango-tibetan-fc.dll" TibetanScriptEngineFc PangoEngineShape PangoRenderFc tibetan:* -"lib\\pango\\1.6.0\\modules\\pango-hangul-fc.dll" HangulScriptEngineFc PangoEngineShape PangoRenderFc hangul:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-thai-fc.dll" ThaiScriptEngineFc PangoEngineShape PangoRenderFc thai:* lao:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-basic-win32.dll" BasicScriptEngineWin32 PangoEngineShape PangoRenderWin32 common: +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" devaScriptEngineFc PangoEngineShape PangoRenderFc devanagari:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" bengScriptEngineFc PangoEngineShape PangoRenderFc bengali:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" guruScriptEngineFc PangoEngineShape PangoRenderFc gurmukhi:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" gujrScriptEngineFc PangoEngineShape PangoRenderFc gujarati:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" oryaScriptEngineFc PangoEngineShape PangoRenderFc oriya:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" tamlScriptEngineFc PangoEngineShape PangoRenderFc tamil:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" teluScriptEngineFc PangoEngineShape PangoRenderFc telugu:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" kndaScriptEngineFc PangoEngineShape PangoRenderFc kannada:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" mlymScriptEngineFc PangoEngineShape PangoRenderFc malayalam:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-fc.dll" sinhScriptEngineFc PangoEngineShape PangoRenderFc sinhala:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-syriac-fc.dll" SyriacScriptEngineFc PangoEngineShape PangoRenderFc syriac:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-khmer-fc.dll" KhmerScriptEngineFc PangoEngineShape PangoRenderFc khmer:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-arabic-lang.dll" ArabicScriptEngineLang PangoEngineLang PangoRenderNone arabic:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-basic-fc.dll" BasicScriptEngineFc PangoEngineShape PangoRenderFc latin:* cyrillic:* greek:* armenian:* georgian:* runic:* ogham:* bopomofo:* cherokee:* coptic:* deseret:* ethiopic:* gothic:* han:* hiragana:* katakana:* old-italic:* canadian-aboriginal:* yi:* braille:* cypriot:* limbu:* osmanya:* shavian:* linear-b:* ugaritic:* glagolitic:* cuneiform:* phoenician:* common: +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-arabic-fc.dll" ArabicScriptEngineFc PangoEngineShape PangoRenderFc arabic:* nko:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" devaIndicScriptEngineLang PangoEngineLang PangoRenderNone devanagari:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" bengIndicScriptEngineLang PangoEngineLang PangoRenderNone bengali:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" guruIndicScriptEngineLang PangoEngineLang PangoRenderNone gurmukhi:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" gujrIndicScriptEngineLang PangoEngineLang PangoRenderNone gujarati:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" oryaIndicScriptEngineLang PangoEngineLang PangoRenderNone oriya:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" tamlIndicScriptEngineLang PangoEngineLang PangoRenderNone tamil:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" teluIndicScriptEngineLang PangoEngineLang PangoRenderNone telugu:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" kndaIndicScriptEngineLang PangoEngineLang PangoRenderNone kannada:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" mlymIndicScriptEngineLang PangoEngineLang PangoRenderNone malayalam:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-indic-lang.dll" sinhIndicScriptEngineLang PangoEngineLang PangoRenderNone sinhala:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-hebrew-fc.dll" HebrewScriptEngineFc PangoEngineShape PangoRenderFc hebrew:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-tibetan-fc.dll" TibetanScriptEngineFc PangoEngineShape PangoRenderFc tibetan:* +"..\\..\\lib\\pango\\1.6.0\\modules\\pango-hangul-fc.dll" HangulScriptEngineFc PangoEngineShape PangoRenderFc hangul:* -- cgit v1.2.3 From 15be15451592817731a271cd16d9b94c40c3023b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Jul 2013 14:29:00 -0400 Subject: use g_unlink() rather than unlink() universally, requires in several files --- gtk2_ardour/editor_export_audio.cc | 6 ++++-- gtk2_ardour/editor_videotimeline.cc | 4 +++- gtk2_ardour/export_video_dialog.cc | 16 +++++++++------- gtk2_ardour/sfdb_ui.cc | 4 +++- gtk2_ardour/transcode_video_dialog.cc | 6 ++++-- libs/ardour/audio_unit.cc | 2 +- libs/ardour/audiofilesource.cc | 7 ++++--- libs/ardour/audiosource.cc | 2 +- libs/ardour/export_handler.cc | 5 +++-- libs/ardour/import.cc | 3 ++- libs/ardour/lv2_plugin.cc | 3 ++- libs/ardour/session_state.cc | 2 +- libs/ardour/smf_source.cc | 3 ++- libs/gtkmm2ext/bindings.cc | 4 +++- libs/gtkmm2ext/motionfeedback.cc | 8 +++++--- libs/pbd/clear_dir.cc | 3 ++- libs/surfaces/frontier/kernel_drivers/tranzport.c | 2 +- libs/surfaces/osc/osc.cc | 7 ++++--- 18 files changed, 54 insertions(+), 33 deletions(-) diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index 877a39e773..e40030d671 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -25,6 +25,8 @@ #include +#include + #include "gtkmm2ext/choice.h" #include "pbd/pthread_utils.h" @@ -158,11 +160,11 @@ Editor::export_region () switch (ret) { case Gtk::RESPONSE_ACCEPT: - /* force unlink because the backend code will + /* force ::g_unlink because the backend code will go wrong if it tries to open an existing file for writing. */ - ::unlink (path.c_str()); + ::g_unlink (path.c_str()); break; default: return; diff --git a/gtk2_ardour/editor_videotimeline.cc b/gtk2_ardour/editor_videotimeline.cc index 7395d767c7..5da8a295b7 100644 --- a/gtk2_ardour/editor_videotimeline.cc +++ b/gtk2_ardour/editor_videotimeline.cc @@ -20,6 +20,8 @@ #include +#include + #include "ardour/profile.h" #include "ardour/rc_configuration.h" #include "ardour/audio_track.h" @@ -118,7 +120,7 @@ Editor::embed_audio_from_video (std::string path, framepos_t n) import_status.all_done = true; #endif - unlink(path.c_str()); + ::g_unlink(path.c_str()); } void diff --git a/gtk2_ardour/export_video_dialog.cc b/gtk2_ardour/export_video_dialog.cc index ce85fad81e..d51fd60e2b 100644 --- a/gtk2_ardour/export_video_dialog.cc +++ b/gtk2_ardour/export_video_dialog.cc @@ -30,6 +30,8 @@ #include #include +#include + #include "pbd/error.h" #include "pbd/convert.h" #include "gtkmm2ext/utils.h" @@ -405,8 +407,8 @@ void ExportVideoDialog::finished () { if (aborted) { - unlink(outfn_path_entry.get_text().c_str()); - unlink (insnd.c_str()); + ::g_unlink(outfn_path_entry.get_text().c_str()); + ::g_unlink (insnd.c_str()); Gtk::Dialog::response(RESPONSE_CANCEL); } else if (twopass && firstpass) { firstpass = false; @@ -416,9 +418,9 @@ ExportVideoDialog::finished () if (twopass_checkbox.get_active()) { std::string outfn = outfn_path_entry.get_text(); std::string p2log = Glib::path_get_dirname (outfn) + G_DIR_SEPARATOR + "ffmpeg2pass"; - unlink (p2log.c_str()); + ::g_unlink (p2log.c_str()); } - unlink (insnd.c_str()); + ::g_unlink (insnd.c_str()); Gtk::Dialog::response(RESPONSE_ACCEPT); } } @@ -554,7 +556,7 @@ ExportVideoDialog::launch_export () audio_progress_connection.disconnect(); status->finish (); if (status->aborted()) { - unlink (insnd.c_str()); + ::g_unlink (insnd.c_str()); Gtk::Dialog::response(RESPONSE_CANCEL); return; } @@ -571,14 +573,14 @@ ExportVideoDialog::encode_pass (int pass) transcoder = new TranscodeFfmpeg(invid); if (!transcoder->ffexec_ok()) { /* ffmpeg binary was not found. TranscodeFfmpeg prints a warning */ - unlink (insnd.c_str()); + ::g_unlink (insnd.c_str()); Gtk::Dialog::response(RESPONSE_CANCEL); return; } if (!transcoder->probe_ok()) { /* video input file can not be read */ warning << _("Export Video: Video input file cannot be read.") << endmsg; - unlink (insnd.c_str()); + ::g_unlink (insnd.c_str()); Gtk::Dialog::response(RESPONSE_CANCEL); return; } diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 482a3b61b7..f116041d03 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -31,6 +31,8 @@ #include #include + +#include #include #include "pbd/convert.h" @@ -1487,7 +1489,7 @@ SoundFileOmega::check_link_status (const Session* s, const vector& paths goto out; } - unlink (tmpc); + ::g_unlink (tmpc); } ret = true; diff --git a/gtk2_ardour/transcode_video_dialog.cc b/gtk2_ardour/transcode_video_dialog.cc index fa5d447a3a..4d8b9b9f11 100644 --- a/gtk2_ardour/transcode_video_dialog.cc +++ b/gtk2_ardour/transcode_video_dialog.cc @@ -30,6 +30,8 @@ #include #include +#include + #include "pbd/error.h" #include "pbd/convert.h" #include "gtkmm2ext/utils.h" @@ -301,9 +303,9 @@ void TranscodeVideoDialog::finished () { if (aborted) { - unlink(path_entry.get_text().c_str()); + ::g_unlink(path_entry.get_text().c_str()); if (!audiofile.empty()) { - unlink(audiofile.c_str()); + ::g_unlink(audiofile.c_str()); } Gtk::Dialog::response(RESPONSE_CANCEL); } else { diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 0e9a11e6df..ea2e93c5a0 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -2452,7 +2452,7 @@ AUPluginInfo::save_cached_info () if (!tree.write (path)) { error << string_compose (_("could not save AU cache to %1"), path) << endmsg; - unlink (path.c_str()); + ::g_unlink (path.c_str()); } } diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 13b03f8f48..014baa9031 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -40,6 +40,7 @@ #include +#include #include #include #include @@ -133,8 +134,8 @@ AudioFileSource::~AudioFileSource () { DEBUG_TRACE (DEBUG::Destruction, string_compose ("AudioFileSource destructor %1, removable? %2\n", _path, removable())); if (removable()) { - unlink (_path.c_str()); - unlink (peakpath.c_str()); + ::g_unlink (_path.c_str()); + ::g_unlink (peakpath.c_str()); } } @@ -292,7 +293,7 @@ AudioFileSource::mark_streaming_write_completed () int AudioFileSource::move_dependents_to_trash() { - return ::unlink (peakpath.c_str()); + return ::g_unlink (peakpath.c_str()); } void diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index d8c25b0200..e224186bd2 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -653,7 +653,7 @@ AudioSource::build_peaks_from_scratch () out: if (ret) { DEBUG_TRACE (DEBUG::Peaks, string_compose("Could not write peak data, attempting to remove peakfile %1\n", peakpath)); - unlink (peakpath.c_str()); + ::g_unlink (peakpath.c_str()); } return ret; diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index 4a6b0552c5..5710ecc452 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -20,6 +20,7 @@ #include "ardour/export_handler.h" +#include #include #include @@ -415,10 +416,10 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp } catch (std::exception& e) { error << string_compose (_("an error occured while writing a TOC/CUE file: %1"), e.what()) << endmsg; - ::unlink (filepath.c_str()); + ::g_unlink (filepath.c_str()); } catch (Glib::Exception& e) { error << string_compose (_("an error occured while writing a TOC/CUE file: %1"), e.what()) << endmsg; - ::unlink (filepath.c_str()); + ::g_unlink (filepath.c_str()); } } diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 48937fb576..9be72a9966 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -464,7 +465,7 @@ remove_file_source (boost::shared_ptr source) boost::shared_ptr fs = boost::dynamic_pointer_cast (source); if (fs) { - ::unlink (fs->path().c_str()); + ::g_unlink (fs->path().c_str()); } } diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index d49f8412b7..c5a02575fd 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -1085,7 +1086,7 @@ LV2Plugin::do_remove_preset(string name) name + ".ttl" ) ); - unlink(preset_file.c_str()); + ::g_unlink(preset_file.c_str()); } bool diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index de573e61b6..62edaa3911 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2900,7 +2900,7 @@ Session::cleanup_sources (CleanupReport& rep) string peakpath = peak_path (base); if (Glib::file_test (peakpath.c_str(), Glib::FILE_TEST_EXISTS)) { - if (::unlink (peakpath.c_str()) != 0) { + if (::g_unlink (peakpath.c_str()) != 0) { error << string_compose (_("cannot remove peakfile %1 for %2 (%3)"), peakpath, _path, strerror (errno)) << endmsg; diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index 830fd75fdf..d915bba845 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -30,6 +30,7 @@ #include "pbd/stl_delete.h" #include "pbd/strsplit.h" +#include #include #include "evoral/Control.hpp" @@ -96,7 +97,7 @@ SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist) SMFSource::~SMFSource () { if (removable()) { - unlink (_path.c_str()); + ::g_unlink (_path.c_str()); } } diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc index e049cd8d57..f96bd586d9 100644 --- a/libs/gtkmm2ext/bindings.cc +++ b/libs/gtkmm2ext/bindings.cc @@ -19,6 +19,8 @@ #include +#include + #include "pbd/xml++.h" #include "pbd/convert.h" @@ -389,7 +391,7 @@ Bindings::save (const string& path) save (*root); if (!tree.write (path)) { - ::unlink (path.c_str()); + ::g_unlink (path.c_str()); return false; } diff --git a/libs/gtkmm2ext/motionfeedback.cc b/libs/gtkmm2ext/motionfeedback.cc index bd0fd1cd73..221a8b0bd6 100644 --- a/libs/gtkmm2ext/motionfeedback.cc +++ b/libs/gtkmm2ext/motionfeedback.cc @@ -25,6 +25,8 @@ #include #include /* for snprintf, grrr */ +#include + #include #include @@ -516,15 +518,15 @@ MotionFeedback::render_pixbuf (int size) pixbuf = Gdk::Pixbuf::create_from_file (path); } catch (const Gdk::PixbufError &e) { std::cerr << "Caught PixbufError: " << e.what() << std::endl; - unlink (path); + ::g_unlink (path); throw; } catch (...) { - unlink (path); + ::g_unlink (path); g_message("Caught ... "); throw; } - unlink (path); + ::g_unlink (path); g_free(path); diff --git a/libs/pbd/clear_dir.cc b/libs/pbd/clear_dir.cc index 29410d41e5..86f7067201 100644 --- a/libs/pbd/clear_dir.cc +++ b/libs/pbd/clear_dir.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include "pbd/error.h" @@ -66,7 +67,7 @@ PBD::clear_directory (const string& dir, size_t* size, vector* paths) continue; } - if (::unlink (fullpath.c_str())) { + if (::g_unlink (fullpath.c_str())) { error << string_compose (_("cannot remove file %1 (%2)"), fullpath, strerror (errno)) << endmsg; ret = 1; diff --git a/libs/surfaces/frontier/kernel_drivers/tranzport.c b/libs/surfaces/frontier/kernel_drivers/tranzport.c index 6893f66921..b7b6709d56 100644 --- a/libs/surfaces/frontier/kernel_drivers/tranzport.c +++ b/libs/surfaces/frontier/kernel_drivers/tranzport.c @@ -445,7 +445,7 @@ static void usb_tranzport_interrupt_out_callback(struct urb *urb) { struct usb_tranzport *dev = urb->context; - /* sync/async unlink faults aren't errors */ + /* sync/async ::g_unlink faults aren't errors */ if (urb->status && !(urb->status == -ENOENT || urb->status == -ECONNRESET || urb->status == -ESHUTDOWN)) diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 0c7c8455a4..8b57dc0c3e 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -181,7 +182,7 @@ OSC::start () int fd = mkstemp(tmpstr); if (fd >= 0 ) { - unlink (tmpstr); + ::g_unlink (tmpstr); close (fd); _osc_unix_server = lo_server_new (tmpstr, error_callback); @@ -284,11 +285,11 @@ OSC::stop () } if (!_osc_unix_socket_path.empty()) { - unlink (_osc_unix_socket_path.c_str()); + ::g_unlink (_osc_unix_socket_path.c_str()); } if (!_osc_url_file.empty() ) { - unlink (_osc_url_file.c_str() ); + ::g_unlink (_osc_url_file.c_str() ); } // Delete any active route observers -- cgit v1.2.3 From 7b480eaa27d73e2e5c21c6ac785a1aa2fb3aa51a Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 16 Jul 2013 18:00:49 +0100 Subject: Windows (compiler specific) includes for libpbd --- libs/pbd/base_ui.cc | 4 ++++ libs/pbd/clear_dir.cc | 10 +++++++++- libs/pbd/epa.cc | 5 +++++ libs/pbd/fpu.cc | 6 +++++- libs/pbd/mountpoint.cc | 6 +++++- libs/pbd/pathexpand.cc | 2 +- libs/pbd/pathscanner.cc | 10 +++++++++- libs/pbd/pbd/abstract_ui.cc | 9 +++++++++ libs/pbd/pbd/localtime_r.h | 8 +++++++- libs/pbd/pbd/pathscanner.h | 4 ++++ libs/pbd/pbd/pthread_utils.h | 4 ++++ libs/pbd/pbd/undo.h | 4 ++++ libs/pbd/pthread_utils.cc | 8 ++++++++ libs/pbd/stateful.cc | 4 ++++ 14 files changed, 78 insertions(+), 6 deletions(-) diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index 5725d69182..4bd3d23514 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -19,7 +19,11 @@ #include #include +#ifdef COMPILER_MSVC +#include // Microsoft's nearest equivalent to +#else #include +#endif #include #include #include diff --git a/libs/pbd/clear_dir.cc b/libs/pbd/clear_dir.cc index 29410d41e5..2ad3b73bb3 100644 --- a/libs/pbd/clear_dir.cc +++ b/libs/pbd/clear_dir.cc @@ -17,9 +17,17 @@ */ -#include +#ifdef COMPILER_MSVC +#include // Microsoft's nearest equivalent to +using PBD::readdir; +using PBD::opendir; +using PBD::closedir; +#else #include #include +#endif + +#include #include #include #include diff --git a/libs/pbd/epa.cc b/libs/pbd/epa.cc index d8a3cd5a65..1a27a436a6 100644 --- a/libs/pbd/epa.cc +++ b/libs/pbd/epa.cc @@ -24,7 +24,12 @@ #include "pbd/epa.h" #include "pbd/strsplit.h" +#ifdef COMPILER_MSVC +#define environ _environ +_CRTIMP extern char ** _environ; +#else extern char** environ; +#endif using namespace PBD; using namespace std; diff --git a/libs/pbd/fpu.cc b/libs/pbd/fpu.cc index 40f8cca9d6..5d81cd2fd3 100644 --- a/libs/pbd/fpu.cc +++ b/libs/pbd/fpu.cc @@ -16,7 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - +#ifndef COMPILER_MSVC #include "libpbd-config.h" #define _XOPEN_SOURCE 600 @@ -141,3 +141,7 @@ FPU::FPU () FPU::~FPU () { } + +#else // COMPILER_MSVC + const char* pbd_fpu = "pbd/msvc/fpu.cc takes precedence over this file"; +#endif // COMPILER_MSVC diff --git a/libs/pbd/mountpoint.cc b/libs/pbd/mountpoint.cc index b2fb84760d..9c05f05ad6 100644 --- a/libs/pbd/mountpoint.cc +++ b/libs/pbd/mountpoint.cc @@ -17,7 +17,7 @@ $Id$ */ - +#ifndef COMPILER_MSVC #include #include #include @@ -172,3 +172,7 @@ main (int argc, char *argv[]) } #endif // TEST_MOUNTPOINT + +#else // COMPILER_MSVC + const char* pbd_mountpoint = "pbd/msvc/mountpoint.cc takes precedence over this file"; +#endif // COMPILER_MSVC diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc index ad53bea37b..5c3a0f8bcf 100644 --- a/libs/pbd/pathexpand.cc +++ b/libs/pbd/pathexpand.cc @@ -36,7 +36,7 @@ using std::vector; string PBD::canonical_path (const std::string& path) { -#ifdef WIN32 +#ifdef COMPILER_MINGW return path; #endif char buf[PATH_MAX+1]; diff --git a/libs/pbd/pathscanner.cc b/libs/pbd/pathscanner.cc index fac2dcfd96..b9b501a120 100644 --- a/libs/pbd/pathscanner.cc +++ b/libs/pbd/pathscanner.cc @@ -18,11 +18,19 @@ $Id$ */ +#ifdef COMPILER_MSVC +#include +#include +using PBD::readdir; +using PBD::opendir; +using PBD::closedir; +#else +#include #include #include +#endif #include #include -#include #include #include diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc index 02b42fdead..9c405745ac 100644 --- a/libs/pbd/pbd/abstract_ui.cc +++ b/libs/pbd/pbd/abstract_ui.cc @@ -28,6 +28,15 @@ #include "i18n.h" +#ifdef COMPILER_MSVC +#include // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be + // searched and sorted. Thus, when instantiating the container, MSVC complains + // if the type of object being contained has no appropriate comparison operators + // defined (specifically, if operators '<' and '==' are undefined). This seems + // to be the case with ptw32 'pthread_t' which is a simple struct. +DECLARE_DEFAULT_COMPARISONS(pthread_t) +#endif + using namespace std; template void diff --git a/libs/pbd/pbd/localtime_r.h b/libs/pbd/pbd/localtime_r.h index 2e7c7aa149..ad5b89d134 100644 --- a/libs/pbd/pbd/localtime_r.h +++ b/libs/pbd/pbd/localtime_r.h @@ -2,6 +2,12 @@ #define PBD_LOCALTIME_R #include -extern struct tm *localtime_r(const time_t *const timep, struct tm *p_tm); +#ifdef COMPILER_MSVC + #define localtime_r( _clock, _result ) \ + ( *(_result) = *localtime( (_clock) ), \ + (_result) ) +#else + extern struct tm *localtime_r(const time_t *const timep, struct tm *p_tm); +#endif #endif diff --git a/libs/pbd/pbd/pathscanner.h b/libs/pbd/pbd/pathscanner.h index 1b7ef58655..796648de0f 100644 --- a/libs/pbd/pbd/pathscanner.h +++ b/libs/pbd/pbd/pathscanner.h @@ -22,7 +22,11 @@ #include #include +#ifdef COMPILER_MSVC +#include +#else #include +#endif class PathScanner diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h index 793c3a1980..3d89d5581e 100644 --- a/libs/pbd/pbd/pthread_utils.h +++ b/libs/pbd/pbd/pthread_utils.h @@ -20,7 +20,11 @@ #ifndef __pbd_pthread_utils__ #define __pbd_pthread_utils__ +#ifdef COMPILER_MSVC +#include +#else #include +#endif #include #include #include diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h index 11ff2bf321..e9582a1b53 100644 --- a/libs/pbd/pbd/undo.h +++ b/libs/pbd/pbd/undo.h @@ -25,7 +25,11 @@ #include #include #include +#ifndef COMPILER_MSVC #include +#else +#include +#endif #include "pbd/command.h" diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index 96cf99716f..91d93ec4f8 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -28,6 +28,14 @@ #include #endif +#ifdef COMPILER_MSVC +DECLARE_DEFAULT_COMPARISONS(pthread_t) // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be + // searched and sorted. Thus, when instantiating the container, MSVC complains + // if the type of object being contained has no appropriate comparison operators + // defined (specifically, if operators '<' and '==' are undefined). This seems + // to be the case with ptw32 'pthread_t' which is a simple struct. +#endif + using namespace std; typedef std::list ThreadMap; diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc index 105af75861..c4077f60af 100644 --- a/libs/pbd/stateful.cc +++ b/libs/pbd/stateful.cc @@ -18,7 +18,11 @@ $Id: stateful.cc 629 2006-06-21 23:01:03Z paul $ */ +#ifdef COMPILER_MSVC +#include // Microsoft's nearest equivalent to +#else #include +#endif #include #include -- cgit v1.2.3 From e257b79ecd79eedb0103195b5d6b697edc7586d4 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 16 Jul 2013 19:13:18 +0100 Subject: 'libs/pbd/file_utils.cc' didn't apply cleanly for some reason --- libs/pbd/file_utils.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index 01c2fe286a..311a3948ef 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -23,8 +23,8 @@ #include #include -#ifdef WIN32 -#include // for W_OK +#ifdef COMPILER_MINGW +#include // For W_OK #endif #include -- cgit v1.2.3 From c7306f57329ce18dd932341f522418c4b56fd846 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 17 Jul 2013 07:38:20 +0100 Subject: Other (Windows specific) includes for libpbd --- libs/pbd/pbd/semaphore.h | 2 +- libs/pbd/resource.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/pbd/pbd/semaphore.h b/libs/pbd/pbd/semaphore.h index e54063a15a..81c4057e6a 100644 --- a/libs/pbd/pbd/semaphore.h +++ b/libs/pbd/pbd/semaphore.h @@ -22,7 +22,7 @@ #ifdef __APPLE__ # include -#elif defined(_WIN32) +#elif defined(PLATFORM_WINDOWS) # include #else # include diff --git a/libs/pbd/resource.cc b/libs/pbd/resource.cc index b2988b6314..5ee6f6dc88 100644 --- a/libs/pbd/resource.cc +++ b/libs/pbd/resource.cc @@ -17,7 +17,7 @@ */ -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS #include #else #include -- cgit v1.2.3 From c92e1a0742b0b74f8c6ed795bbe48ea02a312c6b Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 16:41:48 +1000 Subject: Use g_lstat instead of lstat for portability --- gtk2_ardour/ardour_ui.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 91dbd999df..b321b2bce0 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -37,9 +37,8 @@ #include #include -#include -#include -#include +#include +#include #include #include @@ -3398,11 +3397,11 @@ ARDOUR_UI::start_video_server (Gtk::Window* float_window, bool popup_msg) if (icsd_docroot.empty()) {icsd_docroot = X_("/");} struct stat sb; - if (!lstat (icsd_docroot.c_str(), &sb) == 0 || !S_ISDIR(sb.st_mode)) { + if (!g_lstat (icsd_docroot.c_str(), &sb) == 0 || !S_ISDIR(sb.st_mode)) { warning << _("Specified docroot is not an existing directory.") << endmsg; continue; } - if ( (!lstat (icsd_exec.c_str(), &sb) == 0) + if ( (!g_lstat (icsd_exec.c_str(), &sb) == 0) || (sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0 ) { warning << _("Given Video Server is not an executable file.") << endmsg; continue; -- cgit v1.2.3 From 0444c40053e74414d0f94501d9c8bfad90b25ec1 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 16:45:00 +1000 Subject: Use file modes supported by mingw compiler on Windows --- gtk2_ardour/ardour_ui.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index b321b2bce0..9577444120 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -3401,11 +3401,19 @@ ARDOUR_UI::start_video_server (Gtk::Window* float_window, bool popup_msg) warning << _("Specified docroot is not an existing directory.") << endmsg; continue; } +#ifndef WIN32 if ( (!g_lstat (icsd_exec.c_str(), &sb) == 0) || (sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0 ) { warning << _("Given Video Server is not an executable file.") << endmsg; continue; } +#else + if ( (!g_lstat (icsd_exec.c_str(), &sb) == 0) + || (sb.st_mode & (S_IXUSR)) == 0 ) { + warning << _("Given Video Server is not an executable file.") << endmsg; + continue; + } +#endif char **argp; argp=(char**) calloc(9,sizeof(char*)); -- cgit v1.2.3 From e1d2f7070434c936877213e63ac06c29e5b4afce Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 16:47:29 +1000 Subject: Also define casting macro when using mingw compiler --- gtk2_ardour/canvas-waveview.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/canvas-waveview.c b/gtk2_ardour/canvas-waveview.c index 2080b208d8..51384c0fad 100644 --- a/gtk2_ardour/canvas-waveview.c +++ b/gtk2_ardour/canvas-waveview.c @@ -35,7 +35,7 @@ /* POSIX guarantees casting between void* and function pointers, ISO C doesn't * We can work around warnings by going one step deeper in our casts */ -#ifdef _POSIX_VERSION +#if defined(_POSIX_VERSION) || defined(__MINGW32__) #define POSIX_FUNC_PTR_CAST(type, object) *((type*) &(object)) #endif // _POSIX_VERSION -- cgit v1.2.3 From c7d0a52a0b806f1d96d92f224cdfb81da4e93262 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 16:47:56 +1000 Subject: Work around badly chosen argument name in giomm --- gtk2_ardour/ardour_ui_dialogs.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index 8c78d6494d..c0fd97cfd6 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -27,6 +27,10 @@ #include "ardour/audioengine.h" #include "ardour/automation_watch.h" +#ifdef interface +#undef interface +#endif + #include "actions.h" #include "add_route_dialog.h" #include "add_video_dialog.h" -- cgit v1.2.3 From 22e15422e86e51385a9eb00ec166bdff0e621059 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 16:48:40 +1000 Subject: Fix ambiguous type CheckMenuItem that is also defined via windows.h --- gtk2_ardour/editor_rulers.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 2752f96553..a7883674cd 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -373,11 +373,11 @@ Editor::popup_ruler_menu (framepos_t where, ItemType t) ruler_items.push_back (MenuElem (_("Timeline height"))); static_cast(&ruler_items.back())->set_sensitive(false); ruler_items.push_back (CheckMenuElem (_("Large"), sigc::bind ( sigc::mem_fun(*this, &Editor::set_video_timeline_height), 6))); - if (videotl_bar_height == 6) { static_cast(&ruler_items.back())->set_active(true);} + if (videotl_bar_height == 6) { static_cast(&ruler_items.back())->set_active(true);} ruler_items.push_back (CheckMenuElem (_("Normal"), sigc::bind ( sigc::mem_fun(*this, &Editor::set_video_timeline_height), 4))); - if (videotl_bar_height == 4) { static_cast(&ruler_items.back())->set_active(true);} + if (videotl_bar_height == 4) { static_cast(&ruler_items.back())->set_active(true);} ruler_items.push_back (CheckMenuElem (_("Small"), sigc::bind ( sigc::mem_fun(*this, &Editor::set_video_timeline_height), 3))); - if (videotl_bar_height == 3) { static_cast(&ruler_items.back())->set_active(true);} + if (videotl_bar_height == 3) { static_cast(&ruler_items.back())->set_active(true);} ruler_items.push_back (SeparatorElem ()); ruler_items.push_back (MenuElem (_("Align Video Track"))); @@ -385,7 +385,7 @@ Editor::popup_ruler_menu (framepos_t where, ItemType t) ruler_items.push_back (CheckMenuElem (_("Lock"))); { - CheckMenuItem* vtl_lock = static_cast(&ruler_items.back()); + Gtk::CheckMenuItem* vtl_lock = static_cast(&ruler_items.back()); vtl_lock->set_active(is_video_timeline_locked()); vtl_lock->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_video_timeline_locked)); } -- cgit v1.2.3 From 105652ad09fa4898d2fadd791802406c3f1afbec Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 17 Jul 2013 08:06:26 +0100 Subject: Accommodate 'pthread-win32' and 'boost/regex' (for libpbd) --- libs/pbd/debug_rt_alloc.c | 3 ++- libs/pbd/localtime_r.cc | 2 +- libs/pbd/pathexpand.cc | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/pbd/debug_rt_alloc.c b/libs/pbd/debug_rt_alloc.c index 81e640b66d..7e578a2367 100644 --- a/libs/pbd/debug_rt_alloc.c +++ b/libs/pbd/debug_rt_alloc.c @@ -22,9 +22,10 @@ #define _GNU_SOURCE #include #include -#include #include +#include "pbd/pthread_utils.h" + int (*pbd_alloc_allowed) () = 0; /** Thread-local key whose value is set to 1 if malloc checking is disabled diff --git a/libs/pbd/localtime_r.cc b/libs/pbd/localtime_r.cc index 26e9dcc4a4..c72e3eb458 100644 --- a/libs/pbd/localtime_r.cc +++ b/libs/pbd/localtime_r.cc @@ -5,8 +5,8 @@ #ifndef HAVE_LOCALTIME_R #include #include -#include +#include "pbd/pthread_utils.h" #include "pbd/localtime_r.h" #ifdef localtime_r diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc index 5c3a0f8bcf..ae3bed4599 100644 --- a/libs/pbd/pathexpand.cc +++ b/libs/pbd/pathexpand.cc @@ -23,7 +23,7 @@ #include #include -#include +#include #include -- cgit v1.2.3 From 350ed31655b00f3043e5d723606cdd50099fa91b Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 17 Jul 2013 08:08:46 +0100 Subject: Remaining changes needed for building libpdb on Windows (except for adding the extra JE source modules) --- libs/pbd/base_ui.cc | 10 +++++----- libs/pbd/file_utils.cc | 6 +++--- libs/pbd/mountpoint.cc | 2 +- libs/pbd/pbd/base_ui.h | 4 ++-- libs/pbd/pbd/ringbuffer.h | 4 ++-- libs/pbd/pbd/semaphore.h | 6 +++--- libs/pbd/pbd/semutils.h | 6 +++--- libs/pbd/resource.cc | 4 ++-- libs/pbd/search_path.cc | 2 +- libs/pbd/semutils.cc | 6 +++--- libs/pbd/test/filesystem_test.cc | 2 +- libs/pbd/test/test_common.cc | 2 +- libs/pbd/transmitter.cc | 10 ++++++++-- libs/pbd/uuid.cc | 8 +++----- libs/pbd/xml++.cc | 2 ++ 15 files changed, 40 insertions(+), 34 deletions(-) diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index 4bd3d23514..3a4257ebdd 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -51,13 +51,13 @@ BaseUI::BaseUI (const string& str) : m_context(MainContext::get_default()) , run_loop_thread (0) , _name (str) -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS , request_channel (true) #endif { base_ui_instance = this; -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS request_channel.ios()->connect (sigc::mem_fun (*this, &BaseUI::request_handler)); #endif @@ -124,7 +124,7 @@ BaseUI::quit () } } -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS gboolean BaseUI::_request_handler (gpointer data) { @@ -172,7 +172,7 @@ void BaseUI::signal_new_request () { DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::signal_new_request\n"); -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS // handled in timeout, how to signal...? #else request_channel.wakeup (); @@ -186,7 +186,7 @@ void BaseUI::attach_request_source () { DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::attach_request_source\n"); -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS GSource* request_source = g_timeout_source_new(200); g_source_set_callback (request_source, &BaseUI::_request_handler, this, NULL); g_source_attach (request_source, m_context->gobj()); diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index 311a3948ef..03c3ea853c 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -192,9 +192,9 @@ get_absolute_path (const std::string & p) bool equivalent_paths (const std::string& a, const std::string& b) { - struct stat bA; + GStatBuf bA; int const rA = g_stat (a.c_str(), &bA); - struct stat bB; + GStatBuf bB; int const rB = g_stat (b.c_str(), &bB); return (rA == 0 && rB == 0 && bA.st_dev == bB.st_dev && bA.st_ino == bB.st_ino); @@ -225,7 +225,7 @@ exists_and_writable (const std::string & p) make us unwritable. */ - struct stat statbuf; + GStatBuf statbuf; if (g_stat (p.c_str(), &statbuf) != 0) { /* doesn't exist - not writable */ diff --git a/libs/pbd/mountpoint.cc b/libs/pbd/mountpoint.cc index 9c05f05ad6..65f011c745 100644 --- a/libs/pbd/mountpoint.cc +++ b/libs/pbd/mountpoint.cc @@ -94,7 +94,7 @@ mountpoint (string path) return best; } -#elif defined(WIN32) +#elif defined(PLATFORM_WINDOWS) string mountpoint (string path) diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h index 686af485e6..d947a06b34 100644 --- a/libs/pbd/pbd/base_ui.h +++ b/libs/pbd/pbd/base_ui.h @@ -92,7 +92,7 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop virtual void thread_init () {}; -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS static gboolean _request_handler (gpointer); bool request_handler (); #else @@ -114,7 +114,7 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop std::string _name; BaseUI* base_ui_instance; -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS CrossThreadChannel request_channel; #endif diff --git a/libs/pbd/pbd/ringbuffer.h b/libs/pbd/pbd/ringbuffer.h index f14fa71851..a1a6151542 100644 --- a/libs/pbd/pbd/ringbuffer.h +++ b/libs/pbd/pbd/ringbuffer.h @@ -198,7 +198,7 @@ RingBuffer::write (T const *src, guint cnt) } template void -RingBuffer::get_read_vector (RingBuffer::rw_vector *vec) +RingBuffer::get_read_vector (typename RingBuffer::rw_vector *vec) { guint free_cnt; @@ -238,7 +238,7 @@ RingBuffer::get_read_vector (RingBuffer::rw_vector *vec) } template void -RingBuffer::get_write_vector (RingBuffer::rw_vector *vec) +RingBuffer::get_write_vector (typename RingBuffer::rw_vector *vec) { guint free_cnt; diff --git a/libs/pbd/pbd/semaphore.h b/libs/pbd/pbd/semaphore.h index 81c4057e6a..5f0a2df2c0 100644 --- a/libs/pbd/pbd/semaphore.h +++ b/libs/pbd/pbd/semaphore.h @@ -69,7 +69,7 @@ public: private: #if defined(__APPLE__) semaphore_t _sem; // sem_t is a worthless broken mess on OSX -#elif defined(_WIN32) +#elif defined(PLATFORM_WINDOWS) HANDLE _sem; // types are overrated anyway #else sem_t _sem; @@ -114,7 +114,7 @@ Semaphore::try_wait() return semaphore_timedwait(_sem, zero) == KERN_SUCCESS; } -#elif defined(_WIN32) +#elif defined(PLATFORM_WINDOWS) inline Semaphore::Semaphore(unsigned initial) @@ -151,7 +151,7 @@ Semaphore::try_wait() return WaitForSingleObject(_sem, 0) == WAIT_OBJECT_0; } -#else /* !defined(__APPLE__) && !defined(_WIN32) */ +#else /* !defined(__APPLE__) && !defined(PLATFORM_WINDOWS) */ Semaphore::Semaphore(unsigned initial) { diff --git a/libs/pbd/pbd/semutils.h b/libs/pbd/pbd/semutils.h index 0e8bed0512..af5c201b85 100644 --- a/libs/pbd/pbd/semutils.h +++ b/libs/pbd/pbd/semutils.h @@ -19,7 +19,7 @@ #ifndef __pbd_semutils_h__ #define __pbd_semutils_h__ -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS #include #else #include @@ -29,7 +29,7 @@ namespace PBD { class ProcessSemaphore { private: -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS HANDLE _sem; #elif __APPLE__ @@ -44,7 +44,7 @@ class ProcessSemaphore { ProcessSemaphore (const char* name, int val); ~ProcessSemaphore (); -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS int signal (); int wait (); diff --git a/libs/pbd/resource.cc b/libs/pbd/resource.cc index 5ee6f6dc88..9d6f8b1746 100644 --- a/libs/pbd/resource.cc +++ b/libs/pbd/resource.cc @@ -33,7 +33,7 @@ get_resource_limit (ResourceType resource, ResourceLimit& limit) { if (resource == OpenFiles) { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS limit.current_limit = _getmaxstdio(); limit.max_limit = 2048; return true; @@ -55,7 +55,7 @@ set_resource_limit (ResourceType resource, const ResourceLimit& limit) { if (resource == OpenFiles) { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS // no soft and hard limits on windows rlimit_t new_max = _setmaxstdio(limit.current_limit); diff --git a/libs/pbd/search_path.cc b/libs/pbd/search_path.cc index 3f7be5aa56..e56e22fee3 100644 --- a/libs/pbd/search_path.cc +++ b/libs/pbd/search_path.cc @@ -27,7 +27,7 @@ using namespace std; namespace { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS const char * const path_delimiter = ";"; #else const char * const path_delimiter = ":"; diff --git a/libs/pbd/semutils.cc b/libs/pbd/semutils.cc index e5df2e5c44..e5e5898218 100644 --- a/libs/pbd/semutils.cc +++ b/libs/pbd/semutils.cc @@ -23,7 +23,7 @@ using namespace PBD; ProcessSemaphore::ProcessSemaphore (const char* name, int val) { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS if ((_sem = CreateSemaphore(NULL, val, 32767, name)) == NULL) { throw failed_constructor (); } @@ -48,14 +48,14 @@ ProcessSemaphore::ProcessSemaphore (const char* name, int val) ProcessSemaphore::~ProcessSemaphore () { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS CloseHandle(_sem); #elif __APPLE__ sem_close (ptr_to_sem()); #endif } -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS int ProcessSemaphore::signal () diff --git a/libs/pbd/test/filesystem_test.cc b/libs/pbd/test/filesystem_test.cc index 0cbe5baf32..458105d177 100644 --- a/libs/pbd/test/filesystem_test.cc +++ b/libs/pbd/test/filesystem_test.cc @@ -10,7 +10,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION (FilesystemTest); void FilesystemTest::testPathIsWithin () { -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS system ("rm -r foo"); CPPUNIT_ASSERT (g_mkdir_with_parents ("foo/bar/baz", 0755) == 0); diff --git a/libs/pbd/test/test_common.cc b/libs/pbd/test/test_common.cc index 16da3ed2a8..397a69ad8c 100644 --- a/libs/pbd/test/test_common.cc +++ b/libs/pbd/test/test_common.cc @@ -28,7 +28,7 @@ PBD::SearchPath test_search_path () { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS std::string wsp(g_win32_get_package_installation_directory_of_module(NULL)); return Glib::build_filename (wsp, "pbd_testdata"); #else diff --git a/libs/pbd/transmitter.cc b/libs/pbd/transmitter.cc index a172ac457d..e4266d34d7 100644 --- a/libs/pbd/transmitter.cc +++ b/libs/pbd/transmitter.cc @@ -84,14 +84,20 @@ Transmitter::deliver () /* do the right thing if this should not return */ if (does_not_return()) { -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS +// TODO !!!! Commented out temporarily (for Windows) sigset_t mask; sigemptyset (&mask); sigsuspend (&mask); -#endif /*NOTREACHED*/ exit (1); +/* JE - From what I can tell, the above code suspends + * program execution until (any) signal occurs. Not + * sure at the moment what this achieves, unless it + * provides some time for the user to see the message. + */ +#endif } } diff --git a/libs/pbd/uuid.cc b/libs/pbd/uuid.cc index 1a988b9820..8b55ab3381 100644 --- a/libs/pbd/uuid.cc +++ b/libs/pbd/uuid.cc @@ -20,10 +20,8 @@ #include "pbd/uuid.h" -using namespace PBD; - -UUID& -UUID::operator= (std::string const & str) +PBD::UUID& +PBD::UUID::operator= (std::string const & str) { boost::uuids::string_generator gen; *((boost::uuids::uuid*) this) = gen (str); @@ -31,7 +29,7 @@ UUID::operator= (std::string const & str) } std::string -UUID::to_s () const +PBD::UUID::to_s () const { return std::string ((const char*) data, size()); } diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index a1fa77db66..69187995a1 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -167,6 +167,7 @@ XMLTree::write() const void XMLTree::debug(FILE* out) const { +#ifdef LIBXML_DEBUG_ENABLED xmlDocPtr doc; XMLNodeList children; @@ -176,6 +177,7 @@ XMLTree::debug(FILE* out) const writenode(doc, _root, doc->children, 1); xmlDebugDumpDocument (out, doc); xmlFreeDoc(doc); +#endif } const string& -- cgit v1.2.3 From f903d623e4b0d314f940f8a1efe5346bc323d663 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 18:15:02 +1000 Subject: Use jack_client_stop_thread on windows --- libs/ardour/audioengine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index a69e98283e..583ed1ae82 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1568,7 +1568,7 @@ AudioEngine::stop_process_thread (jack_native_thread_t thread) * Jack 2 _jack arg is not used so it should be OK */ -#ifdef USING_JACK2_EXPANSION_OF_JACK_API +#if defined(USING_JACK2_EXPANSION_OF_JACK_API) || defined(WIN32) if (jack_client_stop_thread (_jack, thread) != 0) { error << "AudioEngine: cannot stop process thread" << endmsg; return false; -- cgit v1.2.3 From 11335e4bf030d9442b659447c23dcb92c9460163 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 19:05:01 +1000 Subject: Allow PBD::canonical_path to compile with mingw build --- libs/pbd/pathexpand.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc index ad53bea37b..89fc148ad7 100644 --- a/libs/pbd/pathexpand.cc +++ b/libs/pbd/pathexpand.cc @@ -38,7 +38,7 @@ PBD::canonical_path (const std::string& path) { #ifdef WIN32 return path; -#endif +#else char buf[PATH_MAX+1]; if (!realpath (path.c_str(), buf) && (errno != ENOENT)) { @@ -46,6 +46,7 @@ PBD::canonical_path (const std::string& path) } return string (buf); +#endif } string -- cgit v1.2.3 From 5f2fcb2e327ac7ebfe002eb25396663674866e97 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 19:29:34 +1000 Subject: Add PBD::ffs function --- libs/pbd/ffs.cc | 35 +++++++++++++++++++++++++++++++++++ libs/pbd/pbd/ffs.h | 27 +++++++++++++++++++++++++++ libs/pbd/wscript | 1 + 3 files changed, 63 insertions(+) create mode 100644 libs/pbd/ffs.cc create mode 100644 libs/pbd/pbd/ffs.h diff --git a/libs/pbd/ffs.cc b/libs/pbd/ffs.cc new file mode 100644 index 0000000000..8f7ecdb502 --- /dev/null +++ b/libs/pbd/ffs.cc @@ -0,0 +1,35 @@ +/* + Copyright (C) 2013 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "pbd/ffs.h" + +#include + +namespace PBD { +int +ffs (int x) +{ +#if defined(WIN32) && defined(__GNUC__) + return __builtin_ffs(x); +#else + return ffs(x); +#endif +} + +} diff --git a/libs/pbd/pbd/ffs.h b/libs/pbd/pbd/ffs.h new file mode 100644 index 0000000000..3a2eadfae7 --- /dev/null +++ b/libs/pbd/pbd/ffs.h @@ -0,0 +1,27 @@ +/* + Copyright (C) 2013 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __libpbd_ffs_h__ +#define __libpbd_ffs_h__ + +namespace PBD { + int ffs(int x); +} + +#endif /* __libpbd_ffs_h__ */ diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 91d9b2c50b..e26b96ca11 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -45,6 +45,7 @@ libpbd_sources = [ 'enums.cc', 'epa.cc', 'error.cc', + 'ffs.cc', 'file_manager.cc', 'file_utils.cc', 'fpu.cc', -- cgit v1.2.3 From 9cbe231b920d92a2e44e08962a3ed6870b962f34 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Wed, 17 Jul 2013 20:03:34 +1000 Subject: Use PBD::ffs for portability --- gtk2_ardour/midi_time_axis.cc | 7 +++---- libs/ardour/ardour/midi_track.h | 4 +++- libs/ardour/midi_diskstream.cc | 4 ++-- libs/ardour/midi_track.cc | 5 ++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index a8fc9c3e60..3da5f11f10 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -19,8 +19,6 @@ #include #include -#include // for ffs(3) - #include #include #include @@ -28,6 +26,7 @@ #include #include "pbd/error.h" +#include "pbd/ffs.h" #include "pbd/stl_delete.h" #include "pbd/whitespace.h" #include "pbd/basename.h" @@ -1491,7 +1490,7 @@ MidiTimeAxisView::playback_channel_mode_changed () _playback_channel_status.set_markup (string_compose ("%1: %2", _("Play"), _("some"))); break; case ForceChannel: - _playback_channel_status.set_markup (string_compose ("%1: %2>%3", _("Play"), _("all"), ffs (midi_track()->get_playback_channel_mask()))); + _playback_channel_status.set_markup (string_compose ("%1: %2>%3", _("Play"), _("all"), PBD::ffs (midi_track()->get_playback_channel_mask()))); break; } } @@ -1507,7 +1506,7 @@ MidiTimeAxisView::capture_channel_mode_changed () _capture_channel_status.set_markup (string_compose ("%1: %2", _("Rec"), _("some"))); break; case ForceChannel: - _capture_channel_status.set_markup (string_compose ("%1: %2>%3", _("Rec"), _("all"), ffs (midi_track()->get_capture_channel_mask()))); + _capture_channel_status.set_markup (string_compose ("%1: %2>%3", _("Rec"), _("all"), PBD::ffs (midi_track()->get_capture_channel_mask()))); break; } } diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index 3b75c0a51b..9c1d21a3e4 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -20,6 +20,8 @@ #ifndef __ardour_midi_track_h__ #define __ardour_midi_track_h__ +#include "pbd/ffs.h" + #include "ardour/track.h" #include "ardour/midi_ring_buffer.h" @@ -183,7 +185,7 @@ private: /* if mode is ForceChannel, force mask to the lowest set channel or 1 if no * channels are set. */ -#define force_mask(mode,mask) (((mode) == ForceChannel) ? (((mask) ? (1<<(ffs((mask))-1)) : 1)) : mask) +#define force_mask(mode,mask) (((mode) == ForceChannel) ? (((mask) ? (1<<(PBD::ffs((mask))-1)) : 1)) : mask) void _set_playback_channel_mode(ChannelMode mode, uint16_t mask) { mask = force_mask (mode, mask); diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index a21f3fb6f4..d27c2fa9c7 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -26,10 +26,10 @@ #include #include #include -#include // for ffs(3) #include #include "pbd/error.h" +#include "pbd/ffs.h" #include "pbd/basename.h" #include #include "pbd/xml++.h" @@ -438,7 +438,7 @@ MidiDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t break; case ForceChannel: if (ev.is_channel_event()) { - ev.set_channel (ffs(mask) - 1); + ev.set_channel (PBD::ffs(mask) - 1); } _capture_buf->write(transport_frame + loop_offset + ev.time(), ev.type(), ev.size(), ev.buffer()); diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index f7f9ff7a59..51edd06aee 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -17,8 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include // for ffs(3) - +#include "pbd/ffs.h" #include "pbd/enumwriter.h" #include "pbd/convert.h" #include "evoral/midi_util.h" @@ -504,7 +503,7 @@ MidiTrack::filter_channels (BufferSet& bufs, ChannelMode mode, uint32_t mask) } break; case ForceChannel: - ev.set_channel (ffs (mask) - 1); + ev.set_channel (PBD::ffs (mask) - 1); ++e; break; case AllChannels: -- cgit v1.2.3 From 110972e59aee51ec90e79980232ab746bfb15aef Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 17 Jul 2013 14:53:17 +0100 Subject: JOHNE source files (needed for building libpbd with MSVC) --- libs/pbd/fallback_folders.cc | 591 ++++++++++++++++++++++++++ libs/pbd/localeguard.cc | 34 ++ libs/pbd/msvc/fpu.cc | 124 ++++++ libs/pbd/msvc/mountpoint.cc | 166 ++++++++ libs/pbd/msvc/msvc_pbd.cc | 895 ++++++++++++++++++++++++++++++++++++++++ libs/pbd/msvc/msvc_poll.cc | 215 ++++++++++ libs/pbd/pbd/fallback_folders.h | 62 +++ libs/pbd/pbd/localeguard.h | 37 ++ libs/pbd/pbd/msvc_pbd.h | 235 +++++++++++ 9 files changed, 2359 insertions(+) create mode 100644 libs/pbd/fallback_folders.cc create mode 100644 libs/pbd/localeguard.cc create mode 100644 libs/pbd/msvc/fpu.cc create mode 100644 libs/pbd/msvc/mountpoint.cc create mode 100644 libs/pbd/msvc/msvc_pbd.cc create mode 100644 libs/pbd/msvc/msvc_poll.cc create mode 100644 libs/pbd/pbd/fallback_folders.h create mode 100644 libs/pbd/pbd/localeguard.h create mode 100644 libs/pbd/pbd/msvc_pbd.h diff --git a/libs/pbd/fallback_folders.cc b/libs/pbd/fallback_folders.cc new file mode 100644 index 0000000000..deecd60d7a --- /dev/null +++ b/libs/pbd/fallback_folders.cc @@ -0,0 +1,591 @@ +/* + Copyright (C) 2008 John Emmas + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include +#include +#include + + + +#ifdef PLATFORM_WINDOWS // Would not be relevant for Cygwin!! +#include +#include + +//*************************************************************** +// +// get_win_special_folder() +// +// Gets the full path name that corresponds of one of the Windows +// special folders, such as "My Documents" and the like. The input +// parameter must be one of the corresponding CSIDL values, such +// as CSIDL_SYSTEM etc. +// +// Returns: +// +// On Success: A pointer to a newly allocated string containing +// the name of the special folder (must later be freed). +// On Failure: NULL +// +gchar * +get_win_special_folder (int csidl) +{ +wchar_t path[PATH_MAX+1]; +HRESULT hr; +LPITEMIDLIST pidl = 0; +gchar *retval = 0; + + if (S_OK == (hr = SHGetSpecialFolderLocation (0, csidl, &pidl))) + { + if (SHGetPathFromIDListW (pidl, path)) + retval = g_utf16_to_utf8 ((const gunichar2*)path, -1, 0, 0, 0); + CoTaskMemFree (pidl); + } + + return retval; +} +#endif // PLATFORM_WINDOWS + +namespace PBD { + +static gchar **fallback_folders = 0; + +//*************************************************************** +// +// get_platform_fallback_folders() +// +// Returns an array of folders to fall back to if the folders +// weren't named at build time and subsequently couldn't be found +// in the user's environment. This might not be needed any more +// because the function 'fixup_bundle_environment()' (in the +// gtk2_ardour branch) now explicitly sets up any environment +// paths that the program will need at run time. However, having +// the folders here might help us to simplify the above function +// which would be useful (currently, there are different versions +// of 'fixup_bundle_environment()' for each supported platform). +// Twelve fallback folders are currently catered for, corresponding to:- +// +// LOCALEDIR +// GTK_DIR +// CONFIG_DIR +// ARDOUR_DIR +// MODULE_DIR +// DATA_DIR +// ICONS_DIR +// PIXMAPS_DIR +// CONTROL_SURFACES_DIR +// VAMP_DIR +// LADSPA_PATH - note that there's only one entry in the path +// VST_PATH - note that there may only be one entry in the path +// +// Returns: +// +// On Success: A pointer to an array containing the above dirs. +// On Failure: NULL +// +#ifdef PLATFORM_WINDOWS // Would not be relevant for Cygwin!! + +static gchar** +get_platform_fallback_folders () +{ +gchar **fallback_dir_vector = 0; +const gchar *pUsrHome = 0; // Do not free !! + + if (!fallback_folders) + { + GArray *pFallbackDirs; + gchar *pAppData = 0; + gchar *pMyAppData = 0; + gchar *pExeRoot = 0; + gchar *pPersonal = 0; + + pFallbackDirs = g_array_new (TRUE, TRUE, sizeof (char *)); + + if (pFallbackDirs) + { + /* Get the path for the user's personal folder */ + gchar *pPersonalTemp = get_win_special_folder (CSIDL_PERSONAL); + + /* and the path for the user's personal application data */ + gchar *pMyAppDataTemp = get_win_special_folder (CSIDL_LOCAL_APPDATA); + + /* and the path for common application data ("Documents and Settings\All Users\Application Data") */ + gchar *pAppDataTemp = get_win_special_folder (CSIDL_COMMON_APPDATA); + + if (0 == pAppDataTemp) + pAppData = g_build_filename("C:\\", "Documents and Settings", "All Users", "Application Data", PROGRAM_NAME, "local", 0); + else + { + pAppData = g_build_filename(pAppDataTemp, PROGRAM_NAME, "local", 0); + g_free (pAppDataTemp); + } + + if (0 == pMyAppDataTemp) + { + pMyAppData = g_build_filename(g_get_home_dir(), "Application Data", "local", 0); + } + else + { + pMyAppData = g_build_filename(pMyAppDataTemp, 0); + g_free (pMyAppDataTemp); + } + + if (0 == pPersonalTemp) + pPersonal = g_build_filename(g_get_home_dir(), 0); + else + { + pPersonal = g_build_filename(pPersonalTemp, 0); + g_free (pPersonalTemp); + } + + /* Get the path to the running application */ + pExeRoot = g_win32_get_package_installation_directory_of_module (0); + + if (0 == pExeRoot) + { + pExeRoot = g_build_filename("C:\\", "Program Files", PROGRAM_NAME, 0); + } + + if ((pExeRoot) && (pAppData) && (pMyAppData) && (pPersonal)) + { + gchar tmp[PATH_MAX+1]; + gchar* p; + + // Build our LOCALEDIR entry + if (0 != (p = g_build_filename(pAppData, "share", "locale", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our GTK_DIR entry + if (0 != (p = g_build_filename(pPersonal, ".gtk-2.0", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our CONFIG_DIR entry + if (0 != (p = g_build_filename(pAppData, "etc", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our ARDOUR_DIR entry + p = g_build_filename(pMyAppData, PROGRAM_NAME, 0); + + if (0 != p) + { + g_array_append_val (pFallbackDirs, p); + + // Build our MODULE_DIR entry + strcpy(tmp, pExeRoot); + if (0 != (p = strrchr (tmp, G_DIR_SEPARATOR))) + { + *p = '\0'; + + if (0 != (p = g_build_filename(tmp, 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our DATA_DIR entry + if (0 != (p = g_build_filename(pAppData, "share", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our ICONS_DIR entry + if (0 != (p = g_build_filename(pAppData, "share", "icons", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our PIXMAPS_DIR entry + if (0 != (p = g_build_filename(pAppData, "share", "pixmaps", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our CONTROL_SURFACES_DIR entry + if (0 != (p = g_build_filename(pExeRoot, "bin", "surfaces", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our VAMP_DIR entry + p = g_build_filename(pExeRoot, "bin", "vamp", 0); + if (p) + g_array_append_val (pFallbackDirs, p); + else + g_array_append_val (pFallbackDirs, ""); + + // Next, build our LADSPA_PATH entry + p = g_build_filename(pExeRoot, "bin", "plugins", 0); + if (p) + g_array_append_val (pFallbackDirs, p); + else + g_array_append_val (pFallbackDirs, ""); + + // And finally, build our VST_PATH entry + DWORD dwType = REG_SZ; HKEY hKey; + DWORD dwSize = PATH_MAX; p = 0; + if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_CURRENT_USER, "Software\\VST", 0, KEY_READ, &hKey)) + { + // Look for the user's VST Registry entry + if (ERROR_SUCCESS == RegQueryValueExA (hKey, "VSTPluginsPath", 0, &dwType, (LPBYTE)tmp, &dwSize)) + p = g_build_filename (Glib::locale_to_utf8(tmp).c_str(), 0); + + RegCloseKey (hKey); + } + + if (p == 0) + if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\VST", 0, KEY_READ, &hKey)) + { + // Look for a global VST Registry entry + if (ERROR_SUCCESS == RegQueryValueExA (hKey, "VSTPluginsPath", 0, &dwType, (LPBYTE)tmp, &dwSize)) + p = g_build_filename (Glib::locale_to_utf8(tmp).c_str(), 0); + + RegCloseKey (hKey); + } + + if (p == 0) + { + gchar *pVSTx86 = 0; + gchar *pProgFilesX86 = get_win_special_folder (CSIDL_PROGRAM_FILESX86); + + if (pProgFilesX86) + { + // Look for a VST folder under C:\Program Files (x86) + if (pVSTx86 = g_build_filename (pProgFilesX86, "Steinberg", "VSTPlugins", 0)) + { + if (Glib::file_test (pVSTx86, Glib::FILE_TEST_EXISTS)) + if (Glib::file_test (pVSTx86, Glib::FILE_TEST_IS_DIR)) + p = g_build_filename (pVSTx86, 0); + + g_free (pVSTx86); + } + + g_free (pProgFilesX86); + } + + if (p == 0) + { + // Look for a VST folder under C:\Program Files + gchar *pVST = 0; + gchar *pProgFiles = get_win_special_folder (CSIDL_PROGRAM_FILES); + + if (pProgFiles) + { + if (pVST = g_build_filename (pProgFiles, "Steinberg", "VSTPlugins", 0)) + { + if (Glib::file_test (pVST, Glib::FILE_TEST_EXISTS)) + if (Glib::file_test (pVST, Glib::FILE_TEST_IS_DIR)) + p = g_build_filename (pVST, 0); + + g_free (pVST); + } + + g_free (pProgFiles); + } + } + } + + if (p == 0) + { + // If all else failed, assume the plugins are under "My Documents" + pUsrHome = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); + if (pUsrHome) + p = g_build_filename (pUsrHome, "Plugins", "VST", 0); + else + { + pUsrHome = g_build_filename(g_get_home_dir(), "My Documents", 0); + if (pUsrHome) + p = g_build_filename (pUsrHome, "Plugins", "VST", 0); + } + } + else + { + gchar* q = 0; + + // Concatenate the registry path with the user's personal path + pUsrHome = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); + + if (pUsrHome) + { + q = p; + p = g_build_path (";", q, g_build_filename(pUsrHome, "Plugins", "VST", 0), 0); + } + else + { + pUsrHome = g_build_filename(g_get_home_dir(), "My Documents", 0); + if (pUsrHome) + { + q = p; + p = g_build_path (";", q, g_build_filename (pUsrHome, "Plugins", "VST", 0), 0); + } + } + } + + if (p) //VST + g_array_append_val (pFallbackDirs, p); + else + g_array_append_val (pFallbackDirs, ""); + + // BUNDLED_LV2 + p = g_build_filename(pExeRoot, "bin", "lv2", 0); + if (p) + g_array_append_val (pFallbackDirs, p); + else + g_array_append_val (pFallbackDirs, ""); + } + } + } + } + } + } + } + } + } + } + + g_free (pAppData); + g_free (pMyAppData); + g_free (pExeRoot); + g_free (pPersonal); + } + + fallback_dir_vector = fallback_folders = (gchar **) g_array_free (pFallbackDirs, FALSE); + } + } + else + fallback_dir_vector = fallback_folders; + + return (fallback_dir_vector); +} + +#else +// Assume Linux, Cygwin or OS-X. Note that in all 3 cases we only +// need to cater for unbundled releases (those built by a user from +// source). Bundled releases of Ardour and Mixbus now specifically +// write their folders and paths to the user's environment at startup. +// See the function 'fixup_bundle_environment()'. + +static gchar** +get_platform_fallback_folders () +{ +gchar **fallback_dir_vector = 0; +gchar *pUsrHome = 0; + + if (!fallback_folders) + { + GArray *pFallbackDirs; + gchar *pAppData = 0; + gchar *pExeRoot = 0; + gchar *pPersonal = 0; + + pFallbackDirs = g_array_new (TRUE, TRUE, sizeof (char *)); + + if (pFallbackDirs) + { + pAppData = g_build_filename("/usr", "local", 0); + pExeRoot = g_build_filename("/usr", "local", "lib", "ardour2", 0); + pPersonal = g_build_filename(g_get_home_dir(), 0); + + if ((pExeRoot) && (pAppData) && (pPersonal)) + { + gchar tmp[PATH_MAX+1]; + gchar* p; + + // Build our LOCALEDIR entry + if (0 != (p = g_build_filename(pAppData, "share", "locale", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our GTK_DIR entry + if (0 != (p = g_build_filename(pPersonal, ".gtk-2.0", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our CONFIG_DIR entry + if (0 != (p = g_build_filename(pAppData, "etc", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our ARDOUR_DIR entry + p = ""; // Empty string (temporary) + if (0 != p) + { + g_array_append_val (pFallbackDirs, p); + + // Build our MODULE_DIR entry + strcpy(tmp, pExeRoot); + if (0 != (p = strrchr (tmp, G_DIR_SEPARATOR))) + { + *p = '\0'; + + if (0 != (p = g_build_filename(tmp, 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our DATA_DIR entry + if (0 != (p = g_build_filename(pAppData, "share", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our ICONS_DIR entry (re-use 'tmp') + strcpy(tmp, "/usr/local/share/ardour2"); + if (0 != (p = g_build_filename(tmp, "icons", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our PIXMAPS_DIR entry + if (0 != (p = g_build_filename(tmp, "pixmaps", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our CONTROL_SURFACES_DIR entry + if (0 != (p = g_build_filename(pExeRoot, "surfaces", 0))) + { + g_array_append_val (pFallbackDirs, p); + + // Build our VAMP_DIR entry + p = g_build_filename(pExeRoot, "vamp", 0); + if (p) + g_array_append_val (pFallbackDirs, p); + + // Next, build our LADSPA_PATH entry + p = g_build_filename(Glib::path_get_dirname(pExeRoot).c_str(), "plugins", 0); + if (p) + g_array_append_val (pFallbackDirs, p); + + // And finally, build our VST_PATH entry + if (g_getenv("HOME")) + p = g_build_filename(g_getenv("HOME"), "VST", "plugins", 0); + else + p = g_build_filename(g_get_home_dir(), "VST", "plugins", 0); + + if (p) + g_array_append_val (pFallbackDirs, p); + } + } + } + } + } + } + } + } + } + } + + g_free (pAppData); + g_free (pExeRoot); + g_free (pPersonal); + } + + fallback_dir_vector = fallback_folders = (gchar **) g_array_free (pFallbackDirs, FALSE); + } + } + else + fallback_dir_vector = fallback_folders; + + if (pUsrHome) + g_free (pUsrHome); + + return (fallback_dir_vector); +} +#endif + + +//*************************************************************** +// +// get_platform_fallback_folder() +// +// Returns a const gchar* which points to a string describing +// the full path to the Ardour fallback folder corresponding to +// the supplied index. See 'get_platform_fallback_folders()' for a +// complete list of the supported index enumerations. Calling this +// function will initialize the fallback folder array if it wasn't +// already initiaized. The array should then (eventually) be freed +// using 'free_platform_fallback_folders()'. +// +// Returns: +// +// On Success: A pointer to the path string contained at the +// relevant index. +// On Failure: NULL +// +PBD_API G_CONST_RETURN gchar* PBD_APICALLTYPE +get_platform_fallback_folder (PBD::fallback_folder_t index) +{ + if ((index >= 0) && (index < FALLBACK_FOLDER_MAX)) + return ((G_CONST_RETURN gchar *)get_platform_fallback_folders ()[index]); + else + return (G_CONST_RETURN gchar *) 0; +} + + +//*************************************************************** +// +// alloc_platform_fallback_folders() +// +// Calls 'get_platform_fallback_folders()' to ensure that memory +// for the fallback folder array is already allocated before the +// array gets used. It doesn't cause any problems if the array gets +// used prior to calling this function (since the memory will get +// allocated anyway, on fist usage). Either way however, the momory +// must later be freed using 'free_platform_fallback_folders()'. +// +// Returns: +// +// The value obtained from 'get_platform_fallback_folders()' +// +PBD_API G_CONST_RETURN gchar* G_CONST_RETURN * PBD_APICALLTYPE +alloc_platform_fallback_folders () +{ + return ((G_CONST_RETURN gchar* G_CONST_RETURN *)get_platform_fallback_folders ()); +} + + +//*************************************************************** +// +// free_platform_fallback_folders() +// +// Frees the memory that was previously allocated for the Ardour +// fallback folder array. +// +// Returns: +// +// NONE. +// +PBD_API void PBD_APICALLTYPE +free_platform_fallback_folders () +{ +int index = FOLDER_LOCALE; + + if (fallback_folders) + { + gchar *p = get_platform_fallback_folders()[(fallback_folder_t)index++]; + + while (index < (FALLBACK_FOLDER_MAX+1)) { + if (p) + g_free (p); + + if (index < FALLBACK_FOLDER_MAX) + p = get_platform_fallback_folders()[(fallback_folder_t)index++]; + else + break; + } + + fallback_folders = 0; + } +} + +} // namespace PBD + diff --git a/libs/pbd/localeguard.cc b/libs/pbd/localeguard.cc new file mode 100644 index 0000000000..12093beeaa --- /dev/null +++ b/libs/pbd/localeguard.cc @@ -0,0 +1,34 @@ +#include +#include +#include + +#include "pbd/localeguard.h" + +// JE - added temporarily, to reduce the delay effects when calling +// setlocale() recursively in a Windows GUI thread (we should think +// about moving the caller(s) into a dedicated worker thread). +std::string PBD::LocaleGuard::current; + +PBD::LocaleGuard::LocaleGuard (const char* str) + : old(0) +{ + if (current != str) { + old = strdup (setlocale (LC_NUMERIC, NULL)); + if (strcmp (old, str)) { + if (setlocale (LC_NUMERIC, str)) + current = str; + } + } +} + +PBD::LocaleGuard::~LocaleGuard () +{ + if (old) { + if (setlocale (LC_NUMERIC, old)) + current = old; + + free ((char*)old); + } +} + + diff --git a/libs/pbd/msvc/fpu.cc b/libs/pbd/msvc/fpu.cc new file mode 100644 index 0000000000..6997405928 --- /dev/null +++ b/libs/pbd/msvc/fpu.cc @@ -0,0 +1,124 @@ +#ifdef COMPILER_MSVC // Added by JE - 05-12-2009. Inline assembler instructions + // have been changed to Intel format and (in the case of + // cpuid) was replaced by the equivalent VC++ system call). +#define _XOPEN_SOURCE 600 +#include +#include +#include // Added by JE - 05-12-2009 + +#include +#include + +#include "i18n.h" + +using namespace PBD; +using namespace std; + +FPU::FPU () +{ + unsigned long cpuflags = 0; + + _flags = (Flags)0; + +#ifndef ARCH_X86 + return; + +#else + +#ifndef USE_X86_64_ASM +int cpuInfo[4]; + + __cpuid (cpuInfo, 1); + cpuflags = cpuInfo[3]; +/* + __asm { // This is how the original section would look if converted to Intel syntax. + // However, I have grave doubts about whether it's doing the right thing. + // It seems as if the intention was to retrieve feature information from + // the processor. However, feature information is returned in the ebx register + // (if you believe Wikipedia) or in edx (if you believe Microsoft). Unfortunately, + // both registers get ignored in the original code!! Confused?? Join the club!! + mov eax, 1 + push ebx + cpuid + mov edx, 0 + pop ebx + mov cpuflags, ecx // This can't be right, surely??? + }; */ +#else +// Note that this syntax is currently still in AT&T format ! + asm volatile ( + "pushq %%rbx\n" + "movq $1, %%rax\n" + "cpuid\n" + "movq %%rdx, %0\n" + "popq %%rbx\n" + : "=r" (cpuflags) + : + : "%rax", "%rcx", "%rdx", "memory" + ); + +#endif /* USE_X86_64_ASM */ + + if (cpuflags & (1<<25)) { + _flags = Flags (_flags | (HasSSE|HasFlushToZero)); + } + + if (cpuflags & (1<<26)) { + _flags = Flags (_flags | HasSSE2); + } + + if (cpuflags & (1 << 24)) { + bool aligned_malloc = false; // Added by JE - 05-12-2009 + char* fxbuf = 0; +// This section changed by JE - 05-12-2009 +#ifdef NO_POSIX_MEMALIGN +#if defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // All of these support '_aligned_malloc()' + fxbuf = (char *) _aligned_malloc(512, 16); // (note that they all need at least MSVC runtime 7.0) + aligned_malloc = true; +#else + fxbuf = (char *) malloc(512); +#endif +#else + fxbuf = posix_memalign ((void**)&fxbuf, 16, 512); +#endif + // Verify that fxbuf is correctly aligned + unsigned long buf_addr = (unsigned long)(void*)fxbuf; + if ((0 == buf_addr) || (buf_addr % 16)) + error << _("cannot allocate 16 byte aligned buffer for h/w feature detection") << endmsg; + else + { + memset(fxbuf, 0, 512); // Initialize the buffer !!! Added by JE - 12-12-2009 + + __asm { + mov eax, fxbuf + fxsave [eax] + }; + + uint32_t mxcsr_mask = *((uint32_t*) &fxbuf[28]); + + /* if the mask is zero, set its default value (from intel specs) */ + + if (mxcsr_mask == 0) { + mxcsr_mask = 0xffbf; + } + + if (mxcsr_mask & (1<<6)) { + _flags = Flags (_flags | HasDenormalsAreZero); + } + + if (aligned_malloc) + _aligned_free (fxbuf); + else + free (fxbuf); + } + } +#endif // ARCH_X86 +} + +FPU::~FPU () +{ +} + +#else // !COMPILER_MSVC + const char* pbd_fpu = "original pbd/fpu.cc takes precedence over this file"; +#endif // COMPILER_MSVC diff --git a/libs/pbd/msvc/mountpoint.cc b/libs/pbd/msvc/mountpoint.cc new file mode 100644 index 0000000000..d30b24462f --- /dev/null +++ b/libs/pbd/msvc/mountpoint.cc @@ -0,0 +1,166 @@ +/* + Copyright (C) 2002 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: mountpoint.cc 3920 2008-10-11 12:34:46Z paul $ +*/ + +#ifdef COMPILER_MSVC + +/* TODO - Still to be implemented */ + +#include +#include +#include +#include +#include + +#include + +using std::string; + +#if HAVE_GETMNTENT +#include + +struct mntent_sorter { + bool operator() (const mntent *a, const mntent *b) { + return strcmp (a->mnt_dir, b->mnt_dir); + } +}; + +string +mountpoint (string path) +{ + FILE *mntf; + mntent *mnt; + unsigned int maxmatch = 0; + unsigned int matchlen; + const char *cpath = path.c_str(); + char best[PATH_MAX+1]; + + if ((mntf = setmntent ("/etc/mtab", "r")) == 0) { + return ""; + } + + best[0] = '\0'; + + while ((mnt = getmntent (mntf))) { + unsigned int n; + + n = 0; + matchlen = 0; + + /* note: strcmp's semantics are not + strict enough to use for this. + */ + + while (cpath[n] && mnt->mnt_dir[n]) { + if (cpath[n] != mnt->mnt_dir[n]) { + break; + } + matchlen++; + n++; + } + + if (cpath[matchlen] == '\0') { + + endmntent (mntf); + return mnt->mnt_dir; + + } else { + + if (matchlen > maxmatch) { + snprintf (best, sizeof(best), "%s", mnt->mnt_dir); + maxmatch = matchlen; + } + } + } + + endmntent (mntf); + + return best; +} + +#else // !HAVE_GETMNTENT + +string +mountpoint (string path) +{ +return ""; + +/* // The rest is commented out temporarily by JE - 30-11-2009 + // (I think this must be the implementation for MacOS). + struct statfs *mntbufp = 0; + int count; + unsigned int maxmatch = 0; + unsigned int matchlen; + const char *cpath = path.c_str(); + char best[PATH_MAX+1]; + + if ((count = getmntinfo(&mntbufp, MNT_NOWAIT)) == 0) { + free(mntbufp); + return "\0"; + } + + best[0] = '\0'; + + for (int i = 0; i < count; ++i) { + unsigned int n = 0; + matchlen = 0; + + // note: strcmp's semantics are not + // strict enough to use for this. + + while (cpath[n] && mntbufp[i].f_mntonname[n]) { + if (cpath[n] != mntbufp[i].f_mntonname[n]) { + break; + } + matchlen++; + n++; + } + + if (cpath[matchlen] == '\0') { + snprintf(best, sizeof(best), "%s", mntbufp[i].f_mntonname); + free(mntbufp); + return best; + + } else { + + if (matchlen > maxmatch) { + snprintf (best, sizeof(best), "%s", mntbufp[i].f_mntonname); + maxmatch = matchlen; + } + } + } + + return best; +*/ +} +#endif // HAVE_GETMNTENT + +#ifdef TEST_MOUNTPOINT + +main (int argc, char *argv[]) +{ + printf ("mp of %s = %s\n", argv[1], mountpoint (argv[1]).c_str()); + exit (0); +} + +#endif // TEST_MOUNTPOINT + +#else // !COMPILER_MSVC + const char* pbd_mountpoint = "original pbd/mountpoint.cc takes precedence over this file"; +#endif // COMPILER_MSVC diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc new file mode 100644 index 0000000000..45137da0f3 --- /dev/null +++ b/libs/pbd/msvc/msvc_pbd.cc @@ -0,0 +1,895 @@ +/* + Copyright (C) 2009 John Emmas + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifdef COMPILER_MSVC + +#include + +extern "C" WINBASEAPI BOOL WINAPI +CreateHardLinkA( LPCSTR lpFileName, + LPCSTR lpExistingFileName, + LPSECURITY_ATTRIBUTES lpSecurityAttributes ); // Needs kernel32.lib on anything higher than Win2K + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // Should ensure that we include the right + // version - but we'll check anyway, later + +#include + +#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 + +struct timezone +{ + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +PBD_API int PBD_APICALLTYPE +gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz) // Does this need to be exported ? +{ +FILETIME ft; +unsigned __int64 tmpres = 0; +static int tzflag = 0; + + if (NULL != tv) + { + GetSystemTimeAsFileTime(&ft); + + tmpres |= ft.dwHighDateTime; + tmpres <<= 32; + tmpres |= ft.dwLowDateTime; + + /*converting file time to unix epoch*/ + tmpres /= 10; /*convert into microseconds*/ + tmpres -= DELTA_EPOCH_IN_MICROSECS; + tv->tv_sec = (long)(tmpres / 1000000UL); + tv->tv_usec = (long)(tmpres % 1000000UL); + } + + if (NULL != tz) + { + struct timezone *ptz = static_cast (tz); + if (!tzflag) + { + _tzset(); + tzflag++; + } + if (ptz) + { + ptz->tz_minuteswest = _timezone / 60; + ptz->tz_dsttime = _daylight; + } + } + + return 0; +} + +// Define the default comparison operators for Windows (ptw32) 'pthread_t' (not used +// by Ardour AFAIK but would be needed if an array of 'pthread_t' had to be sorted). +#ifndef PTHREAD_H // Defined by PTW32 (Linux and other versions define _PTHREAD_H) +#error "An incompatible version of 'pthread.h' is #included. Use only the Windows (ptw32) version!" +#else +bool operator> (const pthread_t& lhs, const pthread_t& rhs) +{ + return (std::greater()(lhs.p, rhs.p)); +} + +bool operator< (const pthread_t& lhs, const pthread_t& rhs) +{ + return (std::less()(lhs.p, rhs.p)); +} + +bool operator!= (const pthread_t& lhs, const pthread_t& rhs) +{ + return (std::not_equal_to()(lhs.p, rhs.p)); +} + +bool operator== (const pthread_t& lhs, const pthread_t& rhs) +{ + return (!(lhs != rhs)); +} +#endif + +// Functions supplied (later) to std::transform +//*************************************************************** +// +// invert_backslash() +// +// Examines a supplied ASCII character and (if the character is +// a backslash) converts it to a forward slash, +// +// Returns: +// +// The supplied character (converted, if it was a backslash) +// +char invert_backslash(char character) +{ + if ('\\' == character) + character = '/'; + + return (character); +} + +//*************************************************************** +// +// invert_forwardslash() +// +// Examines a supplied ASCII character and (if the character is +// a forward slash) converts it to a backslash, +// +// Returns: +// +// The supplied character (converted, if it was a fwd slash) +// +char invert_forwardslash(char character) +{ + if ('/' == character) + character = '\\'; + + return (character); +} + + +//*************************************************************** +// +// pread() +// +// Emulates pread() using _lseek()/_read()/_lseek(). +// +// Returns: +// +// On Success: The number of bytes read from the file +// On Failure: -1 +// +PBD_API ssize_t PBD_APICALLTYPE +pread(int handle, void *buf, size_t nbytes, off_t offset) +{ +int old_errno; +ssize_t ret; + + off_t old_offset = _tell(handle); + + if (0 > old_offset) + ret = (-1); + else + { + _lseek(handle, offset, SEEK_SET); + ret = _read(handle, buf, nbytes); + + old_errno = errno; + _lseek(handle, old_offset, SEEK_SET); + errno = old_errno; + } + + return (ret); +} + + +//*************************************************************** +// +// pwrite() +// +// Emulates pwrite() using _lseek()/_write()/_lseek(). +// +// Returns: +// +// On Success: The number of bytes written to the file +// On Failure: -1 +// +PBD_API ssize_t PBD_APICALLTYPE +pwrite(int handle, const void *buf, size_t nbytes, off_t offset) +{ +int old_errno; +ssize_t ret; + + off_t old_offset = _lseek(handle, offset, SEEK_SET); + + if (0 > old_offset) + ret = (-1); + else + { + ret = _write(handle, buf, nbytes); + + old_errno = errno; + _lseek(handle, old_offset, SEEK_SET); + errno = old_errno; + } + + return (ret); +} + +namespace PBD { + +//*************************************************************** +// +// TestForMinimumSpecOS() +// +// Tests the user's OS to see if it is Win2K or later (could be +// expanded quite easily to accommodate other OS's) +// +// Returns: +// +// On Success: TRUE (if the user's OS matches the minimum spec) +// On Failure: FALSE otherwise +// +PBD_API bool PBD_APICALLTYPE +TestForMinimumSpecOS(char *revision /* currently ignored */) +{ +bool bRet = true; +#ifdef PLATFORM_WINDOWS + bRet = false; + HINSTANCE hKernelDll = (HINSTANCE)dlopen("kernel32.dll", RTLD_NOW); + + if (hKernelDll) + { + // 'CreateHardLink()' is only available from Win2K onwards. + if (NULL != dlsym(hKernelDll, "CreateHardLinkA")) + bRet = true; + + dlclose(hKernelDll); + } +#endif + // Other OS's could be accommodated here + + return (bRet); +} + + +//*************************************************************** +// +// realpath() +// +// Emulates POSIX realpath() using Win32 _fullpath(). +// +// Returns: +// +// On Success: A pointer to the resolved (absolute) path +// On Failure: NULL +// +PBD_API char* PBD_APICALLTYPE +realpath (const char *original_path, char resolved_path[_MAX_PATH+1]) +{ +char *pRet = NULL; +bool bIsSymLink = 0; // We'll probably need to test the incoming path + // to find out if it points to a Windows shortcut + // (or a hard link) and set this appropriately. + if (bIsSymLink) + { + // At the moment I'm not sure if Windows '_fullpath()' is directly + // equivalent to POSIX 'realpath()' - in as much as the latter will + // resolve the supplied path if it happens to point to a symbolic + // link ('_fullpath()' probably DOESN'T do this but I'm not really + // sure if Ardour needs such functionality anyway). Therefore we'll + // possibly need to add that functionality here at a later date. + } + else + { + char temp[(MAX_PATH+1)*6]; // Allow for maximum length of a path in UTF8 characters + + // POSIX 'realpath()' requires that the buffer size is at + // least PATH_MAX+1, so assume that the user knew this !! + pRet = _fullpath(temp, Glib::locale_from_utf8(original_path).c_str(), _MAX_PATH); + if (NULL != pRet) + strcpy(resolved_path, Glib::locale_to_utf8(temp).c_str()); + } + + return (pRet); +} + + +//*************************************************************** +// +// opendir() +// +// Creates a pointer to a DIR structure, appropriately filled in +// and ready to begin a directory search iteration. +// +// Returns: +// +// On Success: Pointer to a (heap based) DIR structure +// On Failure: NULL +// +PBD_API DIR* PBD_APICALLTYPE +opendir (const char *szPath) +{ +wchar_t wpath[PATH_MAX+1]; +unsigned int rc; +DIR *pDir = 0; + + errno = 0; + + if (!szPath) + errno = EFAULT; + + if ((!errno) && ('\0' == szPath[0])) + errno = ENOTDIR; + + // Determine if the given path really is a directory + + if (!errno) + if (0 == MultiByteToWideChar (CP_UTF8, 0, (LPCSTR)szPath, -1, (LPWSTR)wpath, sizeof(wpath))) + errno = EFAULT; + + if ((!errno) && ((rc = GetFileAttributesW(wpath)) == -1)) + errno = ENOENT; + + if ((!errno) && (!(rc & FILE_ATTRIBUTE_DIRECTORY))) + // Error. Entry exists but not a directory. */ + errno = ENOTDIR; + + if (!errno) + { + // Allocate enough memory to store DIR structure, plus + // the complete directory path originally supplied. + pDir = (DIR *)malloc(sizeof(DIR) + strlen(szPath) + strlen("\\") + strlen ("*")); + + if (!pDir) + { + // Error - out of memory + errno = ENOMEM; + } + } + + if (!errno) + { + // Create the search expression + strcpy(pDir->dd_name, szPath); + + // Add a backslash if the path doesn't already end with one + if (pDir->dd_name[0] != '\0' && + pDir->dd_name[strlen(pDir->dd_name) - 1] != '/' && + pDir->dd_name[strlen(pDir->dd_name) - 1] != '\\') + { + strcat (pDir->dd_name, "\\"); + } + + // Add the search pattern + strcat(pDir->dd_name, "*"); + + // Initialize handle to -1 so that a premature closedir() + // doesn't try to call _findclose() on it. + pDir->dd_handle = (-1); + + // Initialize the status + pDir->dd_stat = 0; + + // Initialize the dirent structure. 'ino' and 'reclen' are invalid under Win32 + // and 'name' simply points at the appropriate part of the findfirst_t struct. + pDir->dd_dir.d_ino = 0; + pDir->dd_dir.d_reclen = 0; + pDir->dd_dir.d_namlen = 0; + strcpy(pDir->dd_dir.d_name, pDir->dd_dta.name); + + return (pDir); // Succeeded + } + + if (pDir) + free (pDir); + return (DIR *) 0; // Failed +} + + +//*************************************************************** +// +// readdir() +// +// Return a pointer to a dirent struct, filled with information +// about the next entry in the directory. +// +// Returns: +// +// On Success: A pointer to the supplied DIR's 'dirent' struct +// On Failure: NULL +// +PBD_API struct dirent* PBD_APICALLTYPE +readdir (DIR* pDir) +{ +int old_errno = 0; +errno = 0; + + // Check for valid DIR struct + if (!pDir) + errno = EFAULT; + + if ((strcmp(pDir->dd_dir.d_name, pDir->dd_dta.name)) && (!errno)) + // The structure does not seem to be set up correctly + errno = EINVAL; + else + { + if (pDir->dd_stat < 0) + { + // We have already returned all files in this directory + // (or the structure has an invalid dd_stat). + return (struct dirent *)0; + } + else if (pDir->dd_stat == 0) + { + // We haven't started the search yet. + // Start the search + pDir->dd_handle = _findfirst (Glib::locale_from_utf8(pDir->dd_name).c_str(), &(pDir->dd_dta)); + + if (pDir->dd_handle == -1) + // The directory is empty + pDir->dd_stat = -1; + else + pDir->dd_stat = 1; + } + else + { + // Do not return ENOENT on last file in directory + old_errno = errno; + + // Get the next search entry + if (_findnext (pDir->dd_handle, &(pDir->dd_dta))) + { + // We are off the end or otherwise error + errno = old_errno; + _findclose (pDir->dd_handle); + pDir->dd_handle = -1; + pDir->dd_stat = -1; + } + else + // Update to indicate the correct status number + pDir->dd_stat++; + } + + if (pDir->dd_stat > 0) + { + // We successfully got an entry. Details about the file are + // already appropriately filled in except for the length of + // file name. + strcpy(pDir->dd_dir.d_name, pDir->dd_dta.name); + pDir->dd_dir.d_namlen = strlen (pDir->dd_dir.d_name); + return (&pDir->dd_dir); // Succeeded + } + } + + return (struct dirent *) 0; // Failed +} + + +//*************************************************************** +// +// closedir() +// +// Frees the resources allocated by opendir(). +// +// Returns: +// +// On Success: 0 +// On Failure: -1 +// +PBD_API int PBD_APICALLTYPE +closedir (DIR *pDir) +{ +int rc = 0; + + errno = 0; + + if (!pDir) + errno = EFAULT; + else + { + if ((-1) != pDir->dd_handle) + rc = _findclose (pDir->dd_handle); + + // Free the DIR structure + free (pDir); + + return rc; // Succeeded + } + + return (-1); // Failed +} + +//*************************************************************** +// +// mkstemp() +// +// Emulates Linux mkstemp() using Win32 _mktemp() and _open() etc. +// +// Returns: +// +// On Success: A file descriptor for the opened file. +// On Failure: (-1) +// +PBD_API int PBD_APICALLTYPE +mkstemp (char *template_name) +{ +int ret = (-1); +char *szFileName; +char szTempPath[PATH_MAX+100]; // Just ensure we have plenty of buffer space + + if (NULL != (szFileName = _mktemp(template_name))) + { + if (0 != ::GetTempPathA(sizeof(szTempPath), szTempPath)) + { + strcat(szTempPath, szFileName); + ret = _open(szTempPath, (_O_CREAT|_O_BINARY|_O_TEMPORARY|_O_RDWR|_O_TRUNC), _S_IWRITE); + } + } + + return (ret); +} + + +//*************************************************************** +// +// ntfs_link() +// +// Emulates Linux link() using Win32 CreateHardLink()(NTFS only). +// +// Returns: +// +// On Success: Non-zero. +// On Failure: Zero (call 'GetLastError()' to retrieve info) +// +PBD_API int PBD_APICALLTYPE +ntfs_link (const char *existing_filepath, const char *link_filepath) +{ +int ret = 1; // 'ERROR_INVALID_FUNCTION' +bool bValidPath = false; + + // Make sure we've been sent a valid input string + if (existing_filepath && link_filepath) + { + std::string strRoot = existing_filepath; + + if ((1 < strRoot.length()) && ('\\' == existing_filepath[0]) && ('\\' == existing_filepath[1])) + { + int slashcnt = 0; + + // We've been sent a network path. Convert backslashes to forward slashes temporarily. + std::transform(strRoot.begin(), strRoot.end(), strRoot.begin(), invert_backslash); + + // Now, if there are less than four slashes, add a fourth one or abort + std::string::iterator iter = strRoot.begin(); + while ((slashcnt < 4) && (iter != strRoot.end())) + { + if ('/' == (*iter)) + slashcnt++; + + ++iter; + } + + if (slashcnt > 2) + { + // If only 3 slashes were counted, add a trailing slash + if (slashcnt == 3) + strRoot += '/'; + + // Now find the position of the fourth slash + iter = strRoot.begin(); + int charcnt = 0; + for (slashcnt=0; slashcnt<4;) + { + charcnt++; + + if ('/' == (*iter)) + slashcnt++; + + if (++iter == strRoot.end()) + break; + } + + strRoot.resize(charcnt); + bValidPath = true; + } + } + else + { + // Assume a standard Windows style path + if (1 < strRoot.length() && (':' == existing_filepath[1])) + { + // Convert backslashes to forward slashes temporarily. + std::transform(strRoot.begin(), strRoot.end(), strRoot.begin(), invert_backslash); + + if (2 == strRoot.length()) + strRoot += '/'; + + if ('/' == strRoot[2]) + { + strRoot.resize(3); + bValidPath = true; + } + } + } + + if (bValidPath) + { + char szFileSystemType[_MAX_PATH+1]; + + // Restore the original backslashes + std::transform(strRoot.begin(), strRoot.end(), strRoot.begin(), invert_forwardslash); + + // Windows only supports hard links for the NTFS filing + // system, so let's make sure that's what we're using!! + if (::GetVolumeInformationA(strRoot.c_str(), NULL, 0, NULL, NULL, NULL, szFileSystemType, _MAX_PATH+1)) + { + std::string strRootFileSystemType = szFileSystemType; + std::transform(strRootFileSystemType.begin(), strRootFileSystemType.end(), strRootFileSystemType.begin(), ::toupper); +#if (_WIN32_WINNT >= 0x0500) + if (0 == strRootFileSystemType.compare("NTFS")) + { + if (TestForMinimumSpecOS()) // Hard links were only available from Win2K onwards + if (0 == CreateHardLinkA(link_filepath, existing_filepath, NULL)) + { // Note that the above API call cannot create a link to a directory, so + // should we also be checking that the supplied path was actually a file? + ret = GetLastError(); + } + else + SetLastError(ret = 0); // 'NO_ERROR' + } + else + { + ret = 4300; // 'ERROR_INVALID_MEDIA' + } +#endif + } + } + else + ret = 123; // 'ERROR_INVALID_NAME' + } + else + ret = 161; // 'ERROR_BAD_PATHNAME' + + if (ret) + { + SetLastError(ret); + return (-1); + } + else + return (0); +} + + +//*************************************************************** +// +// ntfs_unlink() +// +// Emulates Linux unlink() using Win32 DeleteFile()(NTFS only). +// +// Returns: +// +// On Success: Non-zero. +// On Failure: Zero (call 'GetLastError()' to retrieve info) +// +PBD_API int PBD_APICALLTYPE +ntfs_unlink (const char *link_filepath) +{ +int ret = 1; // 'ERROR_INVALID_FUNCTION' +bool bValidPath = false; + + // Make sure we've been sent a valid input string + if (link_filepath) + { + std::string strRoot = link_filepath; + + if ((1 < strRoot.length()) && ('\\' == link_filepath[0]) && ('\\' == link_filepath[1])) + { + int slashcnt = 0; + + // We've been sent a network path. Convert backslashes to forward slashes temporarily. + std::transform(strRoot.begin(), strRoot.end(), strRoot.begin(), invert_backslash); + + // Now, if there are less than four slashes, add a fourth one or abort + std::string::iterator iter = strRoot.begin(); + while ((slashcnt < 4) && (iter != strRoot.end())) + { + if ('/' == (*iter)) + slashcnt++; + + ++iter; + } + + if (slashcnt > 2) + { + // If only 3 slashes were counted, add a trailing slash + if (slashcnt == 3) + strRoot += '/'; + + // Now find the position of the fourth slash + iter = strRoot.begin(); + int charcnt = 0; + for (slashcnt=0; slashcnt<4;) + { + charcnt++; + + if ('/' == (*iter)) + slashcnt++; + + if (++iter == strRoot.end()) + break; + } + + strRoot.resize(charcnt); + bValidPath = true; + } + } + else + { + // Assume a standard Windows style path + if (1 < strRoot.length() && (':' == link_filepath[1])) + { + // Convert backslashes to forward slashes temporarily. + std::transform(strRoot.begin(), strRoot.end(), strRoot.begin(), invert_backslash); + + if (2 == strRoot.length()) + strRoot += '/'; + + if ('/' == strRoot[2]) + { + strRoot.resize(3); + bValidPath = true; + } + } + } + + if (bValidPath) + { + char szFileSystemType[_MAX_PATH+1]; + + // Restore the original backslashes + std::transform(strRoot.begin(), strRoot.end(), strRoot.begin(), invert_forwardslash); + + // Windows only supports hard links for the NTFS filing + // system, so let's make sure that's what we're using!! + if (::GetVolumeInformationA(strRoot.c_str(), NULL, 0, NULL, NULL, NULL, szFileSystemType, _MAX_PATH+1)) + { + std::string strRootFileSystemType = szFileSystemType; + std::transform(strRootFileSystemType.begin(), strRootFileSystemType.end(), strRootFileSystemType.begin(), ::toupper); +#if (_WIN32_WINNT >= 0x0500) + if (0 == strRootFileSystemType.compare("NTFS")) + if (TestForMinimumSpecOS()) // Hard links were only available from Win2K onwards + if (0 == DeleteFileA(link_filepath)) + ret = GetLastError(); + else + ret = 0; // 'NO_ERROR' +#endif + } + } + else + ret = 123; // 'ERROR_INVALID_NAME' + } + else + ret = 161; // 'ERROR_BAD_PATHNAME' + + if (ret) + { + SetLastError(ret); + return (-1); + } + else + return (0); +} + +} // namespace PBD + + +//*************************************************************** +// +// dlopen() +// +// Emulates POSIX dlopen() using Win32 LoadLibrary(). +// +// Returns: +// +// On Success: A handle to the opened DLL +// On Failure: NULL +// +PBD_API void* PBD_APICALLTYPE +dlopen (const char *file_name, int mode) +{ + // Note that 'mode' is ignored in Win32 + return(::LoadLibraryA(Glib::locale_from_utf8(file_name).c_str())); +} + + +//*************************************************************** +// +// dlclose() +// +// Emulates POSIX dlclose() using Win32 FreeLibrary(). +// +// Returns: +// +// On Success: A non-zero number +// On Failure: 0 +// +PBD_API int PBD_APICALLTYPE +dlclose (void *handle) +{ + return (::FreeLibrary((HMODULE)handle)); +} + + +//*************************************************************** +// +// dlsym() +// +// Emulates POSIX dlsym() using Win32 GetProcAddress(). +// +// Returns: +// +// On Success: A pointer to the found function or symbol +// On Failure: NULL +// +PBD_API void* PBD_APICALLTYPE +dlsym (void *handle, const char *symbol_name) +{ + // First test for RTLD_DEFAULT and RTLD_NEXT + if ((handle == 0/*RTLD_DEFAULT*/) || (handle == ((void *) -1L)/*RTLD_NEXT*/)) + { + return 0; // Not yet supported for Win32 + } + else + return (::GetProcAddress((HMODULE)handle, symbol_name)); +} + +#define LOCAL_ERROR_BUF_SIZE 1024 +static char szLastWinError[LOCAL_ERROR_BUF_SIZE]; +//*************************************************************** +// +// dlerror() +// +// Emulates POSIX dlerror() using Win32 GetLastError(). +// +// Returns: +// +// On Success: The translated message corresponding to the +// last error +// On Failure: NULL (if the last error was ERROR_SUCCESS) +// +PBD_API char* PBD_APICALLTYPE +dlerror () +{ + DWORD dwLastErrorId = GetLastError(); + if (ERROR_SUCCESS == dwLastErrorId) + return 0; + else + { + if (0 == FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + dwLastErrorId, + 0, + szLastWinError, + LOCAL_ERROR_BUF_SIZE, + 0)) + { + sprintf(szLastWinError, "Could not decipher the previous error message"); + } + + // POSIX dlerror() seems to reset the + // error system, so emulate that here + SetLastError(ERROR_SUCCESS); + } + + return(szLastWinError); +} + +#endif // COMPILER_MSVC diff --git a/libs/pbd/msvc/msvc_poll.cc b/libs/pbd/msvc/msvc_poll.cc new file mode 100644 index 0000000000..e12ef2bbef --- /dev/null +++ b/libs/pbd/msvc/msvc_poll.cc @@ -0,0 +1,215 @@ +/* + Copyright (C) 2009 John Emmas + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifdef COMPILER_MSVC + +//#include +#include "pbd/msvc_pbd.h" + +#ifndef _DWORD_DEFINED +#define _DWORD_DEFINED +typedef unsigned long DWORD; +#endif // !_DWORD_DEFINED + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Note that this entire strategy failed to work, at least for pipes. It turned * + * out that Windows 'tell()' always returns 0 when used on a pipe. This strategy * + * is now deprecated, having been replaced by a new pipe-like object, which I've * + * called 'PBD::pipex'. This polling functionality is included here mostly so * + * that Ardour will build and launch under Windows. However, any module that * + * relies on polling a pipe will eventually need to use the new pipex object. * + * This code will allow it to compile and link successfully, although it won't * + * poll successfully at run time. Having said that, these functions might well * + * work for ports and/or other machanisms that get represented by a file handle. * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +int poll_input (struct pollfd *fds, nfds_t nfds, int& elapsed_time, int timeout) +{ +DWORD dwOldTickCount, + dwNewTickCount = GetTickCount(); +bool input = false, + error = false; +int ret = 0; + + if (NULL != fds) + { + nfds_t loop; + short ev_mask = (POLLOUT|POLLWRNORM|POLLWRBAND); + + errno = NO_ERROR; + + do + { + dwOldTickCount = dwNewTickCount; + + for (loop=0; loop pos) + { + // An error occured ('errno' should have been set by '_tell()') + ret = (-1); + fds[loop].revents = POLLERR; + if (fds[loop].events & POLLRDNORM) + fds[loop].revents |= POLLRDNORM; + if (fds[loop].events & POLLRDBAND) + fds[loop].revents |= POLLRDBAND; + if (fds[loop].events & POLLPRI) + fds[loop].revents |= POLLPRI; + + // Do we want to abort on error? + if (fds[loop].events & POLLERR) + error = true; + } + else if (pos > 0) + { + // Input characters were found for this fd + ret += 1; + if (fds[loop].events & POLLRDNORM) + fds[loop].revents |= POLLRDNORM; + if (fds[loop].events & POLLRDBAND) + fds[loop].revents |= POLLRDBAND; + if (fds[loop].events & POLLPRI) + fds[loop].revents |= POLLPRI; + + // Do we want to abort on input? + if ((fds[loop].events & POLLIN) || + (fds[loop].events & POLLPRI) || + (fds[loop].events & POLLRDNORM) || + (fds[loop].events & POLLRDBAND)) + input = true; + } + } + } + + if (input) + break; + + dwNewTickCount = GetTickCount(); + elapsed_time += (dwNewTickCount-dwOldTickCount); + // Note that the above will wrap round if the user leaves + // his computer powered up for more than about 50 days! + + // Sleep briefly because GetTickCount() only has an accuracy of 10mS + Sleep(10); // For some reason 'g_usleep()' craps over everything here. Different 'C' runtimes??? + + } while ((!error) && ((timeout == (-1)) || (elapsed_time < timeout))); + } + else + { + errno = ERROR_BAD_ARGUMENTS; + ret = (-1); + } + + return (ret); +} + +int poll_output (struct pollfd *fds, nfds_t nfds, int& elapsed_time, int timeout) +{ +int ret = 0; // This functionality is not yet implemented + + if (NULL != fds) + { + // Just flag whichever pollfd was specified for writing + short ev_mask = (POLLOUT|POLLWRNORM|POLLWRBAND); + + errno = NO_ERROR; + elapsed_time = 0; + + for (nfds_t loop=0; loop OPEN_MAX) || (nfds > NPOLLFILE)) + { + errno = ERROR_TOO_MANY_OPEN_FILES; + } + else + { + ret = 0; + + for (nfds_t loop=0; loop +#include + +#ifdef PLATFORM_WINDOWS // Would not be relevant for Cygwin!! + PBD_API gchar* PBD_APICALLTYPE get_win_special_folder (int csidl); +#endif + +namespace PBD { + + typedef enum fallback_folder_t { + FOLDER_LOCALE, + FOLDER_GTK, + FOLDER_CONFIG, + FOLDER_ARDOUR, + FOLDER_MODULE, + FOLDER_DATA, + FOLDER_ICONS, + FOLDER_PIXMAPS, + FOLDER_CONTROL_SURFACES, + FOLDER_VAMP, + FOLDER_LADSPA, + FOLDER_VST, + FOLDER_BUNDLED_LV2, + FALLBACK_FOLDER_MAX + }; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + PBD_API G_CONST_RETURN gchar* PBD_APICALLTYPE get_platform_fallback_folder (PBD::fallback_folder_t index); + PBD_API G_CONST_RETURN gchar* G_CONST_RETURN * PBD_APICALLTYPE alloc_platform_fallback_folders (); + PBD_API void PBD_APICALLTYPE free_platform_fallback_folders (); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +} // namespace PBD + +#endif /* __platform_fallback_folders_h__ */ diff --git a/libs/pbd/pbd/localeguard.h b/libs/pbd/pbd/localeguard.h new file mode 100644 index 0000000000..20899b5c80 --- /dev/null +++ b/libs/pbd/pbd/localeguard.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 1999-2010 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __pbd_localeguard_h__ +#define __pbd_localeguard_h__ + +#include + +namespace PBD { + +struct LocaleGuard { + LocaleGuard (const char*); + ~LocaleGuard (); + const char* old; + + /* JE - temporary !!!! */static std::string current; +}; + +}; // namespace + +#endif /* __pbd_localeguard_h__ */ diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h new file mode 100644 index 0000000000..1c971308d7 --- /dev/null +++ b/libs/pbd/pbd/msvc_pbd.h @@ -0,0 +1,235 @@ +/* + Copyright (C) 2009 John Emmas + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ +#ifndef _msvc_pbd_h_ +#define _msvc_pbd_h_ + +#ifdef PBD_IS_IN_WIN_STATIC_LIB // #define if your project uses libpbd (under Windows) as a static library +#define PBD_IS_IN_WINDLL 0 +#endif + +#ifdef COMPILER_MSVC +#include +#else +#include +#include +#endif + +#if !defined(PBD_IS_IN_WINDLL) + #if defined(COMPILER_MSVC) || defined(COMPILER_MINGW) + // If you need '__declspec' compatibility, add extra compilers to the above as necessary + #define PBD_IS_IN_WINDLL 1 + #else + #define PBD_IS_IN_WINDLL 0 + #endif +#endif + +#if PBD_IS_IN_WINDLL && !defined(PBD_API) + #if defined(BUILDING_PBD) + #define PBD_API __declspec(dllexport) + #define PBD_APICALLTYPE __stdcall + #elif defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // Probably needs Cygwin too, at some point + #define PBD_API __declspec(dllimport) + #define PBD_APICALLTYPE __stdcall + #else + #error "Attempting to define __declspec with an incompatible compiler !" + #endif +#elif !defined(PBD_API) + // Other compilers / platforms could be accommodated here + #define PBD_API + #define PBD_APICALLTYPE +#endif + +#ifndef _MAX_PATH +#define _MAX_PATH 260 +#endif +#ifndef PATH_MAX +#define PATH_MAX _MAX_PATH +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +// This function is (hopefully) temporary and is placed here +// because 'g_usleep()' doesn't seem to work very well for glib-win32 +void pbd_g_usleep (unsigned long microseconds); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#ifndef POLLIN +#define POLLIN 1 +#define POLLPRI 2 +#define POLLOUT 4 +#define POLLERR 8 +#define POLLHUP 16 +#define POLLNVAL 32 +#define NPOLLFILE 64 + +#define POLLRDNORM POLLIN +#define POLLRDBAND POLLIN +#define POLLWRNORM POLLOUT +#define POLLWRBAND POLLOUT +#endif + +#ifdef PLATFORM_WINDOWS + +#ifndef PBDEXTN_API + #if defined(BUILDING_PBDEXTN) + #define PBDEXTN_API __declspec(dllexport) + #define PBDEXTN_APICALLTYPE __cdecl + #elif defined(COMPILER_MSVC) || defined(COMPILER_MINGW) // Probably needs Cygwin too, at some point + #define PBDEXTN_API __declspec(dllimport) + #define PBDEXTN_APICALLTYPE __cdecl + #else + #error "Attempting to define __declspec with an incompatible compiler !" + #endif +#endif // PBDEXTN_API + +#ifndef CYGIMPORT_API + #define CYGIMPORT_API __declspec(dllimport) + #define CYGIMPORT_APICALLTYPE __cdecl +#endif // CYGIMPORT_API + +#ifndef __THROW +#define __THROW throw() +#endif + +#ifndef RTLD_DEFAULT +#define RTLD_DEFAULT ((void *) 0) +#define RTLD_NEXT ((void *) -1L) +#define RTLD_LAZY 0x00001 +#define RTLD_NOW 0x00002 +#define RTLD_BINDING_MASK 0x00003 +#define RTLD_NOLOAD 0x00004 +#define RTLD_GLOBAL 0x00004 +#define RTLD_DEEPBIND 0x00008 +#endif + +#ifndef OPEN_MAX +#define OPEN_MAX 32 +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +PBDEXTN_API int PBDEXTN_APICALLTYPE cyginit (unsigned int result); +PBD_API int PBD_APICALLTYPE dlclose (void *handle) __THROW; +PBD_API void* PBD_APICALLTYPE dlopen (const char *file_name, int mode) __THROW; +PBD_API void* PBD_APICALLTYPE dlsym (void *handle, const char *symbol_name) __THROW; +PBD_API char* PBD_APICALLTYPE dlerror () __THROW; + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#ifndef __CYGWIN__ +#include +#include +#include + +typedef int (FAR PBDEXTN_APICALLTYPE *CYGINIT_API)(unsigned int); + +#ifndef FILENAME_MAX +#define FILENAME_MAX (260) +#endif + +#ifndef _SSIZE_T_ +#define _SSIZE_T_ +typedef long _ssize_t; + +#ifndef _NO_OLDNAMES +typedef _ssize_t ssize_t; +#endif +#endif /* ! _SSIZE_T_ */ + +struct dirent +{ + long d_ino; // Always zero + unsigned short d_reclen; // Always zero + unsigned short d_namlen; // Length of name in d_name + char d_name[FILENAME_MAX]; // File name +}; + +// This is an internal data structure. Do not use it +// except as an argument to one of the functions below. +typedef struct +{ + // Disk transfer area for this dir + struct _finddata_t dd_dta; + + // 'dirent' struct to return from dir (NOTE: this + // is not thread safe). + struct dirent dd_dir; + + // '_findnext()' handle + long dd_handle; + + // Current status of search: + // 0 = not started yet (next entry to read is first entry) + // -1 = off the end + // Otherwise - positive (0 based) index of next entry + int dd_stat; + + // Full path for dir with search pattern (struct will be extended) + char dd_name[1]; +} DIR; + +struct pollfd +{ + int fd; + short events; + short revents; +}; + +typedef unsigned int nfds_t; + +PBD_API int PBD_APICALLTYPE gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz); +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); + +namespace PBD { + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +PBD_API bool PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored"); +PBD_API char* PBD_APICALLTYPE realpath (const char *original_path, char resolved_path[_MAX_PATH+1]); +PBD_API int PBD_APICALLTYPE mkstemp (char *template_name); +PBD_API int PBD_APICALLTYPE ntfs_link (const char *existing_filepath, const char *link_filepath); +PBD_API int PBD_APICALLTYPE ntfs_unlink (const char *link_filepath); + +// These are used to replicate 'dirent.h' functionality +PBD_API DIR* PBD_APICALLTYPE opendir (const char *szPath); +PBD_API struct dirent* PBD_APICALLTYPE readdir (DIR *pDir); +PBD_API int PBD_APICALLTYPE closedir (DIR *pDir); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +} // namespace PBD + +#endif // !__CYGWIN__ +#endif // PLATFORM_WINDOWS +#endif // _msvc_pbd_h_ -- cgit v1.2.3 From eeabf89d19214bb075709009a76b3354c4332ccf Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 17 Jul 2013 14:55:20 +0100 Subject: Miscellaneous header files (needed for building libpbd with MSVC) --- msvc_extra_headers/ardourext/float_cast.h.input | 73 ++ msvc_extra_headers/ardourext/libcharset.h.input | 46 + msvc_extra_headers/ardourext/localcharset.h.input | 42 + msvc_extra_headers/ardourext/misc.h.input | 223 ++++ msvc_extra_headers/ardourext/pthread.h.input | 7 + msvc_extra_headers/ardourext/ptw32/pthread.h.input | 1373 ++++++++++++++++++++ msvc_extra_headers/ardourext/sched.h.input | 183 +++ msvc_extra_headers/ardourext/semaphore.h.input | 171 +++ msvc_extra_headers/ardourext/sys/targetsxs.h.input | 66 + msvc_extra_headers/ardourext/sys/time.h.input | 110 ++ 10 files changed, 2294 insertions(+) create mode 100644 msvc_extra_headers/ardourext/float_cast.h.input create mode 100644 msvc_extra_headers/ardourext/libcharset.h.input create mode 100644 msvc_extra_headers/ardourext/localcharset.h.input create mode 100644 msvc_extra_headers/ardourext/misc.h.input create mode 100644 msvc_extra_headers/ardourext/pthread.h.input create mode 100644 msvc_extra_headers/ardourext/ptw32/pthread.h.input create mode 100644 msvc_extra_headers/ardourext/sched.h.input create mode 100644 msvc_extra_headers/ardourext/semaphore.h.input create mode 100644 msvc_extra_headers/ardourext/sys/targetsxs.h.input create mode 100644 msvc_extra_headers/ardourext/sys/time.h.input diff --git a/msvc_extra_headers/ardourext/float_cast.h.input b/msvc_extra_headers/ardourext/float_cast.h.input new file mode 100644 index 0000000000..a5a82e3668 --- /dev/null +++ b/msvc_extra_headers/ardourext/float_cast.h.input @@ -0,0 +1,73 @@ +/* +** Copyright (C) 2001 Erik de Castro Lopo +** +** Permission to use, copy, modify, distribute, and sell this file for any +** purpose is hereby granted without fee, provided that the above copyright +** and this permission notice appear in all copies. No representations are +** made about the suitability of this software for any purpose. It is +** provided "as is" without express or implied warranty. +*/ + +/* Version 1.1 */ + + +/*============================================================================ +** On Intel Pentium processors (especially PIII and probably P4), converting +** from float to int is very slow. To meet the C specs, the code produced by +** most C compilers targeting Pentium needs to change the FPU rounding mode +** before the float to int conversion is performed. +** +** Changing the FPU rounding mode causes the FPU pipeline to be flushed. It +** is this flushing of the pipeline which is so slow. +** +** Fortunately the ISO C99 specifications define the functions lrint, lrintf, +** llrint and llrintf which fix this problem as a side effect. +** +** On Unix-like systems, the configure process should have detected the +** presence of these functions. If they weren't found we have to replace them +** here with a standard C cast. +*/ + +/* +** The C99 prototypes for lrint and lrintf are as follows: +** +** long int lrintf (float x) ; +** long int lrint (double x) ; +*/ +#ifndef __FLOAT_CAST_H__ // Added by JE - 30-11-2009 +#define __FLOAT_CAST_H__ +#if (defined (WIN32) || defined (_WIN32)) + + #include + + /* Win32 doesn't seem to have these functions. + ** Therefore implement inline versions of these functions here. + */ + + __inline long int + lrint (double flt) + { int intgr; + + _asm + { fld flt + fistp intgr + } ; + + return intgr ; + } + + __inline long int + lrintf (float flt) + { int intgr; + + _asm + { fld flt + fistp intgr + } ; + + return intgr ; + } + +#endif + +#endif // __FLOAT_CAST_H__ diff --git a/msvc_extra_headers/ardourext/libcharset.h.input b/msvc_extra_headers/ardourext/libcharset.h.input new file mode 100644 index 0000000000..2baf24c8b3 --- /dev/null +++ b/msvc_extra_headers/ardourext/libcharset.h.input @@ -0,0 +1,46 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU CHARSET Library. + + The GNU CHARSET Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU CHARSET Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with the GNU CHARSET Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 51 Franklin Street, + Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _LIBCHARSET_H +#define _LIBCHARSET_H + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Support for relocatable packages. */ + +/* Sets the original and the current installation prefix of the package. + Relocation simply replaces a pathname starting with the original prefix + by the corresponding pathname with the current prefix instead. Both + prefixes should be directory names without trailing slash (i.e. use "" + instead of "/"). */ +extern void libcharset_set_relocation_prefix (const char *orig_prefix, + const char *curr_prefix); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LIBCHARSET_H */ diff --git a/msvc_extra_headers/ardourext/localcharset.h.input b/msvc_extra_headers/ardourext/localcharset.h.input new file mode 100644 index 0000000000..129e4a4a32 --- /dev/null +++ b/msvc_extra_headers/ardourext/localcharset.h.input @@ -0,0 +1,42 @@ +/* Determine a canonical name for the current locale's character encoding. + Copyright (C) 2000-2003 Free Software Foundation, Inc. + This file is part of the GNU CHARSET Library. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +#ifndef _LOCALCHARSET_H +#define _LOCALCHARSET_H + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Determine the current locale's character encoding, and canonicalize it + into one of the canonical names listed in config.charset. + The result must not be freed; it is statically allocated. + If the canonical name cannot be determined, the result is a non-canonical + name. */ +extern const char * locale_charset (void); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LOCALCHARSET_H */ diff --git a/msvc_extra_headers/ardourext/misc.h.input b/msvc_extra_headers/ardourext/misc.h.input new file mode 100644 index 0000000000..55eb529f24 --- /dev/null +++ b/msvc_extra_headers/ardourext/misc.h.input @@ -0,0 +1,223 @@ +/* + Copyright (C) 2009 John Emmas + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_msvc_extensions_h__ +#define __ardour_msvc_extensions_h__ + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#endif +#ifndef _CPP_VECTOR +#define _CPP_VECTOR 1 +#endif + +#include +#include +#include +#include +#include +#include +#include + +// 'std::isnan()' is not available in MSVC. Assume '_isnan(double)' +#define isnan(val) (bool)_isnan((double)val) + +// 'std::isinf()' is not available in MSVC. Assume '!_finite(double)' +#define isinf(val) !((bool)_finite((double)val)) + +// 'INFINITY' is not defined in MSVC. Assume 'HUGE_VAL' +#ifndef INFINITY +#define INFINITY HUGE_VAL +#endif + +// File access modes copied from unistd.h +#define F_OK 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 + +// Miscellaneous #defines +#define __attribute__(x) +#define llabs _abs64 +#define atoll _atoi64 +#define access _access +#define getcwd _getcwd +#define getpid _getpid +#define snprintf _snprintf +#define link ntfs_link +#define unlink ntfs_unlink +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define strtok_r( _s, _sep, _lasts ) \ + ( *(_lasts) = strtok( (_s), (_sep) ) ) + +#ifndef PATH_MAX +#define PATH_MAX _MAX_PATH +#endif +#define DECLARE_DEFAULT_COMPARISONS(Type) \ + extern bool operator > (const Type& lhs, const Type& rhs); \ + extern bool operator < (const Type& lhs, const Type& rhs); \ + extern bool operator != (const Type& lhs, const Type& rhs); \ + extern bool operator == (const Type& lhs, const Type& rhs); + +// Types missing from Win32 'stat.h' (hopefully Windows +// will either act sensibly or ignore most of them). +#define _S_IFBLK 0x3000 +#define S_IRWXU _S_IRWXU +#define S_IXUSR _S_IXUSR +#define S_IWUSR _S_IWUSR +#define S_IRUSR _S_IRUSR +#define S_IXGRP _S_IXGRP +#define S_IWGRP _S_IWGRP +#define S_IRGRP _S_IRGRP +#define S_IXOTH _S_IXOTH +#define S_IWOTH _S_IWOTH +#define S_IROTH _S_IROTH + +#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC) +#define _S_IXUSR _S_IEXEC +#define _S_IWUSR _S_IWRITE +#define _S_IRUSR _S_IREAD +#define _S_IXGRP _S_IEXEC +#define _S_IWGRP _S_IWRITE +#define _S_IRGRP _S_IREAD +#define _S_IXOTH _S_IEXEC +#define _S_IWOTH _S_IWRITE +#define _S_IROTH _S_IREAD + +#define S_ISFIFO(m) _S_ISFIFO(m) +#define S_ISDIR(m) _S_ISDIR(m) +#define S_ISCHR(m) _S_ISCHR(m) +#define S_ISBLK(m) _S_ISBLK(m) +#define S_ISREG(m) _S_ISREG(m) + +#define _S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) +#define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) +#define _S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) +#define _S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) +#define _S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) + + +#if defined(__USE_BSD) || defined(_BSD_SOURCE) +/* Convenience macros for operations on timevals. + NOTE: `timercmp' does not work for >= or <=. + Note also that 'timerset', 'timerclear' and + 'timercmp' are (perhaps strangely) already + defined, along with various other 'time' + functions in WinSock.h */ +# define timeradd(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ + if ((result)->tv_usec >= 1000000) \ + { \ + ++(result)->tv_sec; \ + (result)->tv_usec -= 1000000; \ + } \ + } while (0) +# define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +#endif /* BSD */ + +#if !defined(__BIT_TYPES_DEFINED) || !defined(__BIT_TYPES_DEFINED__) +#define __BIT_TYPES_DEFINED__ 1 +// Doesn't yet define all 'bit types'. Only those +// needed by Ardour. More can be added as needed. +#ifndef __int8_t_defined +#define __int8_t_defined +typedef unsigned char u_int8_t; +typedef unsigned short int u_int16_t; +typedef unsigned int u_int32_t; +typedef unsigned __int64 u_int64_t; + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned uint32_t; +typedef long long int64_t; +typedef unsigned long long uint64_t; +#endif // __int8_t + +#ifndef __register_t_defined +#define __register_t_defined +typedef int register_t; +#endif // __register_t +#endif // __BIT_TYPESD + +// throw() +#ifndef __THROW +#define __THROW throw() +#endif + +// round().... Unlike Linux, Windows doesn't seem to support the +// concept of a system-wide (or programmable) rounding direction. +// 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) + +// System V compatibility +typedef unsigned short ushort; +typedef unsigned int uint; + +// mode_t +#ifndef _MODE_T_ +#define _MODE_T_ +typedef unsigned short _mode_t; + +#ifndef NO_OLDNAMES +typedef _mode_t mode_t; +#endif /* NO_OLDNAMES */ +#endif /* _MODE_T_ */ + +// fmin() and fmax() +#define fmin(a, b) min((double)a, (double)b) +#define fmax(a, b) max((double)a, (double)b) + +// approximate POSIX pipe() +#define pipe(handles) _pipe(handles, 4096, _O_BINARY) + +// Windows mkdir() doesn't care about access privileges +#define mkdir(path, mode) _mkdir(path) + +// Redefine 'ftruncate()' to use the glib-win32 version +#define ftruncate(fd, len) g_win32_ftruncate((gint)fd, (guint)len) + + +// #include the main headers for Ardour MSVC +#if defined(BUILDING_PBD) || defined(PBD_IS_IN_WIN_STATIC_LIB) +#include +#endif +#if defined(BUILDING_LIBARDOUR) || defined(LIBARDOUR_IS_IN_WIN_STATIC_LIB) +#include +#endif +#if defined(BUILDING_RUBBERBAND) || defined(RUBBERBAND_IS_IN_WIN_STATIC_LIB) +#include +#endif + +#endif /* __ardour_msvc_extensions_h__ */ diff --git a/msvc_extra_headers/ardourext/pthread.h.input b/msvc_extra_headers/ardourext/pthread.h.input new file mode 100644 index 0000000000..9699ef91eb --- /dev/null +++ b/msvc_extra_headers/ardourext/pthread.h.input @@ -0,0 +1,7 @@ +#if !defined( PTHREAD_H ) +#ifdef _PTHREAD_H // Test added by JE - 12-12-2009 +#error "ardourext/pthread.h conflicts with an existing pthread library" +#else +#include +#endif /* _PTHREAD_H */ +#endif /* PTHREAD_H */ diff --git a/msvc_extra_headers/ardourext/ptw32/pthread.h.input b/msvc_extra_headers/ardourext/ptw32/pthread.h.input new file mode 100644 index 0000000000..0aa4522556 --- /dev/null +++ b/msvc_extra_headers/ardourext/ptw32/pthread.h.input @@ -0,0 +1,1373 @@ +/* This is an implementation of the threads API of POSIX 1003.1-2001. + * + * -------------------------------------------------------------------------- + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright(C) 1998 John E. Bossom + * Copyright(C) 1999,2005 Pthreads-win32 contributors + * + * Contact Email: rpj@callisto.canberra.edu.au + * + * The current list of contributors is contained + * in the file CONTRIBUTORS included with the source + * code distribution. The list can also be seen at the + * following World Wide Web location: + * http://sources.redhat.com/pthreads-win32/contributors.html + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library in the file COPYING.LIB; + * if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#if !defined( PTHREAD_H ) +#ifdef _PTHREAD_H // Test added by JE - 12-12-2009 +#error "ptw32/pthread.h conflicts with an existing pthread library" +#endif +// Now make sure we can't accidentally include a conflicting library !! +#define _PTHREAD_H +#define PTHREAD_H + +/* + * See the README file for an explanation of the pthreads-win32 version + * numbering scheme and how the DLL is named etc. + */ +#define PTW32_VERSION 2,8,0,0 +#define PTW32_VERSION_STRING "2, 8, 0, 0\0" + +/* There are three implementations of cancel cleanup. + * Note that pthread.h is included in both application + * compilation units and also internally for the library. + * The code here and within the library aims to work + * for all reasonable combinations of environments. + * + * The three implementations are: + * + * WIN32 SEH + * C + * C++ + * + * Please note that exiting a push/pop block via + * "return", "exit", "break", or "continue" will + * lead to different behaviour amongst applications + * depending upon whether the library was built + * using SEH, C++, or C. For example, a library built + * with SEH will call the cleanup routine, while both + * C++ and C built versions will not. + */ + +/* + * Define defaults for cleanup code. + * Note: Unless the build explicitly defines one of the following, then + * we default to standard C style cleanup. This style uses setjmp/longjmp + * in the cancelation and thread exit implementations and therefore won't + * do stack unwinding if linked to applications that have it (e.g. + * C++ apps). This is currently consistent with most/all commercial Unix + * POSIX threads implementations. + */ +#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C ) +# define __CLEANUP_C +#endif + +#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC)) +#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler. +#endif + +/* + * Stop here if we are being included by the resource compiler. + */ +#ifndef RC_INVOKED + +#undef PTW32_LEVEL + +#if defined(_POSIX_SOURCE) +#define PTW32_LEVEL 0 +/* Early POSIX */ +#endif + +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 +#undef PTW32_LEVEL +#define PTW32_LEVEL 1 +/* Include 1b, 1c and 1d */ +#endif + +#if defined(INCLUDE_NP) +#undef PTW32_LEVEL +#define PTW32_LEVEL 2 +/* Include Non-Portable extensions */ +#endif + +#define PTW32_LEVEL_MAX 3 + +#if !defined(PTW32_LEVEL) +#define PTW32_LEVEL PTW32_LEVEL_MAX +/* Include everything */ +#endif + +#ifdef _UWIN +# define HAVE_STRUCT_TIMESPEC 1 +# define HAVE_SIGNAL_H 1 +# undef HAVE_CONFIG_H +# pragma comment(lib, "pthread") +#endif + +/* + * ------------------------------------------------------------- + * + * + * Module: pthread.h + * + * Purpose: + * Provides an implementation of PThreads based upon the + * standard: + * + * POSIX 1003.1-2001 + * and + * The Single Unix Specification version 3 + * + * (these two are equivalent) + * + * in order to enhance code portability between Windows, + * various commercial Unix implementations, and Linux. + * + * See the ANNOUNCE file for a full list of conforming + * routines and defined constants, and a list of missing + * routines and constants not defined in this implementation. + * + * Authors: + * There have been many contributors to this library. + * The initial implementation was contributed by + * John Bossom, and several others have provided major + * sections or revisions of parts of the implementation. + * Often significant effort has been contributed to + * find and fix important bugs and other problems to + * improve the reliability of the library, which sometimes + * is not reflected in the amount of code which changed as + * result. + * As much as possible, the contributors are acknowledged + * in the ChangeLog file in the source code distribution + * where their changes are noted in detail. + * + * Contributors are listed in the CONTRIBUTORS file. + * + * As usual, all bouquets go to the contributors, and all + * brickbats go to the project maintainer. + * + * Maintainer: + * The code base for this project is coordinated and + * eventually pre-tested, packaged, and made available by + * + * Ross Johnson + * + * QA Testers: + * Ultimately, the library is tested in the real world by + * a host of competent and demanding scientists and + * engineers who report bugs and/or provide solutions + * which are then fixed or incorporated into subsequent + * versions of the library. Each time a bug is fixed, a + * test case is written to prove the fix and ensure + * that later changes to the code don't reintroduce the + * same error. The number of test cases is slowly growing + * and therefore so is the code reliability. + * + * Compliance: + * See the file ANNOUNCE for the list of implemented + * and not-implemented routines and defined options. + * Of course, these are all defined is this file as well. + * + * Web site: + * The source code and other information about this library + * are available from + * + * http://sources.redhat.com/pthreads-win32/ + * + * ------------------------------------------------------------- + */ + +/* Try to avoid including windows.h */ +#if defined(__MINGW32__) && defined(__cplusplus) +#define PTW32_INCLUDE_WINDOWS_H +#endif + +#ifdef PTW32_INCLUDE_WINDOWS_H +#include +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__) +/* + * VC++6.0 or early compiler's header has no DWORD_PTR type. + */ +typedef unsigned long DWORD_PTR; +#endif +/* + * ----------------- + * autoconf switches + * ----------------- + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#ifndef NEED_FTIME +#include +#else /* NEED_FTIME */ +/* use native WIN32 time API */ +#endif /* NEED_FTIME */ + +#if HAVE_SIGNAL_H +#include +#endif /* HAVE_SIGNAL_H */ + +#include +#include + +/* + * Boolean values to make us independent of system includes. + */ +enum { + PTW32_FALSE = 0, + PTW32_TRUE = (! PTW32_FALSE) +}; + +/* + * This is a duplicate of what is in the autoconf config.h, + * which is only used when building the pthread-win32 libraries. + */ + +#ifndef PTW32_CONFIG_H +# if defined(WINCE) +# define NEED_ERRNO +# define NEED_SEM +# endif +# if defined(_UWIN) || defined(__MINGW32__) +# define HAVE_MODE_T +# endif +#endif + +/* + * + */ + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX +#ifdef NEED_ERRNO +#include "need_errno.h" +#else +#include +#endif +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +/* + * Several systems don't define some error numbers. + */ +#ifndef ENOTSUP +# define ENOTSUP 48 /* This is the value in Solaris. */ +#endif + +#ifndef ETIMEDOUT +# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ +#endif + +#ifndef ENOSYS +# define ENOSYS 140 /* Semi-arbitrary value */ +#endif + +#ifndef EDEADLK +# ifdef EDEADLOCK +# define EDEADLK EDEADLOCK +# else +# define EDEADLK 36 /* This is the value in MSVC. */ +# endif +#endif + +#include + +/* + * To avoid including windows.h we define only those things that we + * actually need from it. + */ +#ifndef PTW32_INCLUDE_WINDOWS_H +#ifndef HANDLE +# define PTW32__HANDLE_DEF +# define HANDLE void * +#endif +#ifndef DWORD +# define PTW32__DWORD_DEF +# define DWORD unsigned long +#endif +#endif + +#ifndef HAVE_STRUCT_TIMESPEC +#define HAVE_STRUCT_TIMESPEC 1 +struct timespec { + long tv_sec; + long tv_nsec; +}; +#endif /* HAVE_STRUCT_TIMESPEC */ + +#ifndef SIG_BLOCK +#define SIG_BLOCK 0 +#endif /* SIG_BLOCK */ + +#ifndef SIG_UNBLOCK +#define SIG_UNBLOCK 1 +#endif /* SIG_UNBLOCK */ + +#ifndef SIG_SETMASK +#define SIG_SETMASK 2 +#endif /* SIG_SETMASK */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* + * ------------------------------------------------------------- + * + * POSIX 1003.1-2001 Options + * ========================= + * + * Options are normally set in , which is not provided + * with pthreads-win32. + * + * For conformance with the Single Unix Specification (version 3), all of the + * options below are defined, and have a value of either -1 (not supported) + * or 200112L (supported). + * + * These options can neither be left undefined nor have a value of 0, because + * either indicates that sysconf(), which is not implemented, may be used at + * runtime to check the status of the option. + * + * _POSIX_THREADS (== 200112L) + * If == 200112L, you can use threads + * + * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L) + * If == 200112L, you can control the size of a thread's + * stack + * pthread_attr_getstacksize + * pthread_attr_setstacksize + * + * _POSIX_THREAD_ATTR_STACKADDR (== -1) + * If == 200112L, you can allocate and control a thread's + * stack. If not supported, the following functions + * will return ENOSYS, indicating they are not + * supported: + * pthread_attr_getstackaddr + * pthread_attr_setstackaddr + * + * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1) + * If == 200112L, you can use realtime scheduling. + * This option indicates that the behaviour of some + * implemented functions conforms to the additional TPS + * requirements in the standard. E.g. rwlocks favour + * writers over readers when threads have equal priority. + * + * _POSIX_THREAD_PRIO_INHERIT (== -1) + * If == 200112L, you can create priority inheritance + * mutexes. + * pthread_mutexattr_getprotocol + + * pthread_mutexattr_setprotocol + + * + * _POSIX_THREAD_PRIO_PROTECT (== -1) + * If == 200112L, you can create priority ceiling mutexes + * Indicates the availability of: + * pthread_mutex_getprioceiling + * pthread_mutex_setprioceiling + * pthread_mutexattr_getprioceiling + * pthread_mutexattr_getprotocol + + * pthread_mutexattr_setprioceiling + * pthread_mutexattr_setprotocol + + * + * _POSIX_THREAD_PROCESS_SHARED (== -1) + * If set, you can create mutexes and condition + * variables that can be shared with another + * process.If set, indicates the availability + * of: + * pthread_mutexattr_getpshared + * pthread_mutexattr_setpshared + * pthread_condattr_getpshared + * pthread_condattr_setpshared + * + * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L) + * If == 200112L you can use the special *_r library + * functions that provide thread-safe behaviour + * + * _POSIX_READER_WRITER_LOCKS (== 200112L) + * If == 200112L, you can use read/write locks + * + * _POSIX_SPIN_LOCKS (== 200112L) + * If == 200112L, you can use spin locks + * + * _POSIX_BARRIERS (== 200112L) + * If == 200112L, you can use barriers + * + * + These functions provide both 'inherit' and/or + * 'protect' protocol, based upon these macro + * settings. + * + * ------------------------------------------------------------- + */ + +/* + * POSIX Options + */ +#undef _POSIX_THREADS +#define _POSIX_THREADS 200112L + +#undef _POSIX_READER_WRITER_LOCKS +#define _POSIX_READER_WRITER_LOCKS 200112L + +#undef _POSIX_SPIN_LOCKS +#define _POSIX_SPIN_LOCKS 200112L + +#undef _POSIX_BARRIERS +#define _POSIX_BARRIERS 200112L + +#undef _POSIX_THREAD_SAFE_FUNCTIONS +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L + +#undef _POSIX_THREAD_ATTR_STACKSIZE +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L + +/* + * The following options are not supported + */ +#undef _POSIX_THREAD_ATTR_STACKADDR +#define _POSIX_THREAD_ATTR_STACKADDR -1 + +#undef _POSIX_THREAD_PRIO_INHERIT +#define _POSIX_THREAD_PRIO_INHERIT -1 + +#undef _POSIX_THREAD_PRIO_PROTECT +#define _POSIX_THREAD_PRIO_PROTECT -1 + +/* TPS is not fully supported. */ +#undef _POSIX_THREAD_PRIORITY_SCHEDULING +#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 + +#undef _POSIX_THREAD_PROCESS_SHARED +#define _POSIX_THREAD_PROCESS_SHARED -1 + + +/* + * POSIX 1003.1-2001 Limits + * =========================== + * + * These limits are normally set in , which is not provided with + * pthreads-win32. + * + * PTHREAD_DESTRUCTOR_ITERATIONS + * Maximum number of attempts to destroy + * a thread's thread-specific data on + * termination (must be at least 4) + * + * PTHREAD_KEYS_MAX + * Maximum number of thread-specific data keys + * available per process (must be at least 128) + * + * PTHREAD_STACK_MIN + * Minimum supported stack size for a thread + * + * PTHREAD_THREADS_MAX + * Maximum number of threads supported per + * process (must be at least 64). + * + * SEM_NSEMS_MAX + * The maximum number of semaphores a process can have. + * (must be at least 256) + * + * SEM_VALUE_MAX + * The maximum value a semaphore can have. + * (must be at least 32767) + * + */ +#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 + +#undef PTHREAD_DESTRUCTOR_ITERATIONS +#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS + +#undef _POSIX_THREAD_KEYS_MAX +#define _POSIX_THREAD_KEYS_MAX 128 + +#undef PTHREAD_KEYS_MAX +#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX + +#undef PTHREAD_STACK_MIN +#define PTHREAD_STACK_MIN 0 + +#undef _POSIX_THREAD_THREADS_MAX +#define _POSIX_THREAD_THREADS_MAX 64 + + /* Arbitrary value */ +#undef PTHREAD_THREADS_MAX +#define PTHREAD_THREADS_MAX 2019 + +#undef _POSIX_SEM_NSEMS_MAX +#define _POSIX_SEM_NSEMS_MAX 256 + + /* Arbitrary value */ +#undef SEM_NSEMS_MAX +#define SEM_NSEMS_MAX 1024 + +#undef _POSIX_SEM_VALUE_MAX +#define _POSIX_SEM_VALUE_MAX 32767 + +#undef SEM_VALUE_MAX +#define SEM_VALUE_MAX INT_MAX + + +#if __GNUC__ && ! defined (__declspec) +# error Please upgrade your GNU compiler to one that supports __declspec. +#endif + +/* + * When building the DLL code, you should define PTW32_BUILD so that + * the variables/functions are exported correctly. When using the DLL, + * do NOT define PTW32_BUILD, and then the variables/functions will + * be imported correctly. + */ +#ifndef PTW32_STATIC_LIB +# ifdef PTW32_BUILD +# define PTW32_DLLPORT __declspec (dllexport) +# else +# define PTW32_DLLPORT __declspec (dllimport) +# endif +#else +# define PTW32_DLLPORT +#endif + +/* + * The Open Watcom C/C++ compiler uses a non-standard calling convention + * that passes function args in registers unless __cdecl is explicitly specified + * in exposed function prototypes. + * + * We force all calls to cdecl even though this could slow Watcom code down + * slightly. If you know that the Watcom compiler will be used to build both + * the DLL and application, then you can probably define this as a null string. + * Remember that pthread.h (this file) is used for both the DLL and application builds. + */ +#define PTW32_CDECL __cdecl + +#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX +# include +#else +/* + * Generic handle type - intended to extend uniqueness beyond + * that available with a simple pointer. It should scale for either + * IA-32 or IA-64. + */ +typedef struct { + void * p; /* Pointer to actual object */ + unsigned int x; /* Extra information - reuse count etc */ +} ptw32_handle_t; + +typedef ptw32_handle_t pthread_t; +typedef struct pthread_attr_t_ * pthread_attr_t; +typedef struct pthread_once_t_ pthread_once_t; +typedef struct pthread_key_t_ * pthread_key_t; +typedef struct pthread_mutex_t_ * pthread_mutex_t; +typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t; +typedef struct pthread_cond_t_ * pthread_cond_t; +typedef struct pthread_condattr_t_ * pthread_condattr_t; +#endif +typedef struct pthread_rwlock_t_ * pthread_rwlock_t; +typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t; +typedef struct pthread_spinlock_t_ * pthread_spinlock_t; +typedef struct pthread_barrier_t_ * pthread_barrier_t; +typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; + +/* + * ==================== + * ==================== + * POSIX Threads + * ==================== + * ==================== + */ + +enum { +/* + * pthread_attr_{get,set}detachstate + */ + PTHREAD_CREATE_JOINABLE = 0, /* Default */ + PTHREAD_CREATE_DETACHED = 1, + +/* + * pthread_attr_{get,set}inheritsched + */ + PTHREAD_INHERIT_SCHED = 0, + PTHREAD_EXPLICIT_SCHED = 1, /* Default */ + +/* + * pthread_{get,set}scope + */ + PTHREAD_SCOPE_PROCESS = 0, + PTHREAD_SCOPE_SYSTEM = 1, /* Default */ + +/* + * pthread_setcancelstate paramters + */ + PTHREAD_CANCEL_ENABLE = 0, /* Default */ + PTHREAD_CANCEL_DISABLE = 1, + +/* + * pthread_setcanceltype parameters + */ + PTHREAD_CANCEL_ASYNCHRONOUS = 0, + PTHREAD_CANCEL_DEFERRED = 1, /* Default */ + +/* + * pthread_mutexattr_{get,set}pshared + * pthread_condattr_{get,set}pshared + */ + PTHREAD_PROCESS_PRIVATE = 0, + PTHREAD_PROCESS_SHARED = 1, + +/* + * pthread_barrier_wait + */ + PTHREAD_BARRIER_SERIAL_THREAD = -1 +}; + +/* + * ==================== + * ==================== + * Cancelation + * ==================== + * ==================== + */ +#define PTHREAD_CANCELED ((void *) -1) + + +/* + * ==================== + * ==================== + * Once Key + * ==================== + * ==================== + */ +#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0} + +struct pthread_once_t_ +{ + int done; /* indicates if user function has been executed */ + void * lock; + int reserved1; + int reserved2; +}; + + +/* + * ==================== + * ==================== + * Object initialisers + * ==================== + * ==================== + */ +#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1) +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2) +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3) + +/* + * Compatibility with LinuxThreads + */ +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER + +#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1) + +#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1) + +#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t) -1) + + +/* + * Mutex types. + */ +enum +{ + /* Compatibility with LinuxThreads */ + PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, + /* For compatibility with POSIX */ + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +}; + + +typedef struct ptw32_cleanup_t ptw32_cleanup_t; + +#if defined(_MSC_VER) +/* Disable MSVC 'anachronism used' warning */ +#pragma warning( disable : 4229 ) +#endif + +typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *); + +#if defined(_MSC_VER) +#pragma warning( default : 4229 ) +#endif + +struct ptw32_cleanup_t +{ + ptw32_cleanup_callback_t routine; + void *arg; + struct ptw32_cleanup_t *prev; +}; + +#ifdef __CLEANUP_SEH + /* + * WIN32 SEH version of cancel cleanup. + */ + +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + ptw32_cleanup_t _cleanup; \ + \ + _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \ + _cleanup.arg = (_arg); \ + __try \ + { \ + +#define pthread_cleanup_pop( _execute ) \ + } \ + __finally \ + { \ + if( _execute || AbnormalTermination()) \ + { \ + (*(_cleanup.routine))( _cleanup.arg ); \ + } \ + } \ + } + +#else /* __CLEANUP_SEH */ + +#ifdef __CLEANUP_C + + /* + * C implementation of PThreads cancel cleanup + */ + +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + ptw32_cleanup_t _cleanup; \ + \ + ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \ + +#define pthread_cleanup_pop( _execute ) \ + (void) ptw32_pop_cleanup( _execute ); \ + } + +#else /* __CLEANUP_C */ + +#ifdef __CLEANUP_CXX + + /* + * C++ version of cancel cleanup. + * - John E. Bossom. + */ + + class PThreadCleanup { + /* + * PThreadCleanup + * + * Purpose + * This class is a C++ helper class that is + * used to implement pthread_cleanup_push/ + * pthread_cleanup_pop. + * The destructor of this class automatically + * pops the pushed cleanup routine regardless + * of how the code exits the scope + * (i.e. such as by an exception) + */ + ptw32_cleanup_callback_t cleanUpRout; + void * obj; + int executeIt; + + public: + PThreadCleanup() : + cleanUpRout( 0 ), + obj( 0 ), + executeIt( 0 ) + /* + * No cleanup performed + */ + { + } + + PThreadCleanup( + ptw32_cleanup_callback_t routine, + void * arg ) : + cleanUpRout( routine ), + obj( arg ), + executeIt( 1 ) + /* + * Registers a cleanup routine for 'arg' + */ + { + } + + ~PThreadCleanup() + { + if ( executeIt && ((void *) cleanUpRout != (void *) 0) ) + { + (void) (*cleanUpRout)( obj ); + } + } + + void execute( int exec ) + { + executeIt = exec; + } + }; + + /* + * C++ implementation of PThreads cancel cleanup; + * This implementation takes advantage of a helper + * class who's destructor automatically calls the + * cleanup routine if we exit our scope weirdly + */ +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ + (void *) (_arg) ); + +#define pthread_cleanup_pop( _execute ) \ + cleanup.execute( _execute ); \ + } + +#else + +#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. + +#endif /* __CLEANUP_CXX */ + +#endif /* __CLEANUP_C */ + +#endif /* __CLEANUP_SEH */ + +/* + * =============== + * =============== + * Methods + * =============== + * =============== + */ + +/* + * PThread Attribute Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, + int *detachstate); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, + void **stackaddr); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, + size_t * stacksize); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, + int detachstate); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, + void *stackaddr); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, + size_t stacksize); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, + struct sched_param *param); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, + const struct sched_param *param); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, + int); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (pthread_attr_t *, + int *); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, + int inheritsched); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(pthread_attr_t * attr, + int * inheritsched); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, + int); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, + int *); + +/* + * PThread Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, + const pthread_attr_t * attr, + void *(*start) (void *), + void *arg); + +PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); + +PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1, + pthread_t t2); + +PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr); + +PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread, + void **value_ptr); + +PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void); + +PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread); + +PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state, + int *oldstate); + +PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, + int *oldtype); + +PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); + +PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, + void (*init_routine) (void)); + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX +PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); + +PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, + void (*routine) (void *), + void *arg); +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +/* + * Thread Specific Data Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, + void (*destructor) (void *)); + +PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); + +PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key, + const void *value); + +PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key); + + +/* + * Mutex Attribute Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t + * attr, + int *pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, + int pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind); + +/* + * Barrier Attribute Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t + * attr, + int *pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, + int pshared); + +/* + * Mutex Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, + const pthread_mutexattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t *mutex, + const struct timespec *abstime); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); + +/* + * Spinlock Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); + +/* + * Barrier Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, + const pthread_barrierattr_t * attr, + unsigned int count); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); + +/* + * Condition Variable Attribute Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, + int *pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, + int pshared); + +/* + * Condition Variable Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, + const pthread_condattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, + pthread_mutex_t * mutex); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, + pthread_mutex_t * mutex, + const struct timespec *abstime); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); + +/* + * Scheduling + */ +PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread, + int policy, + const struct sched_param *param); + +PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread, + int *policy, + struct sched_param *param); + +PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int); + +PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void); + +/* + * Read-Write Lock Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, + const pthread_rwlockattr_t *attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, + const struct timespec *abstime); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, + const struct timespec *abstime); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, + int *pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, + int pshared); + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 + +/* + * Signal Functions. Should be defined in but MSVC and MinGW32 + * already have signal.h that don't define these. + */ +PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); + +/* + * Non-portable functions + */ + +/* + * Compatibility with Linux. + */ +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, + int kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, + int *kind); + +/* + * Possibly supported by other POSIX threads implementations + */ +PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); +PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); + +/* + * Useful if an application wants to statically link + * the lib rather than load the DLL at run-time. + */ +PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void); +PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void); +PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void); +PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void); + +/* + * Features that are auto-detected at load/run time. + */ +PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int); +enum ptw32_features { + PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */ + PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */ +}; + +/* + * Register a system time change with the library. + * Causes the library to perform various functions + * in response to the change. Should be called whenever + * the application's top level window receives a + * WM_TIMECHANGE message. It can be passed directly to + * pthread_create() as a new thread if desired. + */ +PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); + +#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */ + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX + +/* + * Returns the Win32 HANDLE for the POSIX thread. + */ +PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); + + +/* + * Protected Methods + * + * This function blocks until the given WIN32 handle + * is signaled or pthread_cancel had been called. + * This function allows the caller to hook into the + * PThreads cancel mechanism. It is implemented using + * + * WaitForMultipleObjects + * + * on 'waitHandle' and a manually reset WIN32 Event + * used to implement pthread_cancel. The 'timeout' + * argument to TimedWait is simply passed to + * WaitForMultipleObjects. + */ +PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle); +PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, + DWORD timeout); + +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +/* + * Thread-Safe C Runtime Library Mappings. + */ +#ifndef _UWIN +# if defined(NEED_ERRNO) + PTW32_DLLPORT int * PTW32_CDECL _errno( void ); +# else +# ifndef errno +# if (defined(_MT) || defined(_DLL)) + __declspec(dllimport) extern int * __cdecl _errno(void); +# define errno (*_errno()) +# endif +# endif +# endif +#endif + +/* + * WIN32 C runtime library had been made thread-safe + * without affecting the user interface. Provide + * mappings from the UNIX thread-safe versions to + * the standard C runtime library calls. + * Only provide function mappings for functions that + * actually exist on WIN32. + */ + +#if !defined(__MINGW32__) +#define strtok_r( _s, _sep, _lasts ) \ + ( *(_lasts) = strtok( (_s), (_sep) ) ) +#endif /* !__MINGW32__ */ + +#define asctime_r( _tm, _buf ) \ + ( strcpy( (_buf), asctime( (_tm) ) ), \ + (_buf) ) + +#define ctime_r( _clock, _buf ) \ + ( strcpy( (_buf), ctime( (_clock) ) ), \ + (_buf) ) + +#define gmtime_r( _clock, _result ) \ + ( *(_result) = *gmtime( (_clock) ), \ + (_result) ) + +#define localtime_r( _clock, _result ) \ + ( *(_result) = *localtime( (_clock) ), \ + (_result) ) + +#define rand_r( _seed ) \ + ( _seed == _seed? rand() : rand() ) + + +/* + * Some compiler environments don't define some things. + */ +#if defined(__BORLANDC__) +# define _ftime ftime +# define _timeb timeb +#endif + +#ifdef __cplusplus + +/* + * Internal exceptions + */ +class ptw32_exception {}; +class ptw32_exception_cancel : public ptw32_exception {}; +class ptw32_exception_exit : public ptw32_exception {}; + +#endif + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX + +/* FIXME: This is only required if the library was built using SEH */ +/* + * Get internal SEH tag + */ +PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); + +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +#ifndef PTW32_BUILD + +#ifdef __CLEANUP_SEH + +/* + * Redefine the SEH __except keyword to ensure that applications + * propagate our internal exceptions up to the library's internal handlers. + */ +#define __except( E ) \ + __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ + ? EXCEPTION_CONTINUE_SEARCH : ( E ) ) + +#endif /* __CLEANUP_SEH */ + +#ifdef __CLEANUP_CXX + +/* + * Redefine the C++ catch keyword to ensure that applications + * propagate our internal exceptions up to the library's internal handlers. + */ +#ifdef _MSC_VER + /* + * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' + * if you want Pthread-Win32 cancelation and pthread_exit to work. + */ + +#ifndef PtW32NoCatchWarn + +#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.") +#pragma message("------------------------------------------------------------------") +#pragma message("When compiling applications with MSVC++ and C++ exception handling:") +#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads") +#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread") +#pragma message(" cancelation and pthread_exit to work. For example:") +#pragma message("") +#pragma message(" #ifdef PtW32CatchAll") +#pragma message(" PtW32CatchAll") +#pragma message(" #else") +#pragma message(" catch(...)") +#pragma message(" #endif") +#pragma message(" {") +#pragma message(" /* Catchall block processing */") +#pragma message(" }") +#pragma message("------------------------------------------------------------------") + +#endif + +#define PtW32CatchAll \ + catch( ptw32_exception & ) { throw; } \ + catch( ... ) + +#else /* _MSC_VER */ + +#define catch( E ) \ + catch( ptw32_exception & ) { throw; } \ + catch( E ) + +#endif /* _MSC_VER */ + +#endif /* __CLEANUP_CXX */ + +#endif /* ! PTW32_BUILD */ + +#ifdef __cplusplus +} /* End of extern "C" */ +#endif /* __cplusplus */ + +#ifdef PTW32__HANDLE_DEF +# undef HANDLE +#endif +#ifdef PTW32__DWORD_DEF +# undef DWORD +#endif + +#undef PTW32_LEVEL +#undef PTW32_LEVEL_MAX + +#endif /* ! RC_INVOKED */ + +#endif /* PTHREAD_H */ diff --git a/msvc_extra_headers/ardourext/sched.h.input b/msvc_extra_headers/ardourext/sched.h.input new file mode 100644 index 0000000000..e7f4ab0a52 --- /dev/null +++ b/msvc_extra_headers/ardourext/sched.h.input @@ -0,0 +1,183 @@ +/* + * Module: sched.h + * + * Purpose: + * Provides an implementation of POSIX realtime extensions + * as defined in + * + * POSIX 1003.1b-1993 (POSIX.1b) + * + * -------------------------------------------------------------------------- + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright(C) 1998 John E. Bossom + * Copyright(C) 1999,2005 Pthreads-win32 contributors + * + * Contact Email: rpj@callisto.canberra.edu.au + * + * The current list of contributors is contained + * in the file CONTRIBUTORS included with the source + * code distribution. The list can also be seen at the + * following World Wide Web location: + * http://sources.redhat.com/pthreads-win32/contributors.html + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library in the file COPYING.LIB; + * if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#ifndef SCHED_H +#ifdef _SCHED_H // Test added by JE - 12-12-2009 +#error "ardourext/sched.h conflicts with an existing pthread library" +#endif +// Now make sure we can't accidentally include a conflicting library !! +#define _SCHED_H +#define SCHED_H + +#undef PTW32_LEVEL + +#if defined(_POSIX_SOURCE) +#define PTW32_LEVEL 0 +/* Early POSIX */ +#endif + +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 +#undef PTW32_LEVEL +#define PTW32_LEVEL 1 +/* Include 1b, 1c and 1d */ +#endif + +#if defined(INCLUDE_NP) +#undef PTW32_LEVEL +#define PTW32_LEVEL 2 +/* Include Non-Portable extensions */ +#endif + +#define PTW32_LEVEL_MAX 3 + +#if !defined(PTW32_LEVEL) +#define PTW32_LEVEL PTW32_LEVEL_MAX +/* Include everything */ +#endif + + +#if __GNUC__ && ! defined (__declspec) +# error Please upgrade your GNU compiler to one that supports __declspec. +#endif + +/* + * When building the DLL code, you should define PTW32_BUILD so that + * the variables/functions are exported correctly. When using the DLL, + * do NOT define PTW32_BUILD, and then the variables/functions will + * be imported correctly. + */ +#ifndef PTW32_STATIC_LIB +# ifdef PTW32_BUILD +# define PTW32_DLLPORT __declspec (dllexport) +# else +# define PTW32_DLLPORT __declspec (dllimport) +# endif +#else +# define PTW32_DLLPORT +#endif + +/* + * This is a duplicate of what is in the autoconf config.h, + * which is only used when building the pthread-win32 libraries. + */ + +#ifndef PTW32_CONFIG_H +# if defined(WINCE) +# define NEED_ERRNO +# define NEED_SEM +# endif +# if defined(_UWIN) || defined(__MINGW32__) +# define HAVE_MODE_T +# endif +#endif + +/* + * + */ + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX +#ifdef NEED_ERRNO +#include "need_errno.h" +#else +#include +#endif +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +#if defined(__MINGW32__) || defined(_UWIN) +#if PTW32_LEVEL >= PTW32_LEVEL_MAX +/* For pid_t */ +# include +/* Required by Unix 98 */ +# include +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ +#else +typedef int pid_t; +#endif + +/* Thread scheduling policies */ + +enum { + SCHED_OTHER = 0, + SCHED_FIFO, + SCHED_RR, + SCHED_MIN = SCHED_OTHER, + SCHED_MAX = SCHED_RR +}; + +struct sched_param { + int sched_priority; +}; + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +PTW32_DLLPORT int __cdecl sched_yield (void); + +PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy); + +PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy); + +PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy); + +PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); + +/* + * Note that this macro returns ENOTSUP rather than + * ENOSYS as might be expected. However, returning ENOSYS + * should mean that sched_get_priority_{min,max} are + * not implemented as well as sched_rr_get_interval. + * This is not the case, since we just don't support + * round-robin scheduling. Therefore I have chosen to + * return the same value as sched_setscheduler when + * SCHED_RR is passed to it. + */ +#define sched_rr_get_interval(_pid, _interval) \ + ( errno = ENOTSUP, (int) -1 ) + + +#ifdef __cplusplus +} /* End of extern "C" */ +#endif /* __cplusplus */ + +#undef PTW32_LEVEL +#undef PTW32_LEVEL_MAX + +#endif /* !SCHED_H */ + diff --git a/msvc_extra_headers/ardourext/semaphore.h.input b/msvc_extra_headers/ardourext/semaphore.h.input new file mode 100644 index 0000000000..c06373fd77 --- /dev/null +++ b/msvc_extra_headers/ardourext/semaphore.h.input @@ -0,0 +1,171 @@ +/* + * Module: semaphore.h + * + * Purpose: + * Semaphores aren't actually part of the PThreads standard. + * They are defined by the POSIX Standard: + * + * POSIX 1003.1b-1993 (POSIX.1b) + * + * -------------------------------------------------------------------------- + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright(C) 1998 John E. Bossom + * Copyright(C) 1999,2005 Pthreads-win32 contributors + * + * Contact Email: rpj@callisto.canberra.edu.au + * + * The current list of contributors is contained + * in the file CONTRIBUTORS included with the source + * code distribution. The list can also be seen at the + * following World Wide Web location: + * http://sources.redhat.com/pthreads-win32/contributors.html + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library in the file COPYING.LIB; + * if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#if !defined( SEMAPHORE_H ) +#ifdef _SEMAPHORE_H // Test added by JE - 12-12-2009 +#error "ardourext/semaphore.h conflicts with an existing pthread library" +#endif +// Now make sure we can't accidentally include a conflicting library !! +#define _SEMAPHORE_H +#define SEMAPHORE_H + +#undef PTW32_LEVEL + +#if defined(_POSIX_SOURCE) +#define PTW32_LEVEL 0 +/* Early POSIX */ +#endif + +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 +#undef PTW32_LEVEL +#define PTW32_LEVEL 1 +/* Include 1b, 1c and 1d */ +#endif + +#if defined(INCLUDE_NP) +#undef PTW32_LEVEL +#define PTW32_LEVEL 2 +/* Include Non-Portable extensions */ +#endif + +#define PTW32_LEVEL_MAX 3 + +#if !defined(PTW32_LEVEL) +#define PTW32_LEVEL PTW32_LEVEL_MAX +/* Include everything */ +#endif + +#if __GNUC__ && ! defined (__declspec) +# error Please upgrade your GNU compiler to one that supports __declspec. +#endif + +/* + * When building the DLL code, you should define PTW32_BUILD so that + * the variables/functions are exported correctly. When using the DLL, + * do NOT define PTW32_BUILD, and then the variables/functions will + * be imported correctly. + */ +#ifndef PTW32_STATIC_LIB +# ifdef PTW32_BUILD +# define PTW32_DLLPORT __declspec (dllexport) +# else +# define PTW32_DLLPORT __declspec (dllimport) +# endif +#else +# define PTW32_DLLPORT +#endif + +/* + * This is a duplicate of what is in the autoconf config.h, + * which is only used when building the pthread-win32 libraries. + */ + +#ifndef PTW32_CONFIG_H +# if defined(WINCE) +# define NEED_ERRNO +# define NEED_SEM +# endif +# if defined(_UWIN) || defined(__MINGW32__) +# define HAVE_MODE_T +# endif +#endif + +/* + * + */ + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX +#ifdef NEED_ERRNO +#include "need_errno.h" +#else +#include +#endif +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +#define _POSIX_SEMAPHORES + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifndef HAVE_MODE_T +typedef unsigned int mode_t; +#endif + + +typedef struct sem_t_ * sem_t; + +PTW32_DLLPORT int __cdecl sem_init (sem_t * sem, + int pshared, + unsigned int value); + +PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem); + +PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem); + +PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem); + +PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem, + const struct timespec * abstime); + +PTW32_DLLPORT int __cdecl sem_post (sem_t * sem); + +PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem, + int count); + +PTW32_DLLPORT int __cdecl sem_open (const char * name, + int oflag, + mode_t mode, + unsigned int value); + +PTW32_DLLPORT int __cdecl sem_close (sem_t * sem); + +PTW32_DLLPORT int __cdecl sem_unlink (const char * name); + +PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, + int * sval); + +#ifdef __cplusplus +} /* End of extern "C" */ +#endif /* __cplusplus */ + +#undef PTW32_LEVEL +#undef PTW32_LEVEL_MAX + +#endif /* !SEMAPHORE_H */ diff --git a/msvc_extra_headers/ardourext/sys/targetsxs.h.input b/msvc_extra_headers/ardourext/sys/targetsxs.h.input new file mode 100644 index 0000000000..6653041d8a --- /dev/null +++ b/msvc_extra_headers/ardourext/sys/targetsxs.h.input @@ -0,0 +1,66 @@ +#ifndef _TARGETSXS_H_ +#define _TARGETSXS_H_ + +#pragma warning( disable : 4996 ) + +#ifndef HAVE_LV2 +#define HAVE_SUIL +#define HAVE_LV2 +/* Comment out the above lines to build Mixbus without LV2 support */ +#endif + +#ifndef VST_SUPPORT +#define VST_SUPPORT +/* Comment out the above line to build Mixbus without VST support */ +#endif + +#ifndef JACK_32_64 +#define JACK_32_64 +/* Shouldn't really be needed but make sure that any structs we + obtain from libjack will have 1-byte packing alignment where + necessary (belt & braces approach to be on the safe side) */ +#endif + +#ifdef _DEBUG +#define _SECURE_SCL 1 +#define _HAS_ITERATOR_DEBUGGING 1 +/* #define to zero for a more conventional Debug build */ +#endif + +#ifndef __midl +#if defined(_DEBUG) || defined (DEBUG) +/* Experimental - link to the lowest DebugCRT so we can run on another system */ +#define _SXS_ASSEMBLY_VERSION "8.0.50727.42" +#else +#define _SXS_ASSEMBLY_VERSION "8.0.50727.6195" +#endif +#define _CRT_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION +#define _MFC_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION +#define _ATL_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION + +#ifdef __cplusplus +extern "C" { +#endif +__declspec(selectany) int _forceCRTManifest; +__declspec(selectany) int _forceMFCManifest; +__declspec(selectany) int _forceAtlDllManifest; +__declspec(selectany) int _forceCRTManifestRTM; +__declspec(selectany) int _forceMFCManifestRTM; +__declspec(selectany) int _forceAtlDllManifestRTM; +#ifdef __cplusplus +} +#endif +#endif + +/* 'stdint.h' conflicts with various other libraries so + let's #include stdint.h first to ensure one consistent + implementation for commonly used integer types. */ +#include + +#if (BUILDING_ARDOUR) +#if defined(_MSC_VER) && !defined(__MINGW__) && !defined(__MINGW32__) +#include +#endif +#endif + +#endif /*_TARGETSXS_H_*/ diff --git a/msvc_extra_headers/ardourext/sys/time.h.input b/msvc_extra_headers/ardourext/sys/time.h.input new file mode 100644 index 0000000000..2e54976641 --- /dev/null +++ b/msvc_extra_headers/ardourext/sys/time.h.input @@ -0,0 +1,110 @@ +#ifndef _WINX_SYS_TIME_H_ +#define _WINX_SYS_TIME_H_ + +//#include +#include // gets 'struct timeval' + +#ifdef _TIMEVAL_DEFINED +# define _STRUCT_TIMEVAL 1 +#endif /* _TIMEVAL_DEFINED */ +//#include +#define __need_time_t +#include +#define __need_timeval +//#include + +#ifdef _TIMEVAL_DEFINED /* also in winsock[2].h */ +# undef __TIMEVAL__ +# define __TIMEVAL__ 1 +# undef _STRUCT_TIMEVAL +# define _STRUCT_TIMEVAL 1 +#endif /* _TIMEVAL_DEFINED */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __USE_GNU +/* Macros for converting between `struct timeval' and `struct timespec'. */ +# define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} +# define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +} +#endif + +#ifdef __USE_BSD +/* Structure crudely representing a timezone. + This is obsolete and should never be used. */ +struct timezone + { + int tz_minuteswest; /* Minutes west of GMT. */ + int tz_dsttime; /* Nonzero if DST is ever in effect. */ + }; + +typedef struct timezone *__restrict __timezone_ptr_t; +#else +typedef void *__restrict __timezone_ptr_t; +#endif + +/* Get the current time of day and timezone information, + putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. + Returns 0 on success, -1 on errors. + NOTE: This form of timezone information is obsolete. + Use the functions and variables declared in instead. */ +extern int gettimeofday (struct timeval *__restrict __tv, + __timezone_ptr_t __tz) __THROW; + +extern int getntptimeofday (struct timespec *__restrict __tp, + __timezone_ptr_t __tz) __THROW; + +#ifdef __USE_BSD +/* Set the current time of day and timezone information. + This call is restricted to the super-user. */ +extern int settimeofday (__const struct timeval *__tv, + __const struct timezone *__tz) __THROW; +extern int setntptimeofday (__const struct timespec *__tp, + __const struct timezone *__tz) __THROW; +#endif + +///* Values for the first argument to `getitimer' and `setitimer'. */ +//enum __itimer_which +// { +// /* Timers run in real time. */ +// ITIMER_REAL = 0, +//#define ITIMER_REAL ITIMER_REAL +// /* Timers run only when the process is executing. */ +// ITIMER_VIRTUAL = 1, +//#define ITIMER_VIRTUAL ITIMER_VIRTUAL +// /* Timers run when the process is executing and when +// the system is executing on behalf of the process. */ +// ITIMER_PROF = 2 +//#define ITIMER_PROF ITIMER_PROF +// }; + +/* Type of the second argument to `getitimer' and + the second and third arguments `setitimer'. */ +struct itimerval + { + /* Value to put into `it_value' when the timer expires. */ + struct timeval it_interval; + /* Time to the next timer expiration. */ + struct timeval it_value; + }; + +#if defined __USE_GNU && !defined __cplusplus +/* Use the nicer parameter type only in GNU mode and not for C++ since the + strict C++ rules prevent the automatic promotion. */ +typedef enum __itimer_which __itimer_which_t; +#else +typedef int __itimer_which_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_WINX_SYS_TIMEX_H_*/ -- cgit v1.2.3 From 82d351f6ca3214ef77df555aca853e18137b7ab4 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 17 Jul 2013 16:55:24 +0100 Subject: JOHNE - Testing to see if I have write access to the repo --- msvc_extra_headers/je-test.h | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 msvc_extra_headers/je-test.h diff --git a/msvc_extra_headers/je-test.h b/msvc_extra_headers/je-test.h new file mode 100644 index 0000000000..6653041d8a --- /dev/null +++ b/msvc_extra_headers/je-test.h @@ -0,0 +1,66 @@ +#ifndef _TARGETSXS_H_ +#define _TARGETSXS_H_ + +#pragma warning( disable : 4996 ) + +#ifndef HAVE_LV2 +#define HAVE_SUIL +#define HAVE_LV2 +/* Comment out the above lines to build Mixbus without LV2 support */ +#endif + +#ifndef VST_SUPPORT +#define VST_SUPPORT +/* Comment out the above line to build Mixbus without VST support */ +#endif + +#ifndef JACK_32_64 +#define JACK_32_64 +/* Shouldn't really be needed but make sure that any structs we + obtain from libjack will have 1-byte packing alignment where + necessary (belt & braces approach to be on the safe side) */ +#endif + +#ifdef _DEBUG +#define _SECURE_SCL 1 +#define _HAS_ITERATOR_DEBUGGING 1 +/* #define to zero for a more conventional Debug build */ +#endif + +#ifndef __midl +#if defined(_DEBUG) || defined (DEBUG) +/* Experimental - link to the lowest DebugCRT so we can run on another system */ +#define _SXS_ASSEMBLY_VERSION "8.0.50727.42" +#else +#define _SXS_ASSEMBLY_VERSION "8.0.50727.6195" +#endif +#define _CRT_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION +#define _MFC_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION +#define _ATL_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION + +#ifdef __cplusplus +extern "C" { +#endif +__declspec(selectany) int _forceCRTManifest; +__declspec(selectany) int _forceMFCManifest; +__declspec(selectany) int _forceAtlDllManifest; +__declspec(selectany) int _forceCRTManifestRTM; +__declspec(selectany) int _forceMFCManifestRTM; +__declspec(selectany) int _forceAtlDllManifestRTM; +#ifdef __cplusplus +} +#endif +#endif + +/* 'stdint.h' conflicts with various other libraries so + let's #include stdint.h first to ensure one consistent + implementation for commonly used integer types. */ +#include + +#if (BUILDING_ARDOUR) +#if defined(_MSC_VER) && !defined(__MINGW__) && !defined(__MINGW32__) +#include +#endif +#endif + +#endif /*_TARGETSXS_H_*/ -- cgit v1.2.3 From ab628ae3c3bab77227cba9087b80b25b9148a1a9 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 17 Jul 2013 18:18:02 +0100 Subject: JOHNE - remove my earlier test file --- msvc_extra_headers/je-test.h | 66 -------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 msvc_extra_headers/je-test.h diff --git a/msvc_extra_headers/je-test.h b/msvc_extra_headers/je-test.h deleted file mode 100644 index 6653041d8a..0000000000 --- a/msvc_extra_headers/je-test.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _TARGETSXS_H_ -#define _TARGETSXS_H_ - -#pragma warning( disable : 4996 ) - -#ifndef HAVE_LV2 -#define HAVE_SUIL -#define HAVE_LV2 -/* Comment out the above lines to build Mixbus without LV2 support */ -#endif - -#ifndef VST_SUPPORT -#define VST_SUPPORT -/* Comment out the above line to build Mixbus without VST support */ -#endif - -#ifndef JACK_32_64 -#define JACK_32_64 -/* Shouldn't really be needed but make sure that any structs we - obtain from libjack will have 1-byte packing alignment where - necessary (belt & braces approach to be on the safe side) */ -#endif - -#ifdef _DEBUG -#define _SECURE_SCL 1 -#define _HAS_ITERATOR_DEBUGGING 1 -/* #define to zero for a more conventional Debug build */ -#endif - -#ifndef __midl -#if defined(_DEBUG) || defined (DEBUG) -/* Experimental - link to the lowest DebugCRT so we can run on another system */ -#define _SXS_ASSEMBLY_VERSION "8.0.50727.42" -#else -#define _SXS_ASSEMBLY_VERSION "8.0.50727.6195" -#endif -#define _CRT_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION -#define _MFC_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION -#define _ATL_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION - -#ifdef __cplusplus -extern "C" { -#endif -__declspec(selectany) int _forceCRTManifest; -__declspec(selectany) int _forceMFCManifest; -__declspec(selectany) int _forceAtlDllManifest; -__declspec(selectany) int _forceCRTManifestRTM; -__declspec(selectany) int _forceMFCManifestRTM; -__declspec(selectany) int _forceAtlDllManifestRTM; -#ifdef __cplusplus -} -#endif -#endif - -/* 'stdint.h' conflicts with various other libraries so - let's #include stdint.h first to ensure one consistent - implementation for commonly used integer types. */ -#include - -#if (BUILDING_ARDOUR) -#if defined(_MSC_VER) && !defined(__MINGW__) && !defined(__MINGW32__) -#include -#endif -#endif - -#endif /*_TARGETSXS_H_*/ -- cgit v1.2.3 From 57e53d577b914ca1a56d2a59a9dd48a450c573ce Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 17 Jul 2013 13:49:12 -0400 Subject: break symbol name cycle on non-win32-non-gcc platforms --- libs/pbd/ffs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pbd/ffs.cc b/libs/pbd/ffs.cc index 8f7ecdb502..0a61969e8a 100644 --- a/libs/pbd/ffs.cc +++ b/libs/pbd/ffs.cc @@ -28,7 +28,7 @@ ffs (int x) #if defined(WIN32) && defined(__GNUC__) return __builtin_ffs(x); #else - return ffs(x); + return ::ffs(x); #endif } -- cgit v1.2.3 From 9d774969fcf8539aa301b20d659710407b7b4e83 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Thu, 18 Jul 2013 12:08:34 +0100 Subject: Adapt libs/pbd/ffs.cc to be buildable with MSVC --- libs/pbd/ffs.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/pbd/ffs.cc b/libs/pbd/ffs.cc index 0a61969e8a..557504f14e 100644 --- a/libs/pbd/ffs.cc +++ b/libs/pbd/ffs.cc @@ -19,14 +19,28 @@ #include "pbd/ffs.h" +#ifndef COMPILER_MSVC #include +#endif namespace PBD { int ffs (int x) { -#if defined(WIN32) && defined(__GNUC__) +#if defined (COMPILER_MINGW) return __builtin_ffs(x); +#elif defined (COMPILER_MSVC) + unsigned long index; +#ifdef WIN64 + if (0 != _BitScanForward64(&index, (__int64)x)) +#else + if (0 != _BitScanForward(&index, (unsigned long)x)) +#endif + index++; // Make the result 1-based + else + index = 0; // All bits were zero + + return (int)index; #else return ::ffs(x); #endif -- cgit v1.2.3 From 53f1cb2a0f2403ee473dd1802fd17597b05d5307 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Sat, 20 Jul 2013 08:30:40 +0100 Subject: Modify 'libs/vamp-plugins' to be buildable with MSVC --- libs/vamp-plugins/Onset.cpp | 3 +++ libs/vamp-plugins/OnsetDetect.cpp | 3 +++ libs/vamp-plugins/PercussionOnsetDetector.cpp | 3 +++ libs/vamp-plugins/SpectralCentroid.cpp | 19 +++++++++++++++---- msvc_extra_headers/ardourext/sys/targetsxs.h.input | 2 +- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/libs/vamp-plugins/Onset.cpp b/libs/vamp-plugins/Onset.cpp index d475b11be9..4a58bf9fa5 100644 --- a/libs/vamp-plugins/Onset.cpp +++ b/libs/vamp-plugins/Onset.cpp @@ -14,6 +14,9 @@ */ +#ifdef COMPILER_MSVC +#include +#endif #include #include "Onset.h" diff --git a/libs/vamp-plugins/OnsetDetect.cpp b/libs/vamp-plugins/OnsetDetect.cpp index 614eb4c943..714eee3647 100644 --- a/libs/vamp-plugins/OnsetDetect.cpp +++ b/libs/vamp-plugins/OnsetDetect.cpp @@ -12,6 +12,9 @@ COPYING included with this distribution for more information. */ +#ifdef COMPILER_MSVC +#include +#endif #include "OnsetDetect.h" #include "dsp/onsets/DetectionFunction.h" diff --git a/libs/vamp-plugins/PercussionOnsetDetector.cpp b/libs/vamp-plugins/PercussionOnsetDetector.cpp index 447eb19a28..623b89b6a0 100644 --- a/libs/vamp-plugins/PercussionOnsetDetector.cpp +++ b/libs/vamp-plugins/PercussionOnsetDetector.cpp @@ -34,6 +34,9 @@ authorization. */ +#ifdef COMPILER_MSVC +#include +#endif #include "PercussionOnsetDetector.h" using std::string; diff --git a/libs/vamp-plugins/SpectralCentroid.cpp b/libs/vamp-plugins/SpectralCentroid.cpp index 82d80b8100..f1493bf282 100644 --- a/libs/vamp-plugins/SpectralCentroid.cpp +++ b/libs/vamp-plugins/SpectralCentroid.cpp @@ -34,6 +34,19 @@ authorization. */ +#include + +#ifdef COMPILER_MSVC +#include + +// 'std::isinf()' and 'std::isnan()' are not available in MSVC. +#define isinf(val) !((bool)_finite((double)val)) +#define isnan(val) (bool)_isnan((double)val) +#else +using std::isnan; +using std:isinf; +#endif + #include "SpectralCentroid.h" using std::string; @@ -41,8 +54,6 @@ using std::vector; using std::cerr; using std::endl; -#include - SpectralCentroid::SpectralCentroid(float inputSampleRate) : Plugin(inputSampleRate), @@ -165,13 +176,13 @@ SpectralCentroid::process(const float *const *inputBuffers, Vamp::RealTime) Feature feature; feature.hasTimestamp = false; - if (!std::isnan(centroidLog) && !std::isinf(centroidLog)) { + if (!isnan(centroidLog) && !isinf(centroidLog)) { feature.values.push_back(centroidLog); } returnFeatures[0].push_back(feature); feature.values.clear(); - if (!std::isnan(centroidLin) && !std::isinf(centroidLin)) { + if (!isnan(centroidLin) && !isinf(centroidLin)) { feature.values.push_back(centroidLin); } returnFeatures[1].push_back(feature); diff --git a/msvc_extra_headers/ardourext/sys/targetsxs.h.input b/msvc_extra_headers/ardourext/sys/targetsxs.h.input index 6653041d8a..2730c8cb8d 100644 --- a/msvc_extra_headers/ardourext/sys/targetsxs.h.input +++ b/msvc_extra_headers/ardourext/sys/targetsxs.h.input @@ -57,8 +57,8 @@ __declspec(selectany) int _forceAtlDllManifestRTM; implementation for commonly used integer types. */ #include -#if (BUILDING_ARDOUR) #if defined(_MSC_VER) && !defined(__MINGW__) && !defined(__MINGW32__) +#if (INCLUDE_ARDOUR_MISCELLANEOUS) #include #endif #endif -- cgit v1.2.3 From e39bf4d82c902b49d008ebc5c193142c6969e05f Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Fri, 19 Jul 2013 09:33:00 +1000 Subject: Correct file perms on to make scripts executable in windows build files --- tools/windows_packaging/clean.sh | 0 tools/windows_packaging/configure-debug.sh | 0 tools/windows_packaging/configure-release.sh | 0 tools/windows_packaging/cptovm.sh | 0 tools/windows_packaging/make-installer.sh | 0 tools/windows_packaging/mingw-env.sh | 0 tools/windows_packaging/package.sh | 0 tools/windows_packaging/print-env.sh | 0 tools/windows_packaging/run-wine.sh | 0 tools/windows_packaging/startvm.sh | 0 tools/windows_packaging/waf.sh | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/windows_packaging/clean.sh mode change 100644 => 100755 tools/windows_packaging/configure-debug.sh mode change 100644 => 100755 tools/windows_packaging/configure-release.sh mode change 100644 => 100755 tools/windows_packaging/cptovm.sh mode change 100644 => 100755 tools/windows_packaging/make-installer.sh mode change 100644 => 100755 tools/windows_packaging/mingw-env.sh mode change 100644 => 100755 tools/windows_packaging/package.sh mode change 100644 => 100755 tools/windows_packaging/print-env.sh mode change 100644 => 100755 tools/windows_packaging/run-wine.sh mode change 100644 => 100755 tools/windows_packaging/startvm.sh mode change 100644 => 100755 tools/windows_packaging/waf.sh diff --git a/tools/windows_packaging/clean.sh b/tools/windows_packaging/clean.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/configure-debug.sh b/tools/windows_packaging/configure-debug.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/configure-release.sh b/tools/windows_packaging/configure-release.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/cptovm.sh b/tools/windows_packaging/cptovm.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/make-installer.sh b/tools/windows_packaging/make-installer.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/mingw-env.sh b/tools/windows_packaging/mingw-env.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/package.sh b/tools/windows_packaging/package.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/print-env.sh b/tools/windows_packaging/print-env.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/run-wine.sh b/tools/windows_packaging/run-wine.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/startvm.sh b/tools/windows_packaging/startvm.sh old mode 100644 new mode 100755 diff --git a/tools/windows_packaging/waf.sh b/tools/windows_packaging/waf.sh old mode 100644 new mode 100755 -- cgit v1.2.3 From 1e9301a713ce1905edaf8326879d2b100a5ea6d1 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Mon, 22 Jul 2013 11:56:18 +1000 Subject: Define PLATFORM_WINDOWS and COMPILER_MINGW when dist target is set to mingw --- wscript | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wscript b/wscript index 3088319def..eefa532b1e 100644 --- a/wscript +++ b/wscript @@ -618,6 +618,10 @@ def configure(conf): if Options.options.dist_target == 'mingw': Options.options.fpu_optimization = False + conf.env.append_value('CFLAGS', '-DPLATFORM_WINDOWS') + conf.env.append_value('CFLAGS', '-DCOMPILER_MINGW') + conf.env.append_value('CXXFLAGS', '-DPLATFORM_WINDOWS') + conf.env.append_value('CXXFLAGS', '-DCOMPILER_MINGW') conf.env.append_value('LIB', 'pthreadGC2') # needed for at least libsmf conf.check_cc(function_name='htonl', header_name='winsock2.h', lib='ws2_32') -- cgit v1.2.3 From d0deae357bba112a51a60a30cb97e7736636a120 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 10:40:29 +1000 Subject: Remove tools/sanity_check dir from build in mingw cross compile This is already added to build further down. I believe this is result of a partially applied patch. --- wscript | 2 -- 1 file changed, 2 deletions(-) diff --git a/wscript b/wscript index eefa532b1e..b96c8932f4 100644 --- a/wscript +++ b/wscript @@ -47,10 +47,8 @@ i18n_children = [ ] if sys.platform == 'linux2': - children += [ 'tools/sanity_check' ] lxvst_default = True elif sys.platform == 'darwin': - children += [ 'libs/appleutility' ] lxvst_default = False else: lxvst_default = False -- cgit v1.2.3 From 56a6f5285613bd140a71bf476df0e6a822aa7638 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 11:11:39 +1000 Subject: Remove lxvst variable from wscript that was no longer in use --- wscript | 7 ------- 1 file changed, 7 deletions(-) diff --git a/wscript b/wscript index b96c8932f4..ecc989da64 100644 --- a/wscript +++ b/wscript @@ -46,13 +46,6 @@ i18n_children = [ 'libs/gtkmm2ext', ] -if sys.platform == 'linux2': - lxvst_default = True -elif sys.platform == 'darwin': - lxvst_default = False -else: - lxvst_default = False - # Version stuff def fetch_gcc_version (CC): -- cgit v1.2.3 From ed9dd5ca6261ec511c128af67c4ee522084f4e07 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 11:44:50 +1000 Subject: Enable lxvst support by default and then disable for build targets that don't support it --- wscript | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/wscript b/wscript index ecc989da64..d4d0cc2be4 100644 --- a/wscript +++ b/wscript @@ -244,7 +244,7 @@ def set_compiler_flags (conf,opt): print("However, this is tricky and not recommended for beginners.") sys.exit (-1) - if opt.lxvst: + if conf.env['LXVST_SUPPORT'] == True: if conf.env['build_target'] == 'x86_64': conf.env.append_value('CXXFLAGS', "-DLXVST_64BIT") else: @@ -416,7 +416,7 @@ def options(opt): help='Compile with support for LV2 (if Lilv+Suil is available)') opt.add_option('--no-lv2', action='store_false', dest='lv2', help='Do not compile with support for LV2') - opt.add_option('--lxvst', action='store_true', default=False, dest='lxvst', + opt.add_option('--lxvst', action='store_true', default=True, dest='lxvst', help='Compile with support for linuxVST plugins') opt.add_option('--nls', action='store_true', default=True, dest='nls', help='Enable i18n (native language support) (default)') @@ -665,8 +665,13 @@ def configure(conf): conf.env.append_value('CXXFLAGS', '-I' + Options.options.wine_include) autowaf.check_header(conf, 'cxx', 'windows.h', mandatory = True) if opts.lxvst: - conf.define('LXVST_SUPPORT', 1) - conf.env['LXVST_SUPPORT'] = True + if sys.platform == 'darwin': + conf.env['LXVST_SUPPORT'] = False + elif Options.options.dist_target == 'mingw': + conf.env['LXVST_SUPPORT'] = False + else: + conf.define('LXVST_SUPPORT', 1) + conf.env['LXVST_SUPPORT'] = True if bool(conf.env['JACK_SESSION']): conf.define('HAVE_JACK_SESSION', 1) conf.define('WINDOWS_KEY', opts.windows_key) -- cgit v1.2.3 From d3850612b47f209f4c594294405918c4a675932d Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Fri, 19 Jul 2013 09:32:12 +1000 Subject: Disable building all surface plugins on MinGW build --- libs/surfaces/wscript | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/surfaces/wscript b/libs/surfaces/wscript index 1b2948c50a..335d14ee87 100644 --- a/libs/surfaces/wscript +++ b/libs/surfaces/wscript @@ -35,10 +35,12 @@ def sub_config_and_use(conf, name, has_objects = True): def configure(conf): autowaf.set_recursive() autowaf.configure(conf) - + for i in children: sub_config_and_use(conf, i) + if (conf.env['build_target'] == 'mingw'): return + #autowaf.check_pkg(conf, 'libusb-1.0', uselib_store='USB', mandatory=False) #if Options.options.tranzport and conf.is_defined('HAVE_USB'): # conf.define('BUILD_TRANZPORT', 1) @@ -63,6 +65,7 @@ def configure(conf): def build(bld): bld.recurse('control_protocol') + if (bld.env['build_target'] == 'mingw'): return if bld.is_defined ('BUILD_MACKIE'): bld.recurse('mackie') if bld.is_defined ('HAVE_LO'): -- cgit v1.2.3 From f7e3b01e23726a457a818781e5638d56ce1d9986 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Fri, 19 Jul 2013 18:35:42 +1000 Subject: Use cross-platform packaging version script in MinGW build --- tools/windows_packaging/mingw-env.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/windows_packaging/mingw-env.sh b/tools/windows_packaging/mingw-env.sh index 37a575885f..28e5bf5fd3 100755 --- a/tools/windows_packaging/mingw-env.sh +++ b/tools/windows_packaging/mingw-env.sh @@ -26,8 +26,9 @@ BUILD_DIR=$BASE/build BUILD_CACHE_FILE=$BUILD_DIR/c4che/_cache.py TOOLS_DIR=$BASE/tools/windows_packaging +. ../define_versions.sh + APPNAME=`grep -m 1 '^APPNAME' $BASE/wscript | awk '{print $3}' | sed "s/'//g"` -VERSION=`grep -m 1 '^VERSION' $BASE/wscript | awk '{print $3}' | sed "s/'//g"` # These are only relevant after a build if test -f $BUILD_CACHE_FILE @@ -35,9 +36,9 @@ then # Figure out the Build Type if grep -q "DEBUG = True" $BUILD_CACHE_FILE; then DEBUG=1 - PACKAGE_DIR="$APPNAME-$VERSION-win32-dbg" + PACKAGE_DIR="$APPNAME-${version}-win32-dbg" else - PACKAGE_DIR="$APPNAME-$VERSION-win32" + PACKAGE_DIR="$APPNAME-${version}-win32" fi if grep -q "BUILD_TESTS = True" $BUILD_CACHE_FILE; then -- cgit v1.2.3 From 5ef3d54acbf9e8d5e0f1b945e4afb247d2c7c3fe Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 10:38:54 +1000 Subject: Add some dll's to list to copy to mingw based windows package These are some new dependencies in Fedora 19 mingw packages --- tools/windows_packaging/package.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/windows_packaging/package.sh b/tools/windows_packaging/package.sh index 1270bc0cc5..92f55e8906 100755 --- a/tools/windows_packaging/package.sh +++ b/tools/windows_packaging/package.sh @@ -60,6 +60,7 @@ jackserver-0.dll libart_lgpl_2-2.dll libatk-1.0-0.dll libatkmm-1.6-1.dll +libbz2-1.dll libcairo-2.dll libcairo-gobject-2.dll libcairomm-1.0-1.dll @@ -90,6 +91,7 @@ libgobject-2.0-0.dll libgthread-2.0-0.dll libgtkmm-2.4-1.dll libgtk-win32-2.0-0.dll +libharfbuzz-0.dll libiconv-2.dll iconv.dll libFLAC-8.dll @@ -99,6 +101,7 @@ libvorbisenc-2.dll libffi-6.dll libidn-11.dll libintl-8.dll +liblo-7.dll libpango-1.0-0.dll libpangocairo-1.0-0.dll libpangoft2-1.0-0.dll -- cgit v1.2.3 From 77cea1181e0da8eed036d81a8a0da6ab8bfb096f Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Mon, 22 Jul 2013 11:57:26 +1000 Subject: Fix broken using declaration in vamp-plugins --- libs/vamp-plugins/SpectralCentroid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/vamp-plugins/SpectralCentroid.cpp b/libs/vamp-plugins/SpectralCentroid.cpp index f1493bf282..f93fdcaa32 100644 --- a/libs/vamp-plugins/SpectralCentroid.cpp +++ b/libs/vamp-plugins/SpectralCentroid.cpp @@ -44,7 +44,7 @@ #define isnan(val) (bool)_isnan((double)val) #else using std::isnan; -using std:isinf; +using std::isinf; #endif #include "SpectralCentroid.h" -- cgit v1.2.3 From b02fb1dbea550596a37391fafcf4dc5005cdc0f1 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Mon, 22 Jul 2013 12:01:44 +1000 Subject: Reinstate include of regex.h for Linux and MinGW build I'm not sure how boost/regex.h is relevant but it doesn't enable the build to succeed in on Linux or using Mingw so if this is not an error and required for msvc build then fix it --- libs/pbd/pathexpand.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc index 3f1f1cf670..5784ec9428 100644 --- a/libs/pbd/pathexpand.cc +++ b/libs/pbd/pathexpand.cc @@ -23,7 +23,7 @@ #include #include -#include +#include #include -- cgit v1.2.3 From c4e02af713c24beb1a472ade00d7b9e81e1f2e8f Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Fri, 19 Jul 2013 18:38:46 +1000 Subject: Fix for ambiguous Polygon type when building with MinGW --- gtk2_ardour/marker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/marker.cc b/gtk2_ardour/marker.cc index 27fa9f5d42..2492d1a348 100644 --- a/gtk2_ardour/marker.cc +++ b/gtk2_ardour/marker.cc @@ -242,7 +242,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con /* adjust to properly locate the tip */ - mark = new Polygon (*group); + mark = new ArdourCanvas::Polygon (*group); mark->property_points() = *points; set_color_rgba (rgba); mark->property_width_pixels() = 1; -- cgit v1.2.3 From 61c8e093ef36721fb24079573842fd1c7a64cfea Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Fri, 19 Jul 2013 18:40:50 +1000 Subject: Use PBD::ffs for portability --- gtk2_ardour/midi_channel_selector.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/midi_channel_selector.cc b/gtk2_ardour/midi_channel_selector.cc index 2f5ca729a6..b51584aef5 100644 --- a/gtk2_ardour/midi_channel_selector.cc +++ b/gtk2_ardour/midi_channel_selector.cc @@ -516,7 +516,7 @@ MidiChannelSelectorWindow::set_playback_selected_channels (uint16_t mask) case ForceChannel: /* only set the lowest set channel in the mask as active */ for (uint16_t i = 0; i < 16; i++) { - playback_buttons[i]->set_active (i == (ffs (mask) - 1)); + playback_buttons[i]->set_active (i == (PBD::ffs (mask) - 1)); } break; } @@ -539,7 +539,7 @@ MidiChannelSelectorWindow::set_capture_selected_channels (uint16_t mask) case ForceChannel: /* only set the lowest set channel in the mask as active */ for (uint16_t i = 0; i < 16; i++) { - capture_buttons[i]->set_active (i == (ffs (mask) - 1)); + capture_buttons[i]->set_active (i == (PBD::ffs (mask) - 1)); } break; } @@ -595,7 +595,7 @@ MidiChannelSelectorWindow::playback_mode_changed () case ForceChannel: if (last_drawn_playback_mode == AllChannels || last_drawn_playback_mode == FilterChannels) { playback_buttons.clear (); - first_channel = ffs (track->get_playback_channel_mask()) - 1; + first_channel = PBD::ffs (track->get_playback_channel_mask()) - 1; } for (vector::iterator i = playback_mask_controls.begin(); i != playback_mask_controls.end(); ++i) { (*i)->set_sensitive (false); @@ -693,7 +693,7 @@ MidiChannelSelectorWindow::capture_mode_changed () case ForceChannel: if (last_drawn_capture_mode == AllChannels || last_drawn_capture_mode == FilterChannels) { capture_buttons.clear (); - first_channel = ffs (track->get_capture_channel_mask()) - 1; + first_channel = PBD::ffs (track->get_capture_channel_mask()) - 1; } for (vector::iterator i = capture_mask_controls.begin(); i != capture_mask_controls.end(); ++i) { (*i)->set_sensitive (false); -- cgit v1.2.3 From fee2c9d71f03336f5a64b08ff10cf90e22372da8 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Fri, 19 Jul 2013 18:41:34 +1000 Subject: Fix ambiguous type CheckMenuItem that is also defined via windows.h --- gtk2_ardour/midi_time_axis.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 3da5f11f10..93649dbebe 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -738,7 +738,7 @@ MidiTimeAxisView::add_single_channel_controller_item(Menu_Helpers::MenuList& ctl } } - Gtk::CheckMenuItem* cmi = static_cast(&ctl_items.back()); + Gtk::CheckMenuItem* cmi = static_cast(&ctl_items.back()); _controller_menu_map[fully_qualified_param] = cmi; cmi->set_active (visible); @@ -794,7 +794,7 @@ MidiTimeAxisView::add_multi_channel_controller_item(Menu_Helpers::MenuList& ctl_ } } - Gtk::CheckMenuItem* cmi = static_cast(&chn_items.back()); + Gtk::CheckMenuItem* cmi = static_cast(&chn_items.back()); _controller_menu_map[fully_qualified_param] = cmi; cmi->set_active (visible); } -- cgit v1.2.3 From f42c51463153bb2f761e722e4a7575cad580da3e Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 10:17:59 +1000 Subject: undef SearchPath where needed as it is defined via windows.h --- gtk2_ardour/transcode_ffmpeg.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk2_ardour/transcode_ffmpeg.cc b/gtk2_ardour/transcode_ffmpeg.cc index 9499c6c184..9c6a7d801b 100644 --- a/gtk2_ardour/transcode_ffmpeg.cc +++ b/gtk2_ardour/transcode_ffmpeg.cc @@ -32,6 +32,10 @@ #include "i18n.h" +#ifdef SearchPath +#undef SearchPath +#endif + using namespace PBD; TranscodeFfmpeg::TranscodeFfmpeg (std::string f) -- cgit v1.2.3 From f383585094528b62585d9a534a1ea6eff62ed42f Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 10:21:12 +1000 Subject: Disable some code on MinGW build until it can be tested NEEDS FIXING Windows has the function strtok_s which is equivalent to strtok_r in versions of msvcrt in Vista and above but not win XP. So either reimplement for WinXP or replace with something more portable and C++'y. --- gtk2_ardour/utils_videotl.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk2_ardour/utils_videotl.cc b/gtk2_ardour/utils_videotl.cc index 504fc3d2eb..1496893e82 100644 --- a/gtk2_ardour/utils_videotl.cc +++ b/gtk2_ardour/utils_videotl.cc @@ -253,6 +253,7 @@ video_query_info ( , filepath.c_str()); char *res = curl_http_get(url, NULL); int pid=0; +#ifndef COMPILER_MINGW if (res) { char *pch, *pst; int version; @@ -285,6 +286,7 @@ video_query_info ( } free(res); } +#endif if (pid!=5) { return false; } -- cgit v1.2.3 From 533e40ca52c9a8f969405d4afbb82552956445ae Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sun, 21 Jul 2013 18:49:29 +1000 Subject: Work around badly chosen argument name in giomm/dbusmessage.h interface is defined in windows/mingw headers. hopefully this will be fixed in giomm at some point and this crap can be removed --- gtk2_ardour/export_video_infobox.cc | 3 +++ gtk2_ardour/video_server_dialog.cc | 4 ++++ libs/gtkmm2ext/gtkmm2ext/gtk_ui.h | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/gtk2_ardour/export_video_infobox.cc b/gtk2_ardour/export_video_infobox.cc index fbe28bd821..a3e356decc 100644 --- a/gtk2_ardour/export_video_infobox.cc +++ b/gtk2_ardour/export_video_infobox.cc @@ -18,6 +18,9 @@ */ #include "ardour/session.h" +#ifdef interface +#undef interface +#endif #include "export_video_infobox.h" #include "i18n.h" diff --git a/gtk2_ardour/video_server_dialog.cc b/gtk2_ardour/video_server_dialog.cc index 8838409ccf..a8383f4d23 100644 --- a/gtk2_ardour/video_server_dialog.cc +++ b/gtk2_ardour/video_server_dialog.cc @@ -29,6 +29,10 @@ #include "ardour/template_utils.h" #include "ardour/session.h" +#ifdef interface +#undef interface +#endif + #include "video_server_dialog.h" #include "utils_videotl.h" #include "i18n.h" diff --git a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h index 64176232f0..a758ad78f4 100644 --- a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h +++ b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h @@ -27,6 +27,10 @@ #include #include +#ifdef interface +#undef interface +#endif + #include #include -- cgit v1.2.3 From c0e65452b1d8202698d89bfa593da5e0c6aaa015 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Mon, 22 Jul 2013 12:44:45 +1000 Subject: undef SearchPath where needed as it is defined via windows.h --- gtk2_ardour/video_server_dialog.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk2_ardour/video_server_dialog.cc b/gtk2_ardour/video_server_dialog.cc index a8383f4d23..468bcc5c8d 100644 --- a/gtk2_ardour/video_server_dialog.cc +++ b/gtk2_ardour/video_server_dialog.cc @@ -37,6 +37,10 @@ #include "utils_videotl.h" #include "i18n.h" +#ifdef SearchPath +#undef SearchPath +#endif + using namespace Gtk; using namespace std; using namespace PBD; -- cgit v1.2.3 From d975d84437119b4595619a523f1d2afaa14965ff Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Fri, 19 Jul 2013 18:46:52 +1000 Subject: Use GLib::usleep for portability --- gtk2_ardour/video_image_frame.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/video_image_frame.cc b/gtk2_ardour/video_image_frame.cc index 3c39dea77b..310f3a68d3 100644 --- a/gtk2_ardour/video_image_frame.cc +++ b/gtk2_ardour/video_image_frame.cc @@ -197,7 +197,7 @@ http_get_thread (void *arg) { char *res = NULL; do { res=curl_http_get(url, &status); - if (status == 503) usleep(5000); // try-again + if (status == 503) Glib::usleep(5000); // try-again } while (status == 503 && --timeout > 0); if (status != 200 || !res) { @@ -246,7 +246,7 @@ VideoImageFrame::http_download_done (char *data){ exposeimg(); /* don't request frames too quickly, wait after user has zoomed */ - usleep(40000); + Glib::usleep(40000); if (queued_request) { http_get_again(want_video_frame_number); -- cgit v1.2.3 From ccaa29d210c723aae458bbf607b29fe2b4755b2e Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 10:17:18 +1000 Subject: Use Glib::usleep for portability --- gtk2_ardour/transcode_ffmpeg.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/transcode_ffmpeg.cc b/gtk2_ardour/transcode_ffmpeg.cc index 9c6a7d801b..15b9f40919 100644 --- a/gtk2_ardour/transcode_ffmpeg.cc +++ b/gtk2_ardour/transcode_ffmpeg.cc @@ -126,7 +126,7 @@ TranscodeFfmpeg::probe () * SystemExec::Terminated is emitted and ffcmd set to NULL */ int timeout = 300; // 1.5 sec while (ffcmd && --timeout > 0) { - usleep(5000); + Glib::usleep(5000); } if (timeout == 0 || ffoutput.empty()) { return false; @@ -507,7 +507,11 @@ TranscodeFfmpeg::cancel () { if (!ffcmd || !ffcmd->is_running()) { return;} ffcmd->write_to_stdin("q"); +#ifdef WIN32 + Sleep(1000); +#else sleep (1); +#endif if (ffcmd) { ffcmd->terminate(); } -- cgit v1.2.3 From 486720de61a22d7c74e956a2478cf0f581d66d9e Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 10:26:30 +1000 Subject: Use Glib::usleep for portability --- gtk2_ardour/video_monitor.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/video_monitor.cc b/gtk2_ardour/video_monitor.cc index 2c265365fa..ae4d5faacc 100644 --- a/gtk2_ardour/video_monitor.cc +++ b/gtk2_ardour/video_monitor.cc @@ -94,7 +94,7 @@ VideoMonitor::query_full_state (bool wait) process->write_to_stdin("get osdcfg\n"); int timeout = 40; if (wait && knownstate !=127 && --timeout) { - usleep(50000); + Glib::usleep(50000); sched_yield(); } } @@ -113,7 +113,7 @@ VideoMonitor::quit () */ int timeout = 40; while (is_started() && --timeout) { - usleep(50000); + Glib::usleep(50000); sched_yield(); } if (timeout <= 0) { -- cgit v1.2.3 From f3fe3cfeaacda7194b569314b377b12526e09f54 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 10:33:48 +1000 Subject: Fix reference to new location of windows test image --- tools/windows_packaging/mingw-env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/windows_packaging/mingw-env.sh b/tools/windows_packaging/mingw-env.sh index 28e5bf5fd3..616f89af5e 100755 --- a/tools/windows_packaging/mingw-env.sh +++ b/tools/windows_packaging/mingw-env.sh @@ -49,4 +49,4 @@ then fi # put this somewhere better... -VIRT_IMAGE_PATH=$HOME/virt-images/winxp.raw +VIRT_IMAGE_PATH=$HOME/Data/virt-images/winxp.raw -- cgit v1.2.3 From b889a3d2f999dc97f21bbba4603ccdc349ba5bf2 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 20 Jul 2013 10:37:41 +1000 Subject: Use common mingw build script to reference location of windows test image --- tools/windows_packaging/startvm.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/windows_packaging/startvm.sh b/tools/windows_packaging/startvm.sh index 6d36bd8cb7..de65be9b5d 100755 --- a/tools/windows_packaging/startvm.sh +++ b/tools/windows_packaging/startvm.sh @@ -1,3 +1,4 @@ #!/bin/bash +. mingw-env.sh -qemu-kvm -smp 2 -m 1536 -hda $HOME/virt-images/winxp.raw -net nic -net user -vga std -soundhw all +qemu-kvm -smp 2 -m 1536 -hda $VIRT_IMAGE_PATH -net nic -net user -vga std -soundhw all -- cgit v1.2.3 From d0a6c1913425fd1a62441a94a1b56b377e4531e9 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 23 Jul 2013 07:40:17 +0100 Subject: Remove some unnecessary warnings when building 'libs/qm-dsp' with MSVC --- libs/qm-dsp/dsp/wavelet/Wavelet.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/qm-dsp/dsp/wavelet/Wavelet.cpp b/libs/qm-dsp/dsp/wavelet/Wavelet.cpp index 504090528c..ef792460dd 100644 --- a/libs/qm-dsp/dsp/wavelet/Wavelet.cpp +++ b/libs/qm-dsp/dsp/wavelet/Wavelet.cpp @@ -13,6 +13,10 @@ COPYING included with this distribution for more information. */ +#ifdef COMPILER_MSVC +#pragma warning(disable:4305) +#endif + #include "Wavelet.h" #include -- cgit v1.2.3 From 1cb37fc11c2698a5a8a416638a6a45cbcf797e21 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 23 Jul 2013 07:43:48 +0100 Subject: Remove an unnecessary #include that prevents 'libs/evoral' from building with MSVC (more evoral changes to follow) --- libs/evoral/evoral/midi_util.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/evoral/evoral/midi_util.h b/libs/evoral/evoral/midi_util.h index e1ae7f4620..e4480b347e 100644 --- a/libs/evoral/evoral/midi_util.h +++ b/libs/evoral/evoral/midi_util.h @@ -22,7 +22,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3 From 453ed61c4a23551c7ffeee5d972b29d6d92c1591 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 23 Jul 2013 07:47:10 +0100 Subject: 'libs/evoral' - cast the returned pointers from malloc() / g_ptr_array_index() etc, as needed to satisfy MSVC --- libs/evoral/src/libsmf/smf.c | 16 ++++++++-------- libs/evoral/src/libsmf/smf_decode.c | 16 ++++++++-------- libs/evoral/src/libsmf/smf_load.c | 14 +++++++------- libs/evoral/src/libsmf/smf_save.c | 4 ++-- libs/evoral/src/libsmf/smf_tempo.c | 8 ++++---- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/libs/evoral/src/libsmf/smf.c b/libs/evoral/src/libsmf/smf.c index d01c9bf148..10fb419fb3 100644 --- a/libs/evoral/src/libsmf/smf.c +++ b/libs/evoral/src/libsmf/smf.c @@ -56,7 +56,7 @@ smf_new(void) { int cantfail; - smf_t *smf = malloc(sizeof(smf_t)); + smf_t *smf = (smf_t*)malloc(sizeof(smf_t)); if (smf == NULL) { g_critical("Cannot allocate smf_t structure: %s", strerror(errno)); return (NULL); @@ -89,7 +89,7 @@ smf_delete(smf_t *smf) { /* Remove all the tracks, from last to first. */ while (smf->tracks_array->len > 0) - smf_track_delete(g_ptr_array_index(smf->tracks_array, smf->tracks_array->len - 1)); + smf_track_delete((smf_track_t*)g_ptr_array_index(smf->tracks_array, smf->tracks_array->len - 1)); smf_fini_tempo(smf); @@ -109,7 +109,7 @@ smf_delete(smf_t *smf) smf_track_t * smf_track_new(void) { - smf_track_t *track = malloc(sizeof(smf_track_t)); + smf_track_t *track = (smf_track_t*)malloc(sizeof(smf_track_t)); if (track == NULL) { g_critical("Cannot allocate smf_track_t structure: %s", strerror(errno)); return (NULL); @@ -135,7 +135,7 @@ smf_track_delete(smf_track_t *track) /* Remove all the events, from last to first. */ while (track->events_array->len > 0) - smf_event_delete(g_ptr_array_index(track->events_array, track->events_array->len - 1)); + smf_event_delete((smf_event_t*)g_ptr_array_index(track->events_array, track->events_array->len - 1)); if (track->smf) smf_track_remove_from_smf(track); @@ -217,7 +217,7 @@ smf_track_remove_from_smf(smf_track_t *track) smf_event_t * smf_event_new(void) { - smf_event_t *event = malloc(sizeof(smf_event_t)); + smf_event_t *event = (smf_event_t*)malloc(sizeof(smf_event_t)); if (event == NULL) { g_critical("Cannot allocate smf_event_t structure: %s", strerror(errno)); return (NULL); @@ -250,7 +250,7 @@ smf_event_new_from_pointer(const void *midi_data, size_t len) return (NULL); event->midi_buffer_length = len; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno)); smf_event_delete(event); @@ -340,7 +340,7 @@ smf_event_new_from_bytes(int first_byte, int second_byte, int third_byte) } event->midi_buffer_length = len; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno)); smf_event_delete(event); @@ -777,7 +777,7 @@ smf_track_get_event_by_number(const smf_track_t *track, size_t event_number) if (event_number > track->number_of_events) return (NULL); - event = g_ptr_array_index(track->events_array, event_number - 1); + event = (smf_event_t*)g_ptr_array_index(track->events_array, event_number - 1); assert(event); diff --git a/libs/evoral/src/libsmf/smf_decode.c b/libs/evoral/src/libsmf/smf_decode.c index dc152d37a5..395d483bea 100644 --- a/libs/evoral/src/libsmf/smf_decode.c +++ b/libs/evoral/src/libsmf/smf_decode.c @@ -118,7 +118,7 @@ smf_event_decode_textual(const smf_event_t *event, const char *name) int off = 0; char *buf, *extracted; - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_textual: malloc failed."); return (NULL); @@ -181,7 +181,7 @@ smf_event_decode_metadata(const smf_event_t *event) break; } - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_metadata: malloc failed."); return (NULL); @@ -239,7 +239,7 @@ smf_event_decode_metadata(const smf_event_t *event) off += snprintf(buf + off, BUFFER_SIZE - off, "Time Signature: %d/%d, %d clocks per click, %d notated 32nd notes per quarter note", - event->midi_buffer[3], (int)pow(2, event->midi_buffer[4]), event->midi_buffer[5], + event->midi_buffer[3], (int)pow((double)2, event->midi_buffer[4]), event->midi_buffer[5], event->midi_buffer[6]); break; @@ -306,7 +306,7 @@ smf_event_decode_system_realtime(const smf_event_t *event) return (NULL); } - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_system_realtime: malloc failed."); return (NULL); @@ -358,7 +358,7 @@ smf_event_decode_sysex(const smf_event_t *event) return (NULL); } - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_sysex: malloc failed."); return (NULL); @@ -459,7 +459,7 @@ smf_event_decode_system_common(const smf_event_t *event) if (smf_event_is_sysex(event)) return (smf_event_decode_sysex(event)); - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode_system_realtime: malloc failed."); return (NULL); @@ -530,7 +530,7 @@ smf_event_decode(const smf_event_t *event) return (NULL); } - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode: malloc failed."); return (NULL); @@ -600,7 +600,7 @@ smf_decode(const smf_t *smf) int off = 0; char *buf; - buf = malloc(BUFFER_SIZE); + buf = (char*)malloc(BUFFER_SIZE); if (buf == NULL) { g_critical("smf_event_decode: malloc failed."); return (NULL); diff --git a/libs/evoral/src/libsmf/smf_load.c b/libs/evoral/src/libsmf/smf_load.c index 4215d03e43..60b5d8166b 100644 --- a/libs/evoral/src/libsmf/smf_load.c +++ b/libs/evoral/src/libsmf/smf_load.c @@ -123,7 +123,7 @@ parse_mthd_header(smf_t *smf) return (-1); } - tmp_mthd = smf->file_buffer; + tmp_mthd = (chunk_header_struct*)smf->file_buffer; if (!chunk_signature_matches(tmp_mthd, "MThd")) { g_critical("SMF error: MThd signature not found, is that a MIDI file?"); @@ -409,7 +409,7 @@ extract_sysex_event(const unsigned char *buf, const size_t buffer_length, smf_ev } event->midi_buffer_length = message_length; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate memory in extract_sysex_event(): %s", strerror(errno)); return (-4); @@ -452,7 +452,7 @@ extract_escaped_event(const unsigned char *buf, const size_t buffer_length, smf_ } event->midi_buffer_length = message_length; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate memory in extract_escaped_event(): %s", strerror(errno)); return (-4); @@ -522,7 +522,7 @@ extract_midi_event(const unsigned char *buf, const size_t buffer_length, smf_eve } event->midi_buffer_length = message_length; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate memory in extract_midi_event(): %s", strerror(errno)); return (-4); @@ -611,7 +611,7 @@ make_string(const unsigned char *buf, const size_t buffer_length, uint32_t len) len = buffer_length; } - str = malloc(len + 1); + str = (char*)malloc(len + 1); if (str == NULL) { g_critical("Cannot allocate memory in make_string()."); return (NULL); @@ -662,14 +662,14 @@ smf_event_extract_text(const smf_event_t *event) return (NULL); } - smf_extract_vlq((void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length); + smf_extract_vlq((const unsigned char*)(void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length); if (string_length <= 0) { g_critical("smf_event_extract_text: truncated MIDI message."); return (NULL); } - return (make_string((void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length)); + return (make_string((const unsigned char*)(void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length)); } /** diff --git a/libs/evoral/src/libsmf/smf_save.c b/libs/evoral/src/libsmf/smf_save.c index 2cceba1ce2..f818d0a862 100644 --- a/libs/evoral/src/libsmf/smf_save.c +++ b/libs/evoral/src/libsmf/smf_save.c @@ -58,7 +58,7 @@ static void * smf_extend(smf_t *smf, const int length) { int i, previous_file_buffer_length = smf->file_buffer_length; - char *previous_file_buffer = smf->file_buffer; + char *previous_file_buffer = (char*)smf->file_buffer; /* XXX: Not terribly efficient. */ smf->file_buffer_length += length; @@ -205,7 +205,7 @@ smf_event_new_textual(int type, const char *text) /* "2 +" is for leading 0xFF 0xtype. */ event->midi_buffer_length = 2 + text_length + MAX_VLQ_LENGTH; - event->midi_buffer = malloc(event->midi_buffer_length); + event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length); if (event->midi_buffer == NULL) { g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno)); smf_event_delete(event); diff --git a/libs/evoral/src/libsmf/smf_tempo.c b/libs/evoral/src/libsmf/smf_tempo.c index c24e7460c1..6620cd405c 100644 --- a/libs/evoral/src/libsmf/smf_tempo.c +++ b/libs/evoral/src/libsmf/smf_tempo.c @@ -59,7 +59,7 @@ new_tempo(smf_t *smf, size_t pulses) return (previous_tempo); } - tempo = malloc(sizeof(smf_tempo_t)); + tempo = (smf_tempo_t*)malloc(sizeof(smf_tempo_t)); if (tempo == NULL) { g_critical("Cannot allocate smf_tempo_t."); return (NULL); @@ -152,7 +152,7 @@ maybe_add_to_tempo_map(smf_event_t *event) } numerator = event->midi_buffer[3]; - denominator = (int)pow(2, event->midi_buffer[4]); + denominator = (int)pow((double)2, event->midi_buffer[4]); clocks_per_click = event->midi_buffer[5]; notes_per_note = event->midi_buffer[6]; @@ -259,7 +259,7 @@ smf_get_tempo_by_number(const smf_t *smf, size_t number) if (number >= smf->tempo_array->len) return (NULL); - return (g_ptr_array_index(smf->tempo_array, number)); + return ((smf_tempo_t*)g_ptr_array_index(smf->tempo_array, number)); } /** @@ -341,7 +341,7 @@ smf_fini_tempo(smf_t *smf) smf_tempo_t *tempo; while (smf->tempo_array->len > 0) { - tempo = g_ptr_array_index(smf->tempo_array, smf->tempo_array->len - 1); + tempo = (smf_tempo_t*)g_ptr_array_index(smf->tempo_array, smf->tempo_array->len - 1); assert(tempo); memset(tempo, 0, sizeof(smf_tempo_t)); -- cgit v1.2.3 From f9b99edc4a4036dd767e04a6c5c18e0a0ddf5880 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 23 Jul 2013 07:50:25 +0100 Subject: 'std::isnan' is not available in MSVC (at least, not VC8) --- libs/evoral/src/ControlList.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index a095daa135..18803af348 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -16,6 +16,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +// 'std::isnan()' is not available in MSVC. +#ifndef COMPILER_MSVC +using std::isnan; +#endif + #include #include #include @@ -812,7 +817,7 @@ ControlList::modify (iterator iter, double when, double val) (*iter)->when = when; (*iter)->value = val; - if (std::isnan (val)) { + if (isnan (val)) { abort (); } -- cgit v1.2.3 From af51ef383de1e0e160a639ab5d6fb1a6054c1135 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 23 Jul 2013 07:53:57 +0100 Subject: 'libs/evoral' - Through a compiler extension gcc can implement an array whose size in not known at compile time. MSVC doesn't have this extension. Therefore, use std::vector instead --- libs/evoral/src/Curve.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/evoral/src/Curve.cpp b/libs/evoral/src/Curve.cpp index 6f3532fdcb..a813eb7062 100644 --- a/libs/evoral/src/Curve.cpp +++ b/libs/evoral/src/Curve.cpp @@ -56,8 +56,8 @@ Curve::solve () (www.korf.co.uk/spline.pdf) for more details. */ - double x[npoints]; - double y[npoints]; + vector x(npoints); + vector y(npoints); uint32_t i; ControlList::EventList::const_iterator xx; -- cgit v1.2.3 From bc34d6f731062693a61b0c73cc9d489ab25568e3 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 23 Jul 2013 07:56:30 +0100 Subject: 'libs/evoral' - For each of the NNNN_lower_bound() functions (3 in total) add a non-const iterator to supplement the existing const_iterator --- libs/evoral/evoral/Sequence.hpp | 8 +++++++- libs/evoral/src/Sequence.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index e2e92385aa..dbc04d619b 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -179,7 +179,7 @@ public: OverlapPitchResolution overlap_pitch_resolution() const { return _overlap_pitch_resolution; } void set_overlap_pitch_resolution(OverlapPitchResolution opr); - void set_notes (const Sequence