diff --git a/.gitignore b/.gitignore index f2251ba204..f148f7e3fb 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,58 @@ tags # /libs/pbd/ /libs/pbd/version.cc /libs/pbd/pbd/version.h + +/libs/taglib/taglib/flacproperties.h +/libs/taglib/taglib/apefooter.h +/libs/taglib/taglib/apeitem.h +/libs/taglib/taglib/apetag.h +/libs/taglib/taglib/attachedpictureframe.h +/libs/taglib/taglib/commentsframe.h +/libs/taglib/taglib/flacfile.h +/libs/taglib/taglib/id3v2tag.h +/libs/taglib/taglib/generalencapsulatedobjectframe.h +/libs/taglib/taglib/id3v1genres.h +/libs/taglib/taglib/id3v1tag.h +/libs/taglib/taglib/id3v2extendedheader.h +/libs/taglib/taglib/id3v2footer.h +/libs/taglib/taglib/id3v2frame.h +/libs/taglib/taglib/id3v2framefactory.h +/libs/taglib/taglib/id3v2header.h +/libs/taglib/taglib/id3v2synchdata.h +/libs/taglib/taglib/oggpageheader.h +/libs/taglib/taglib/mpcfile.h +/libs/taglib/taglib/mpcproperties.h +/libs/taglib/taglib/mpegfile.h +/libs/taglib/taglib/mpegheader.h +/libs/taglib/taglib/mpegproperties.h +/libs/taglib/taglib/oggfile.h +/libs/taglib/taglib/oggflacfile.h +/libs/taglib/taglib/oggpage.h +/libs/taglib/taglib/textidentificationframe.h +/libs/taglib/taglib/relativevolumeframe.h +/libs/taglib/taglib/speexfile.h +/libs/taglib/taglib/speexproperties.h +/libs/taglib/taglib/taglib.h +/libs/taglib/taglib/tbytevector.h +/libs/taglib/taglib/tbytevectorlist.h +/libs/taglib/taglib/tdebug.h +/libs/taglib/taglib/tlist.h +/libs/taglib/taglib/tmap.h +/libs/taglib/taglib/trueaudiofile.h +/libs/taglib/taglib/trueaudioproperties.h +/libs/taglib/taglib/tstring.h +/libs/taglib/taglib/tstringlist.h +/libs/taglib/taglib/tfile.h +/libs/taglib/taglib/urllinkframe.h +/libs/taglib/taglib/unicode.h +/libs/taglib/taglib/uniquefileidentifierframe.h +/libs/taglib/taglib/unknownframe.h +/libs/taglib/taglib/unsynchronizedlyricsframe.h +/libs/taglib/taglib/xiphcomment.h +/libs/taglib/taglib/vorbisfile.h +/libs/taglib/taglib/vorbisproperties.h +/libs/taglib/taglib/wavpackfile.h +/libs/taglib/taglib/wavpackproperties.h +/libs/taglib/taglib/xingheader.h +/libs/taglib/taglib/tlist.tcc +/libs/taglib/taglib/tmap.tcc \ No newline at end of file diff --git a/gtk2_ardour/about.cc b/gtk2_ardour/about.cc index 280f72a8dc..df1bd586c5 100644 --- a/gtk2_ardour/about.cc +++ b/gtk2_ardour/about.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -265,7 +264,7 @@ patent must be licensed for everyone's free use or not licensed at all.\n\ The precise terms and conditions for copying, distribution and\n\ modification follow.\n\ \n\ - GNU GENERAL PUBLIC LICENSE\n\ +"" GNU GENERAL PUBLIC LICENSE\n\ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\ \n\ 0. This License applies to any program or other work which contains\n\ @@ -547,7 +546,9 @@ proprietary programs. If your program is a subroutine library, you may\n\ consider it more useful to permit linking proprietary applications with the\n\ library. If this is what you want to do, use the GNU Library General\n\ Public License instead of this License.\n\ -"); +"); /* Note that at the start of (approximately) line 265, the above license + text has been split into two concatenated tokens (to satisfy compilation + under MSVC). Hopefully this won't affect gcc */ About::About () : config_info (0) @@ -561,7 +562,7 @@ About::About () std::string splash_file; - SearchPath spath(ardour_data_search_path()); + Searchpath spath(ardour_data_search_path()); if (find_file_in_search_path (spath, "splash.png", splash_file)) { set_logo (Gdk::Pixbuf::create_from_file (splash_file)); diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 6337b1919f..a2a5f0a385 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -27,15 +27,18 @@ #include #include +#ifndef PLATFORM_WINDOWS +#include +#endif + #include #include #include #include #include -#include -#include -#include +#include +#include #include #include @@ -48,6 +51,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" @@ -293,7 +297,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 */ @@ -753,8 +757,9 @@ ARDOUR_UI::starting () // wait for announce reply from nsm server for ( i = 0; i < 5000; ++i) { nsm->check (); - usleep (i); - if (nsm->is_active()) { + + Glib::usleep (i); + if (nsm->is_active()) break; } } @@ -765,8 +770,9 @@ ARDOUR_UI::starting () // wait for open command from nsm server for ( i = 0; i < 5000; ++i) { nsm->check (); - usleep (1000); - if (nsm->client_id ()) { + + Glib::usleep (1000); + if (nsm->client_id ()) break; } } @@ -848,7 +854,7 @@ ARDOUR_UI::starting () void ARDOUR_UI::check_memory_locking () { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(PLATFORM_WINDOWS) /* OS X doesn't support mlockall(2), and so testing for memory locking capability there is pointless */ return; #else // !__APPLE__ @@ -3102,13 +3108,13 @@ require some unused files to continue to exist.")); space_adjusted = rep.space; } else if (rep.space < 1000000) { bprefix = _("kilo"); - space_adjusted = truncf((float)rep.space / 1000.0); + space_adjusted = floorf((float)rep.space / 1000.0); } else if (rep.space < 1000000 * 1000) { bprefix = _("mega"); - space_adjusted = truncf((float)rep.space / (1000.0 * 1000.0)); + space_adjusted = floorf((float)rep.space / (1000.0 * 1000.0)); } else { bprefix = _("giga"); - space_adjusted = truncf((float)rep.space / (1000.0 * 1000 * 1000.0)); + space_adjusted = floorf((float)rep.space / (1000.0 * 1000 * 1000.0)); } if (msg_delete) { @@ -3453,16 +3459,24 @@ ARDOUR_UI::start_video_server (Gtk::Window* float_window, bool popup_msg) std::string icsd_docroot = video_server_dialog->get_docroot(); if (icsd_docroot.empty()) {icsd_docroot = X_("/");} - struct stat sb; - if (!lstat (icsd_docroot.c_str(), &sb) == 0 || !S_ISDIR(sb.st_mode)) { + GStatBuf sb; + 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) +#ifndef PLATFORM_WINDOWS + 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*)); @@ -3498,7 +3512,7 @@ ARDOUR_UI::start_video_server (Gtk::Window* float_window, bool popup_msg) } int timeout = 120; // 6 sec while (!ARDOUR_UI::instance()->video_timeline->check_server()) { - usleep (50000); + Glib::usleep (50000); if (--timeout <= 0 || !video_server_process->is_running()) break; } if (timeout <= 0) { @@ -4126,7 +4140,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 78cc46efb5..1561a0102c 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -66,30 +66,37 @@ #include "video_timeline.h" +#include "about.h" #include "ardour_button.h" #include "ardour_dialog.h" #include "ardour_window.h" #include "editing.h" +#include "engine_dialog.h" #include "meterbridge.h" #include "ui_config.h" #include "enums.h" #include "visibility_group.h" #include "window_manager.h" -class About; -class AddRouteDialog; -class AddVideoDialog; +#include "add_route_dialog.h" +#include "add_video_dialog.h" +#include "big_clock_window.h" +#include "bundle_manager.h" +#include "global_port_matrix.h" +#include "keyeditor.h" +#include "location_ui.h" +#include "rc_option_editor.h" +#include "route_params_ui.h" +#include "session_option_editor.h" +#include "speaker_dialog.h" +#include "theme_manager.h" + class VideoTimeLine; class SystemExec; class ArdourKeyboard; class AudioClock; -class BigClockWindow; -class BundleManager; class ButtonJoiner; class ConnectionEditor; -class EngineControl; -class KeyEditor; -class LocationUIWindow; class MainClock; class Mixer_UI; class PublicEditor; @@ -99,13 +106,10 @@ class SessionDialog; class SessionOptionEditor; class ShuttleControl; class Splash; -class SpeakerDialog; -class ThemeManager; class TimeInfoBox; class MidiTracer; class NSM_Client; class LevelMeterHBox; -class GlobalPortMatrixWindow; class GUIObjectState; namespace Gtkmm2ext { @@ -721,7 +725,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/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index d127c40343..2cfa27cbb2 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" diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index b24d22f1b9..7bbc00c267 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -1131,7 +1131,7 @@ AudioClock::set_minsec (framepos_t when, bool /*force*/) mins = (int) floor (left / (_session->frame_rate() * 60.0f)); left -= (framecnt_t) floor (mins * _session->frame_rate() * 60.0f); secs = (int) floor (left / (float) _session->frame_rate()); - left -= (framecnt_t) floor (secs * _session->frame_rate()); + left -= (framecnt_t) floor ((double)(secs * _session->frame_rate())); millisecs = floor (left * 1000.0 / (float) _session->frame_rate()); if (negative) { @@ -1742,7 +1742,7 @@ AudioClock::on_motion_notify_event (GdkEventMotion *ev) drag_y = ev->y; - if (trunc (drag_accum) != 0) { + if (floor (drag_accum) != 0) { framepos_t frames; framepos_t pos; diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index 2aeb2dbe60..730cd99b37 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 PLATFORM_WINDOWS , _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 PLATFORM_WINDOWS + m_peak_sem.post (); +#else + _peak_channel.deliver ('c'); +#endif +} + +void +AudioRegionEditor::wait_for_signal () +{ +#ifdef PLATFORM_WINDOWS + 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 b72986ecf1..3fdecc1837 100644 --- a/gtk2_ardour/audio_region_editor.h +++ b/gtk2_ardour/audio_region_editor.h @@ -36,7 +36,11 @@ #include "pbd/signals.h" +#ifdef PLATFORM_WINDOWS +#include "pbd/glib_semaphore.h" +#else #include "pbd/crossthread.h" +#endif #include "audio_clock.h" #include "ardour_dialog.h" @@ -73,11 +77,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 PLATFORM_WINDOWS + PBD::GlibSemaphore m_peak_sem; +#else CrossThreadChannel _peak_channel; +#endif }; #endif /* __gtk_ardour_audio_region_edit_h__ */ diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index f95576cd3e..d8ec2abb3c 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -561,9 +562,9 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr ar, f uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth); double effective_height; - float curve[npoints]; + std::vector curve(npoints); - audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, curve, npoints); + audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, &curve[0], npoints); if (_height >= NAME_HIGHLIGHT_THRESH) { effective_height = _height - NAME_HIGHLIGHT_SIZE - 1; @@ -639,9 +640,9 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr ar, uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth); double effective_height; - float curve[npoints]; + std::vector curve(npoints); - audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, curve, npoints); + audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, &curve[0], npoints); if (_height >= NAME_HIGHLIGHT_THRESH) { effective_height = _height - (NAME_HIGHLIGHT_SIZE + 1); /* skip the top pixel that shows the frame of this regionview */ @@ -762,8 +763,8 @@ AudioRegionView::redraw_start_xfade_to (boost::shared_ptr ar, frame } else { - float vec[npoints]; - inverse->curve().get_vector (0, inverse->back()->when, vec, npoints); + std::vector vec(npoints); + inverse->curve().get_vector (0, inverse->back()->when, &vec[0], npoints); for (Points::size_type i = 0, pci = 0; i < npoints; ++i, ++pci) { ArdourCanvas::Duple &p (ipoints[pci]); @@ -1256,7 +1257,7 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev) } void -AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*ev*/) +AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent* /*ev*/) { ControlPoint *cp = reinterpret_cast (item->get_data ("control_point")); audio_region()->envelope()->erase (cp->model()); diff --git a/gtk2_ardour/audio_region_view.h b/gtk2_ardour/audio_region_view.h index e00c98d20f..ab3d59a235 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/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc index d22806a8c0..8ca04c7bdb 100644 --- a/gtk2_ardour/audio_time_axis.cc +++ b/gtk2_ardour/audio_time_axis.cc @@ -385,19 +385,19 @@ 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")))); set const & params = _route->pannable()->what_can_be_automated (); - for (set::iterator p = params.begin(); p != params.end(); ++p) { + for (set::const_iterator p = params.begin(); p != params.end(); ++p) { _main_automation_menu_map[*p] = pan_automation_item; } } diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index eee0689c35..2551b40c75 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -17,6 +17,17 @@ */ +#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 #include #include @@ -949,7 +960,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events) model_to_view_coord (tx, ty); - if (std::isnan (tx) || std::isnan (ty)) { + if (isnan (tx) || isnan (ty)) { warning << string_compose (_("Ignoring illegal points on AutomationLine \"%1\""), _name) << endmsg; continue; diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index bc91eafbd6..86f8034be3 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -489,22 +489,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)); @@ -524,13 +524,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/big_clock_window.cc b/gtk2_ardour/big_clock_window.cc index 5b369a68c1..c67ae38074 100644 --- a/gtk2_ardour/big_clock_window.cc +++ b/gtk2_ardour/big_clock_window.cc @@ -19,6 +19,7 @@ #include #include +#include #include "ardour_ui.h" #include "audio_clock.h" @@ -138,11 +139,11 @@ BigClockWindow::text_resizer (int, int) if (size != current_size) { string family = fd.get_family(); - char buf[family.length()+16]; - snprintf (buf, family.length()+16, "%s %d", family.c_str(), size); + std::vector buf(family.length()+16); + snprintf (&buf[0], family.length()+16, "%s %d", family.c_str(), size); try { - Pango::FontDescription fd (buf); + Pango::FontDescription fd (&buf[0]); Glib::RefPtr rcstyle = clock.get_modifier_style (); rcstyle->set_font (fd); clock.modify_style (rcstyle); 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); diff --git a/gtk2_ardour/canvas-waveview.c b/gtk2_ardour/canvas-waveview.c index 2080b208d8..6aff1be771 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(COMPILER_MINGW) #define POSIX_FUNC_PTR_CAST(type, object) *((type*) &(object)) #endif // _POSIX_VERSION diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index df9cdcf824..d0ad6d68d3 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -665,7 +665,7 @@ Editor::start_canvas_autoscroll (int dx, int dy) autoscroll_x = dx; autoscroll_y = dy; autoscroll_x_distance = (framepos_t) floor (current_page_samples()/50.0); - autoscroll_y_distance = fabs (dy * 5); /* pixels */ + autoscroll_y_distance = fabs ((double)dy * 5); /* pixels */ autoscroll_cnt = 0; /* do it right now, which will start the repeated callbacks */ diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index f1809ec2bb..1748c39736 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -1498,7 +1498,7 @@ RegionCreateDrag::motion (GdkEvent* event, bool first_move) place snapped notes at the start of the region. */ - framecnt_t const len = (framecnt_t) fabs (f - grab_frame () - 1); + framecnt_t const len = (framecnt_t) fabs ((double)(f - grab_frame () - 1)); _region->set_length (len < 1 ? 1 : len); } } @@ -4369,7 +4369,7 @@ NoteDrag::motion (GdkEvent *, bool) uint8_t new_note = min (max (_primary->note()->note() + note_delta, 0), 127); snprintf (buf, sizeof (buf), "%s (%d)", Evoral::midi_note_name (new_note).c_str(), - (int) floor (new_note)); + (int) floor ((double)new_note)); show_verbose_cursor_text (buf); } @@ -4873,7 +4873,7 @@ NoteCreateDrag::finished (GdkEvent*, bool had_movement) } framepos_t const start = min (_note[0], _note[1]); - framecnt_t length = (framecnt_t) fabs (_note[0] - _note[1]); + framecnt_t length = (framecnt_t) fabs ((double)(_note[0] - _note[1])); framecnt_t const g = grid_frames (start); double const one_tick = 1 / Timecode::BBT_Time::ticks_per_beat; 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_markers.cc b/gtk2_ardour/editor_markers.cc index 41010d317e..eb82a94f6b 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -860,14 +860,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/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 7b56dc920d..f299075170 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -3477,7 +3477,7 @@ Editor::freeze_route () /* wait for just a little while, because the above call is asynchronous */ - ::usleep (250000); + Glib::usleep (250000); if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) { return; diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 865a555c8a..132ae8eeb1 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -388,11 +388,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"))); @@ -400,7 +400,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)); } diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index 06823fda19..2528c823b7 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 PLATFORM_WINDOWS + Sleep(2000); +#else struct timespec t = { 2, 0 }; nanosleep (&t, 0); - +#endif return 0; } diff --git a/gtk2_ardour/editor_videotimeline.cc b/gtk2_ardour/editor_videotimeline.cc index 458393708a..1390aa440f 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" @@ -103,7 +105,7 @@ Editor::embed_audio_from_video (std::string path, framepos_t n, bool lock_positi } import_status.all_done = true; - unlink(path.c_str()); + ::g_unlink(path.c_str()); } void 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_dialog.cc b/gtk2_ardour/export_dialog.cc index 1458747786..6351c512c1 100644 --- a/gtk2_ardour/export_dialog.cc +++ b/gtk2_ardour/export_dialog.cc @@ -333,7 +333,7 @@ ExportDialog::show_progress () if (gtk_events_pending()) { gtk_main_iteration (); } else { - usleep (10000); + Glib::usleep (10000); } } 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.cc b/gtk2_ardour/export_timespan_selector.cc index f239ab194b..d6ca02fe03 100644 --- a/gtk2_ardour/export_timespan_selector.cc +++ b/gtk2_ardour/export_timespan_selector.cc @@ -50,7 +50,7 @@ ExportTimespanSelector::ExportTimespanSelector (ARDOUR::Session * session, Profi option_hbox.pack_start (time_format_label, false, false, 0); option_hbox.pack_start (time_format_combo, false, false, 6); - Gtk::Button* b = manage (new Gtk::Button (_("Select All"))); + Gtk::Button* b = Gtk::manage (new Gtk::Button (_("Select All"))); b->signal_clicked().connect ( sigc::bind ( sigc::mem_fun (*this, &ExportTimespanSelector::set_selection_state_of_all_timespans), true @@ -58,7 +58,7 @@ ExportTimespanSelector::ExportTimespanSelector (ARDOUR::Session * session, Profi ); option_hbox.pack_start (*b, false, false, 6); - b = manage (new Gtk::Button (_("Deselect All"))); + b = Gtk::manage (new Gtk::Button (_("Deselect All"))); b->signal_clicked().connect ( sigc::bind ( sigc::mem_fun (*this, &ExportTimespanSelector::set_selection_state_of_all_timespans), false @@ -305,7 +305,7 @@ ExportTimespanSelector::ms_str (framecnt_t frames) const mins = (int) floor (left / (_session->frame_rate() * 60.0f)); left -= (framecnt_t) floor (mins * _session->frame_rate() * 60.0f); secs = (int) floor (left / (float) _session->frame_rate()); - left -= (framecnt_t) floor (secs * _session->frame_rate()); + left -= (framecnt_t) floor ((double)(secs * _session->frame_rate())); sec_promilles = (int) (left * 1000 / (float) _session->frame_rate() + 0.5); oss << std::setfill('0') << std::right << 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/export_video_dialog.cc b/gtk2_ardour/export_video_dialog.cc index 2f9df2fb1c..a9d0f99ad1 100644 --- a/gtk2_ardour/export_video_dialog.cc +++ b/gtk2_ardour/export_video_dialog.cc @@ -29,6 +29,8 @@ #include +#include + #include "pbd/error.h" #include "pbd/convert.h" #include "gtkmm2ext/utils.h" @@ -414,8 +416,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; @@ -425,9 +427,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); } } @@ -570,13 +572,13 @@ ExportVideoDialog::launch_export () if (gtk_events_pending()) { gtk_main_iteration (); } else { - usleep (10000); + Glib::usleep (10000); } } audio_progress_connection.disconnect(); status->finish (); if (status->aborted()) { - unlink (insnd.c_str()); + ::g_unlink (insnd.c_str()); Gtk::Dialog::response(RESPONSE_CANCEL); return; } @@ -593,14 +595,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; } @@ -698,7 +700,7 @@ ExportVideoDialog::encode_pass (int pass) ffs["-an"] = "-y"; ffs["-passlogfile"] = Glib::path_get_dirname (outfn) + G_DIR_SEPARATOR + "ffmpeg2pass"; ffs["-f"] = get_file_extension(invid).empty()?"mov":get_file_extension(invid); -#ifdef _OS_WIN32 +#ifdef PLATFORM_WINDOWS outfn = "NUL"; #else outfn = "/dev/null"; 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/fft_graph.cc b/gtk2_ardour/fft_graph.cc index 2b0b32a28a..1edd483dab 100644 --- a/gtk2_ardour/fft_graph.cc +++ b/gtk2_ardour/fft_graph.cc @@ -17,6 +17,11 @@ */ +#ifdef COMPILER_MSVC +#include +using std::min; using std::max; +#endif + #include #include @@ -287,8 +292,8 @@ FFTGraph::redraw() // Find "session wide" min & max - float min = 1000000000000.0; - float max = -1000000000000.0; + float minf = 1000000000000.0; + float maxf = -1000000000000.0; TreeNodeChildren track_rows = _a_window->track_list.get_model()->children(); @@ -302,18 +307,18 @@ FFTGraph::redraw() continue; } - if ( res->minimum() < min) { - min = res->minimum(); + if ( res->minimum() < minf) { + minf = res->minimum(); } - if ( res->maximum() > max) { - max = res->maximum(); + if ( res->maximum() > maxf) { + maxf = res->maximum(); } } if (!_show_normalized) { - min = -150.0f; - max = 0.0f; + minf = -150.0f; + maxf = 0.0f; } //int graph_height = height - 2 * h_margin; @@ -323,7 +328,7 @@ FFTGraph::redraw() float fft_pane_size_w = (float)(width - 2*v_margin) - 1.0; float fft_pane_size_h = (float)(height - 2*h_margin); - double pixels_per_db = (double)fft_pane_size_h / (double)(max - min); + double pixels_per_db = (double)fft_pane_size_h / (double)(maxf - minf); cairo_rectangle(cr, 0.0, 0.0, fft_pane_size_w, fft_pane_size_h); cairo_clip(cr); @@ -350,14 +355,14 @@ FFTGraph::redraw() mpp = -1000000.0; cairo_set_source_rgba(cr, res->get_color().get_red_p(), res->get_color().get_green_p(), res->get_color().get_blue_p(), 0.30); - cairo_move_to(cr, 0.5f + (float)_logScale[0], 0.5f + (float)( fft_pane_size_h - (int)floor( (res->maxAt(0) - min) * pixels_per_db) )); + cairo_move_to(cr, 0.5f + (float)_logScale[0], 0.5f + (float)( fft_pane_size_h - (int)floor( (res->maxAt(0) - minf) * pixels_per_db) )); // Draw the line of maximum values for (int x = 1; x < res->length(); x++) { if (res->maxAt(x) > mpp) mpp = res->maxAt(x); - mpp = fmax(mpp, min); - mpp = fmin(mpp, max); + mpp = fmax(mpp, minf); + mpp = fmin(mpp, maxf); // If the next point on the log scale is at the same location, // don't draw yet @@ -366,7 +371,7 @@ FFTGraph::redraw() } float X = 0.5f + (float)_logScale[x]; - float Y = 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - min) * pixels_per_db) ); + float Y = 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - minf) * pixels_per_db) ); cairo_line_to(cr, X, Y); @@ -378,8 +383,8 @@ FFTGraph::redraw() for (int x = res->length()-1; x >= 0; x--) { if (res->minAt(x) < mpp) mpp = res->minAt(x); - mpp = fmax(mpp, min); - mpp = fmin(mpp, max); + mpp = fmax(mpp, minf); + mpp = fmin(mpp, maxf); // If the next point on the log scale is at the same location, // don't draw yet @@ -388,7 +393,7 @@ FFTGraph::redraw() } float X = 0.5f + (float)_logScale[x]; - float Y = 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - min) * pixels_per_db) ); + float Y = 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - minf) * pixels_per_db) ); cairo_line_to(cr, X, Y ); @@ -414,8 +419,8 @@ FFTGraph::redraw() if (res->avgAt(x) > mpp) mpp = res->avgAt(x); - mpp = fmax(mpp, min); - mpp = fmin(mpp, max); + mpp = fmax(mpp, minf); + mpp = fmin(mpp, maxf); // If the next point on the log scale is at the same location, // don't draw yet @@ -423,7 +428,7 @@ FFTGraph::redraw() continue; } - cairo_line_to(cr, 0.5f + (float)_logScale[x], 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - min) * pixels_per_db) )); + cairo_line_to(cr, 0.5f + (float)_logScale[x], 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - minf) * pixels_per_db) )); mpp = -1000000.0; } diff --git a/gtk2_ardour/fft_result.cc b/gtk2_ardour/fft_result.cc index 37c045b7b0..a83b65e854 100644 --- a/gtk2_ardour/fft_result.cc +++ b/gtk2_ardour/fft_result.cc @@ -18,8 +18,8 @@ */ -#include -#include +#include "fft_result.h" +#include "fft_graph.h" #include #include #include diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index ef29c01d46..faec8fb4ae 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include "pbd/stl_delete.h" #include "pbd/xml++.h" @@ -41,8 +42,6 @@ #include "ardour/plugin_insert.h" #include "ardour/session.h" -#include - #include "ardour_ui.h" #include "prompter.h" #include "plugin_ui.h" @@ -311,9 +310,9 @@ GenericPluginUI::build () // are similar enough to be grouped together. string label, previous_label = ""; - int numbers_in_labels[cui_controls_list.size()]; + std::vector numbers_in_labels(cui_controls_list.size()); - float similarity_scores[cui_controls_list.size()]; + std::vector similarity_scores(cui_controls_list.size()); float most_similar = 0.0, least_similar = 1.0; i = 0; diff --git a/gtk2_ardour/global_port_matrix.cc b/gtk2_ardour/global_port_matrix.cc index 80e2616bd8..218cfe7a1c 100644 --- a/gtk2_ardour/global_port_matrix.cc +++ b/gtk2_ardour/global_port_matrix.cc @@ -48,7 +48,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 (); } @@ -59,8 +59,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) { @@ -103,8 +103,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, }; }; diff --git a/gtk2_ardour/gtk-custom-hruler.c b/gtk2_ardour/gtk-custom-hruler.c index a3745ba691..5f17ffe583 100644 --- a/gtk2_ardour/gtk-custom-hruler.c +++ b/gtk2_ardour/gtk-custom-hruler.c @@ -64,7 +64,7 @@ GType gtk_custom_hruler_get_type (void) }; hruler_type = g_type_register_static (gtk_custom_ruler_get_type(), "GtkCustomHRuler", - &hruler_info, 0); + &hruler_info, (GTypeFlags)0); } return hruler_type; diff --git a/gtk2_ardour/gtk-custom-ruler.c b/gtk2_ardour/gtk-custom-ruler.c index 797922f563..16097faa2e 100644 --- a/gtk2_ardour/gtk-custom-ruler.c +++ b/gtk2_ardour/gtk-custom-ruler.c @@ -98,7 +98,7 @@ GType gtk_custom_ruler_get_type (void) }; ruler_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkCustomRuler", - &ruler_info, 0); + &ruler_info, (GTypeFlags)0); } return ruler_type; @@ -198,9 +198,8 @@ gtk_custom_ruler_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - (void) pspec; - GtkCustomRuler *ruler = GTK_CUSTOM_RULER (object); + (void) pspec; switch (prop_id) { diff --git a/gtk2_ardour/gtk_pianokeyboard.c b/gtk2_ardour/gtk_pianokeyboard.c index 34bf184249..8d91626a2b 100644 --- a/gtk2_ardour/gtk_pianokeyboard.c +++ b/gtk2_ardour/gtk_pianokeyboard.c @@ -244,7 +244,7 @@ bind_key(PianoKeyboard *pk, const char *key, int note) { assert(pk->key_bindings != NULL); - g_hash_table_insert(pk->key_bindings, key, (gpointer)((intptr_t)note)); + g_hash_table_insert(pk->key_bindings, (const gpointer)key, (gpointer)((intptr_t)note)); } static void @@ -610,15 +610,15 @@ piano_keyboard_class_init(PianoKeyboardClass *klass) /* Set up signals. */ piano_keyboard_signals[NOTE_ON_SIGNAL] = g_signal_new ("note-on", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_TYPE_FROM_CLASS (klass), (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); piano_keyboard_signals[NOTE_OFF_SIGNAL] = g_signal_new ("note-off", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_TYPE_FROM_CLASS (klass), (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); piano_keyboard_signals[REST_SIGNAL] = g_signal_new ("rest", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_TYPE_FROM_CLASS (klass), (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION), 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); widget_klass = (GtkWidgetClass*) klass; @@ -659,7 +659,7 @@ piano_keyboard_get_type(void) 0, /* value_table */ }; - mk_type = g_type_register_static(GTK_TYPE_DRAWING_AREA, "PianoKeyboard", &mk_info, 0); + mk_type = g_type_register_static(GTK_TYPE_DRAWING_AREA, "PianoKeyboard", &mk_info, (GTypeFlags)0); } return mk_type; @@ -668,7 +668,7 @@ piano_keyboard_get_type(void) GtkWidget * piano_keyboard_new(void) { - GtkWidget *widget = gtk_type_new(piano_keyboard_get_type()); + GtkWidget *widget = (GtkWidget*)gtk_type_new(piano_keyboard_get_type()); PianoKeyboard *pk = PIANO_KEYBOARD(widget); diff --git a/gtk2_ardour/hit.cc b/gtk2_ardour/hit.cc index 257a3cd4f0..4d2498a0d5 100644 --- a/gtk2_ardour/hit.cc +++ b/gtk2_ardour/hit.cc @@ -35,7 +35,7 @@ Hit::Hit ( bool with_events) : NoteBase (region, with_events, note) { - _polygon = new Polygon (group); + _polygon = new ArdourCanvas::Polygon (group); set_item (_polygon); } diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index d01bca2a62..de56b1e387 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" @@ -101,7 +102,7 @@ gui_jack_error () 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; @@ -112,7 +113,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__ @@ -125,7 +126,7 @@ extern void set_language_preference (); // cocoacarbon.mm void fixup_bundle_environment (int, char* []) { - if (!getenv ("ARDOUR_BUNDLED")) { + if (!g_getenv ("ARDOUR_BUNDLED")) { return; } @@ -180,7 +181,7 @@ fixup_bundle_environment (int, char* []) /* 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, @@ -205,13 +206,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() { @@ -249,7 +250,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) * acceptable to build paths directly using '/'. */ - if (!getenv ("ARDOUR_BUNDLED")) { + if (!g_getenv ("ARDOUR_BUNDLED")) { return; } @@ -268,7 +269,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 @@ -290,15 +291,15 @@ fixup_bundle_environment (int /*argc*/, char* argv[]) /* 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; } @@ -327,19 +328,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); } @@ -460,7 +461,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 @@ -505,9 +506,11 @@ int main (int argc, char *argv[]) return curvetest (curvetest_file); } +#ifndef PLATFORM_WINDOWS if (::signal (SIGPIPE, sigpipe_handler)) { cerr << _("Cannot xinstall SIGPIPE error handler") << endl; } +#endif try { ui = new ARDOUR_UI (&argc, &argv, localedir); 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/meter_patterns.cc b/gtk2_ardour/meter_patterns.cc index 7db2924697..2fa1d73565 100644 --- a/gtk2_ardour/meter_patterns.cc +++ b/gtk2_ardour/meter_patterns.cc @@ -885,7 +885,7 @@ meter_render_metrics (Gtk::Widget& w, MeterType type, vector types) case DataType::MIDI: align_center = false; // don't bleed into legend fraction = (j->first) / 127.0; - pos = 1 + height - (gint) rintf (height * fraction); + pos = 1 + height - (gint) lrintf (height * fraction); pos = min (pos, height); cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p()); if (tickleft) { 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); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index ffd09b76a8..afae96bf22 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -3080,7 +3080,7 @@ MidiRegionView::nudge_notes (bool forward) return; } - Evoral::MusicalTime delta = region_frames_to_region_beats (fabs (distance)); + Evoral::MusicalTime delta = region_frames_to_region_beats (fabs ((double)distance)); if (!forward) { delta = -delta; @@ -3298,7 +3298,7 @@ MidiRegionView::selection_as_cut_buffer () const { Notes notes; - for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { + for (Selection::const_iterator i = _selection.begin(); i != _selection.end(); ++i) { NoteType* n = (*i)->note().get(); notes.insert (boost::shared_ptr (new NoteType (*n))); } diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 002efb9910..4884dc34f3 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" @@ -663,7 +662,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); } @@ -695,7 +694,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); @@ -737,7 +736,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); @@ -793,7 +792,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); } @@ -1489,7 +1488,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; } } @@ -1505,7 +1504,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/gtk2_ardour/midi_tracer.cc b/gtk2_ardour/midi_tracer.cc index ea4b0c2d54..a92c5a57e3 100644 --- a/gtk2_ardour/midi_tracer.cc +++ b/gtk2_ardour/midi_tracer.cc @@ -23,6 +23,9 @@ #include #include +#include "pbd/localtime_r.h" +#include "pbd/timersub.h" + #include "midi++/parser.h" #include "ardour/async_midi_port.h" @@ -212,7 +215,7 @@ MidiTracer::tracer (Parser&, byte* msg, size_t len) s = snprintf (buf, bufsize, "+%02" PRId64 ":%06" PRId64, (int64_t) delta.tv_sec, (int64_t) delta.tv_usec); bufsize -= s; } else { - localtime_r (&tv.tv_sec, &now); + localtime_r ((const time_t*)&tv.tv_sec, &now); s = strftime (buf, bufsize, "%H:%M:%S", &now); bufsize -= s; s += snprintf (&buf[s], bufsize, ".%06" PRId64, (int64_t) tv.tv_usec); diff --git a/gtk2_ardour/missing_file_dialog.cc b/gtk2_ardour/missing_file_dialog.cc index c7cb7f5edc..37868d5572 100644 --- a/gtk2_ardour/missing_file_dialog.cc +++ b/gtk2_ardour/missing_file_dialog.cc @@ -19,6 +19,7 @@ #include "pbd/compose.h" #include "pbd/replace_all.h" #include "pbd/strsplit.h" +#include "pbd/search_path.h" #include "ardour/session.h" @@ -56,14 +57,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/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index e7c3f138b8..a0f9f24198 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -1522,7 +1522,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)); @@ -1532,7 +1532,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/note.cc b/gtk2_ardour/note.cc index 23358130a0..c9a60a7de9 100644 --- a/gtk2_ardour/note.cc +++ b/gtk2_ardour/note.cc @@ -35,8 +35,10 @@ Note::Note ( ) : NoteBase (region, with_events, note) { - _rectangle = new Rectangle (group); + _rectangle = new ArdourCanvas::Rectangle (group); +#ifdef CANVAS_DEBUG _rectangle->name = "note"; +#endif set_item (_rectangle); } diff --git a/gtk2_ardour/nsmclient.cc b/gtk2_ardour/nsmclient.cc index 76e18bc629..94c3e8570e 100644 --- a/gtk2_ardour/nsmclient.cc +++ b/gtk2_ardour/nsmclient.cc @@ -23,7 +23,11 @@ #include #include +#ifndef COMPILER_MSVC #pragma GCC diagnostic ignored "-Wunused-parameter" +#else +#include // Needed for 'getpid()' +#endif namespace NSM { diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h index 2073da530d..47afa77868 100644 --- a/gtk2_ardour/option_editor.h +++ b/gtk2_ardour/option_editor.h @@ -227,9 +227,9 @@ public: _get (g), _set (s) { - _label = manage (new Gtk::Label (n + ":")); + _label = Gtk::manage (new Gtk::Label (n + ":")); _label->set_alignment (0, 0.5); - _combo = manage (new Gtk::ComboBoxText); + _combo = Gtk::manage (new Gtk::ComboBoxText); _combo->signal_changed().connect (sigc::mem_fun (*this, &ComboOption::changed)); } @@ -305,9 +305,9 @@ public: ) : Option (i, n) { - _label = manage (new Gtk::Label (n + ":")); + _label = Gtk::manage (new Gtk::Label (n + ":")); _label->set_alignment (0, 0.5); - _hscale = manage (new Gtk::HScale(adj)); + _hscale = Gtk::manage (new Gtk::HScale(adj)); _adj = NULL; } @@ -323,9 +323,9 @@ public: , _set (s) , _adj (adj) { - _label = manage (new Gtk::Label (n + ":")); + _label = Gtk::manage (new Gtk::Label (n + ":")); _label->set_alignment (0, 0.5); - _hscale = manage (new Gtk::HScale(*_adj)); + _hscale = Gtk::manage (new Gtk::HScale(*_adj)); _adj->signal_value_changed().connect (sigc::mem_fun (*this, &HSliderOption::changed)); } @@ -379,9 +379,9 @@ public: _get (g), _set (s) { - _label = manage (new Gtk::Label (n + ":")); + _label = Gtk::manage (new Gtk::Label (n + ":")); _label->set_alignment (0, 0.5); - _combo = manage (new Gtk::ComboBoxText); + _combo = Gtk::manage (new Gtk::ComboBoxText); _combo->signal_changed().connect (sigc::mem_fun (*this, &ComboStringOption::changed)); } @@ -493,18 +493,18 @@ public: _set (s), _scale (scale) { - _label = manage (new Gtk::Label (n + ":")); + _label = Gtk::manage (new Gtk::Label (n + ":")); _label->set_alignment (0, 0.5); - _spin = manage (new Gtk::SpinButton); + _spin = Gtk::manage (new Gtk::SpinButton); _spin->set_range (min, max); _spin->set_increments (step, page); - _box = manage (new Gtk::HBox); + _box = Gtk::manage (new Gtk::HBox); _box->pack_start (*_spin, true, true); _box->set_spacing (4); if (unit.length()) { - _box->pack_start (*manage (new Gtk::Label (unit)), false, false); + _box->pack_start (*Gtk::manage (new Gtk::Label (unit)), false, false); } _spin->signal_value_changed().connect (sigc::mem_fun (*this, &SpinOption::changed)); 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 */ diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index 3ee794e578..ce2f0aec83 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -369,7 +369,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/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); diff --git a/gtk2_ardour/pingback.cc b/gtk2_ardour/pingback.cc index dea7f52f01..62d9191daf 100644 --- a/gtk2_ardour/pingback.cc +++ b/gtk2_ardour/pingback.cc @@ -23,7 +23,10 @@ #include #include +#ifndef PLATFORM_WINDOWS #include +#endif + #include #include @@ -70,6 +73,7 @@ struct ping_call { static void* _pingback (void *arg) { +#ifndef PLATFORM_WINDOWS 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 /* PLATFORM_WINDOWS */ + return 0; } diff --git a/gtk2_ardour/plugin_eq_gui.cc b/gtk2_ardour/plugin_eq_gui.cc index 631fb7be71..4bf2a5f879 100644 --- a/gtk2_ardour/plugin_eq_gui.cc +++ b/gtk2_ardour/plugin_eq_gui.cc @@ -18,6 +18,17 @@ */ +#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 "plugin_eq_gui.h" #include "fft.h" @@ -765,13 +776,13 @@ PluginEqGui::plot_signal_amplitude_difference(Gtk::Widget *w, cairo_t *cr) } */ - if (std::isinf(power)) { + if (isinf(power)) { if (power < 0) { power = _min_dB - 1.0; } else { power = _max_dB - 1.0; } - } else if (std::isnan(power)) { + } else if (isnan(power)) { power = _min_dB - 1.0; } diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc index bb96c7f392..f11753819a 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 3f523a82d2..4423e3905d 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -57,8 +57,6 @@ #include "lv2_plugin_ui.h" #endif -#include - #include "ardour_window.h" #include "ardour_ui.h" #include "prompter.h" diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 35e9a5cbd3..6bd9d96262 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -527,7 +527,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 cd91589391..605fbbc25f 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -440,7 +440,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/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 815c7f4e7e..7c5d9a7763 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -529,7 +529,7 @@ public: _dpi_adjustment (50, 50, 250, 1, 10), _dpi_slider (_dpi_adjustment) { - _dpi_adjustment.set_value (floor (_rc_config->get_font_scale () / 1024)); + _dpi_adjustment.set_value (floor ((double)(_rc_config->get_font_scale () / 1024))); Label* l = manage (new Label (_("Font scaling:"))); l->set_name ("OptionsLabel"); @@ -548,7 +548,7 @@ public: void parameter_changed (string const & p) { if (p == "font-scale") { - _dpi_adjustment.set_value (floor (_rc_config->get_font_scale() / 1024)); + _dpi_adjustment.set_value (floor ((double)(_rc_config->get_font_scale() / 1024))); } } diff --git a/gtk2_ardour/rc_option_editor.h b/gtk2_ardour/rc_option_editor.h index 7b9b29c3ff..879a9c4464 100644 --- a/gtk2_ardour/rc_option_editor.h +++ b/gtk2_ardour/rc_option_editor.h @@ -17,6 +17,9 @@ */ +#ifndef __gtk_ardour_rc_option_editor_h__ +#define __gtk_ardour_rc_option_editor_h__ + #include "option_editor.h" #include "visibility_group.h" @@ -54,3 +57,5 @@ private: PBD::ScopedConnection parameter_change_connection; }; + +#endif /* __gtk_ardour_rc_option_editor_h__ */ diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index 16df6be245..a5d5fddbd0 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/return_ui.cc b/gtk2_ardour/return_ui.cc index 92846af469..775f283947 100644 --- a/gtk2_ardour/return_ui.cc +++ b/gtk2_ardour/return_ui.cc @@ -49,7 +49,7 @@ ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr r, Session* s _vbox.pack_start (_hbox, false, false, false); - io = manage (new IOSelector (parent, session, r->output())); + io = Gtk::manage (new IOSelector (parent, session, r->output())); pack_start (_vbox, false, false); diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index cdf844b3d9..715eec53b4 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -698,7 +698,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); @@ -2028,12 +2028,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 ad5e3bfd94..424e59aee4 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -784,7 +784,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); @@ -1206,20 +1206,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()); @@ -1237,25 +1237,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)); @@ -1268,7 +1268,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); } @@ -1957,7 +1957,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; diff --git a/gtk2_ardour/send_ui.cc b/gtk2_ardour/send_ui.cc index 1fead73084..b10bd96ea9 100644 --- a/gtk2_ardour/send_ui.cc +++ b/gtk2_ardour/send_ui.cc @@ -57,7 +57,7 @@ SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr s, Session* session // users (among others) // _vbox.pack_start (_panners, false, false); - io = manage (new IOSelector (parent, session, s->output())); + io = Gtk::manage (new IOSelector (parent, session, s->output())); pack_start (_vbox, false, false); diff --git a/gtk2_ardour/session_metadata_dialog.h b/gtk2_ardour/session_metadata_dialog.h index 9aa62ed4ca..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 @@ -82,7 +86,7 @@ class TextMetadataField : public MetadataField { Gtk::Label* value_label; Gtk::Entry* entry; - uint width; + guint width; }; /// MetadataField that accepts only numbers diff --git a/gtk2_ardour/session_option_editor.h b/gtk2_ardour/session_option_editor.h index 73b9b2b033..2e7ba192b6 100644 --- a/gtk2_ardour/session_option_editor.h +++ b/gtk2_ardour/session_option_editor.h @@ -17,6 +17,9 @@ */ +#ifndef __gtk_ardour_session_option_editor_h__ +#define __gtk_ardour_session_option_editor_h__ + #include "option_editor.h" namespace ARDOUR { @@ -39,3 +42,5 @@ private: ComboOption* _vpu; }; + +#endif /* __gtk_ardour_session_option_editor_h__ */ diff --git a/gtk2_ardour/sfdb_freesound_mootcher.cc b/gtk2_ardour/sfdb_freesound_mootcher.cc index 8e57d9a0c4..e1501460ca 100644 --- a/gtk2_ardour/sfdb_freesound_mootcher.cc +++ b/gtk2_ardour/sfdb_freesound_mootcher.cc @@ -91,7 +91,7 @@ void Mootcher::ensureWorkingDir () } } basePath = p; -#ifdef __WIN32__ +#ifdef PLATFORM_WINDOWS std::string replace = "/"; size_t pos = basePath.find("\\"); while( pos != std::string::npos ){ diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 9b3d78e86d..54e8ea98ab 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" @@ -1457,6 +1459,9 @@ SoundFileOmega::check_info (const vector& paths, bool& same_size, bool& bool SoundFileOmega::check_link_status (const Session* s, const vector& paths) { +#ifdef PLATFORM_WINDOWS + return false; +#else std::string tmpdir(Glib::build_filename (s->session_directory().sound_path(), "linktest")); bool ret = false; @@ -1478,7 +1483,7 @@ SoundFileOmega::check_link_status (const Session* s, const vector& paths goto out; } - unlink (tmpc); + ::g_unlink (tmpc); } ret = true; @@ -1486,6 +1491,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) diff --git a/gtk2_ardour/system_exec.cc b/gtk2_ardour/system_exec.cc index 59f3647e51..1a8399d22e 100644 --- a/gtk2_ardour/system_exec.cc +++ b/gtk2_ardour/system_exec.cc @@ -25,9 +25,12 @@ #include #include -#include -#ifdef __WIN32__ +#ifndef COMPILER_MSVC +#include +#endif + +#ifdef PLATFORM_WINDOWS #include #else #include @@ -47,7 +50,7 @@ void * interposer_thread (void *arg); static void close_fd (int& fd) { if (fd >= 0) ::close (fd); fd = -1; } -#ifndef __WIN32__ +#ifndef PLATFORM_WINDOWS /* * This function was part of libasyncns. * LGPL v2.1 @@ -155,7 +158,7 @@ SystemExec::SystemExec (std::string c, std::string a) nicelevel = 0; envp = NULL; argp = NULL; -#ifdef __WIN32__ +#ifdef PLATFORM_WINDOWS stdinP[0] = stdinP[1] = INVALID_HANDLE_VALUE; stdoutP[0] = stdoutP[1] = INVALID_HANDLE_VALUE; stderrP[0] = stderrP[1] = INVALID_HANDLE_VALUE; @@ -173,7 +176,7 @@ SystemExec::SystemExec (std::string c, char **a) pin[1] = -1; nicelevel = 0; envp = NULL; -#ifdef __WIN32__ +#ifdef PLATFORM_WINDOWS stdinP[0] = stdinP[1] = INVALID_HANDLE_VALUE; stdoutP[0] = stdoutP[1] = INVALID_HANDLE_VALUE; stderrP[0] = stderrP[1] = INVALID_HANDLE_VALUE; @@ -197,7 +200,7 @@ SystemExec::~SystemExec () } free (argp); } -#ifdef __WIN32__ +#ifdef PLATFORM_WINDOWS if (w_args) free(w_args); #endif pthread_mutex_destroy(&write_lock); @@ -211,7 +214,7 @@ interposer_thread (void *arg) { return 0; } -#ifdef __WIN32__ /* Windows Process */ +#ifdef PLATFORM_WINDOWS /* Windows Process */ /* HELPER FUNCTIONS */ diff --git a/gtk2_ardour/system_exec.h b/gtk2_ardour/system_exec.h index cf8518f547..38589bb26f 100644 --- a/gtk2_ardour/system_exec.h +++ b/gtk2_ardour/system_exec.h @@ -177,7 +177,7 @@ class SystemExec char **envp; private: -#ifdef __WIN32__ +#ifdef PLATFORM_WINDOWS PROCESS_INFORMATION *pid; HANDLE stdinP[2]; HANDLE stdoutP[2]; diff --git a/gtk2_ardour/transcode_ffmpeg.cc b/gtk2_ardour/transcode_ffmpeg.cc index ea753104db..0a622cb690 100644 --- a/gtk2_ardour/transcode_ffmpeg.cc +++ b/gtk2_ardour/transcode_ffmpeg.cc @@ -51,7 +51,7 @@ TranscodeFfmpeg::TranscodeFfmpeg (std::string f) #endif std::string ff_file_path; - if (find_file_in_search_path (SearchPath(Glib::getenv("PATH")), X_("ffmpeg_harvid"), ff_file_path)) { ffmpeg_exe = ff_file_path; } + if (find_file_in_search_path (Searchpath(Glib::getenv("PATH")), X_("ffmpeg_harvid"), ff_file_path)) { ffmpeg_exe = ff_file_path; } else if (Glib::file_test(X_("C:\\Program Files\\harvid\\ffmpeg.exe"), Glib::FILE_TEST_EXISTS)) { ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe"); } @@ -59,7 +59,7 @@ TranscodeFfmpeg::TranscodeFfmpeg (std::string f) ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe"); } - if (find_file_in_search_path (SearchPath(Glib::getenv("PATH")), X_("ffprobe_harvid"), ff_file_path)) { ffprobe_exe = ff_file_path; } + if (find_file_in_search_path (Searchpath(Glib::getenv("PATH")), X_("ffprobe_harvid"), ff_file_path)) { ffprobe_exe = ff_file_path; } else if (Glib::file_test(X_("C:\\Program Files\\harvid\\ffprobe.exe"), Glib::FILE_TEST_EXISTS)) { ffprobe_exe = X_("C:\\Program Files\\ffmpeg\\ffprobe.exe"); } @@ -124,7 +124,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; @@ -192,7 +192,7 @@ TranscodeFfmpeg::probe () h * 3600.0 + m * 60.0 + s * 1.0 - + atoi(f) / pow(10, strlen(f)) + + atoi(f) / pow((double)10, (int)strlen(f)) )); } } else if (key == X_("duration_ts") && m_fps == 0 && timebase !=0 ) { @@ -505,7 +505,11 @@ TranscodeFfmpeg::cancel () { if (!ffcmd || !ffcmd->is_running()) { return;} ffcmd->write_to_stdin("q"); +#ifdef PLATFORM_WINDOWS + Sleep(1000); +#else sleep (1); +#endif if (ffcmd) { ffcmd->terminate(); } @@ -539,7 +543,7 @@ TranscodeFfmpeg::ffmpegparse_a (std::string d, size_t /* s */) h * 3600.0 + m * 60.0 + s * 1.0 - + atoi(f) / pow(10, strlen(f)) + + atoi(f) / pow((double)10, (int)strlen(f)) )); p = p * m_fps / 100.0; if (p > m_duration ) { p = m_duration; } diff --git a/gtk2_ardour/transcode_video_dialog.cc b/gtk2_ardour/transcode_video_dialog.cc index 6e4a1a3298..3963bb6cd3 100644 --- a/gtk2_ardour/transcode_video_dialog.cc +++ b/gtk2_ardour/transcode_video_dialog.cc @@ -29,6 +29,8 @@ #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/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index 7cb1953390..215df25e7f 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -287,7 +287,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 e6dc2c5790..777eb62616 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -568,7 +568,7 @@ get_xpm (std::string name) { if (!xpm_map[name]) { - SearchPath spath(ARDOUR::ardour_data_search_path()); + Searchpath spath(ARDOUR::ardour_data_search_path()); spath.add_subdirectory_to_paths("pixmaps"); @@ -594,7 +594,7 @@ get_icon_path (const char* cname) string name = cname; name += X_(".png"); - SearchPath spath(ARDOUR::ardour_data_search_path()); + Searchpath spath(ARDOUR::ardour_data_search_path()); spath.add_subdirectory_to_paths("icons"); @@ -741,7 +741,9 @@ set_pango_fontsize () /* FT2 rendering - used by GnomeCanvas, sigh */ +#ifndef PLATFORM_WINDOWS pango_ft2_font_map_set_resolution ((PangoFT2FontMap*) pango_ft2_font_map_new(), val/1024, val/1024); +#endif /* Cairo rendering, in case there is any */ diff --git a/gtk2_ardour/video_image_frame.cc b/gtk2_ardour/video_image_frame.cc index e5cd197782..ebcb9e6f96 100644 --- a/gtk2_ardour/video_image_frame.cc +++ b/gtk2_ardour/video_image_frame.cc @@ -211,7 +211,7 @@ http_get_thread (void *arg) { char *res = NULL; do { res=a3_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) { @@ -250,8 +250,8 @@ VideoImageFrame::http_download_done (char *data){ } exposeimg(); - /* don't request frames rapidly, wait after user has zoomed */ - usleep(20000); + /* don't request frames too quickly, wait after user has zoomed */ + Glib::usleep(40000); if (queued_request) { http_get_again(want_video_frame_number); diff --git a/gtk2_ardour/video_monitor.cc b/gtk2_ardour/video_monitor.cc index 238845fb2f..c04d9bde35 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) { diff --git a/gtk2_ardour/video_server_dialog.cc b/gtk2_ardour/video_server_dialog.cc index 18a4d21dc9..bc9e8be442 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" @@ -80,7 +84,7 @@ VideoServerDialog::VideoServerDialog (Session* s) listenaddr_combo.set_active(0); std::string icsd_file_path; - if (find_file_in_search_path (PBD::SearchPath(Glib::getenv("PATH")), X_("harvid"), icsd_file_path)) { + if (find_file_in_search_path (PBD::Searchpath(Glib::getenv("PATH")), X_("harvid"), icsd_file_path)) { path_entry.set_text(icsd_file_path); } else if (Glib::file_test(X_("C:\\Program Files\\harvid\\harvid.exe"), Glib::FILE_TEST_EXISTS)) { diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index a1a85a0243..536d57afe6 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -347,17 +347,17 @@ VideoTimeLine::update_video_timeline() assert (vtl_dist > 0); assert (apv > 0); - leftmost_video_frame = floor (floor((leftmost_sample - video_start_offset - video_offset ) / vtl_dist) * vtl_dist / apv); + leftmost_video_frame = floor (floor((long double)(leftmost_sample - video_start_offset - video_offset ) / vtl_dist) * vtl_dist / apv); vtl_start = rint (video_offset + video_start_offset + leftmost_video_frame * apv); - visible_video_frames = 2 + ceil(editor->current_page_samples() / vtl_dist); /* +2 left+right partial frames */ + visible_video_frames = 2 + ceil((double)editor->current_page_samples() / vtl_dist); /* +2 left+right partial frames */ /* expand timeline (cache next/prev page images) */ vtl_start -= visible_video_frames * vtl_dist; visible_video_frames *=3; if (vtl_start < video_offset ) { - visible_video_frames += ceil(vtl_start/vtl_dist); + visible_video_frames += ceil((double)vtl_start/vtl_dist); vtl_start = video_offset; } @@ -717,7 +717,7 @@ VideoTimeLine::find_xjadeo () { std::string xjadeo_file_path; if (getenv("XJREMOTE")) { _xjadeo_bin = strdup(getenv("XJREMOTE")); // XXX TODO: free it?! - } else if (find_file_in_search_path (SearchPath(Glib::getenv("PATH")), X_("xjremote"), xjadeo_file_path)) { + } else if (find_file_in_search_path (Searchpath(Glib::getenv("PATH")), X_("xjremote"), xjadeo_file_path)) { _xjadeo_bin = xjadeo_file_path; } else if (Glib::file_test(X_("/Applications/Jadeo.app/Contents/MacOS/xjremote"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) { diff --git a/gtk2_ardour/window_manager.h b/gtk2_ardour/window_manager.h index 0dbe66b1b1..2dd6a2262e 100644 --- a/gtk2_ardour/window_manager.h +++ b/gtk2_ardour/window_manager.h @@ -159,7 +159,7 @@ class ProxyWithConstructor: public ProxyBase { return 0; } - _window = creator (); + _window = dynamic_cast (creator ()); if (_window) { setup (); diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index a6ead1adb9..578409c4ae 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -260,8 +260,9 @@ def configure(conf): '', '') 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 @@ -433,6 +434,10 @@ def build(bld): obj.use += ' libappleutility' obj.includes += ['../libs'] + if bld.env['build_target'] == 'mingw': + if bld.env['DEBUG'] == False: + obj.linkflags = ['-mwindows'] + if bld.is_defined('HAVE_SUIL'): obj.source += [ 'lv2_plugin_ui.cc' ] obj.use += [ 'SUIL' ] diff --git a/libs/ardour/ardour/async_midi_port.h b/libs/ardour/ardour/async_midi_port.h index e7eeb8ee30..c5babf6135 100644 --- a/libs/ardour/ardour/async_midi_port.h +++ b/libs/ardour/ardour/async_midi_port.h @@ -53,10 +53,16 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { /* called from non-RT context */ void parse (framecnt_t timestamp); - int write (const MIDI::byte *msg, size_t msglen, MIDI::timestamp_t timestamp); + int write (const MIDI::byte *msg, size_t msglen, MIDI::timestamp_t timestamp); int read (MIDI::byte *buf, size_t bufsize); void drain (int check_interval_usecs); - int selectable () const { return xthread.selectable(); } + int selectable () const { +#ifdef PLATFORM_WINDOWS + return false; +#else + return xthread.selectable(); +#endif + } static void set_process_thread (pthread_t); static pthread_t get_process_thread () { return _process_thread; } @@ -67,8 +73,22 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { MIDI::timestamp_t _last_write_timestamp; RingBuffer< Evoral::Event > output_fifo; Evoral::EventRingBuffer input_fifo; - Glib::Threads::Mutex output_fifo_lock; - CrossThreadChannel xthread; + Glib::Threads::Mutex output_fifo_lock; +#ifndef PLATFORM_WINDOWS + CrossThreadChannel xthread; +#endif + + int create_port (); + + /** Channel used to signal to the MidiControlUI that input has arrived */ + + std::string _connections; + PBD::ScopedConnection connect_connection; + PBD::ScopedConnection halt_connection; + void flush (void* jack_port_buffer); + void jack_halted (); + void make_connections (); + void init (std::string const &, Flags); void flush_output_fifo (pframes_t); diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index 723c734a49..53819c1c9e 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -64,6 +64,7 @@ public: virtual void clear_capture_marks() {} virtual bool one_of_several_channels () const { return false; } + virtual void flush () = 0; virtual int update_header (framepos_t when, struct tm&, time_t) = 0; virtual int flush_header () = 0; diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h index c3d10b6030..c4196dc3b6 100644 --- a/libs/ardour/ardour/audioplaylist.h +++ b/libs/ardour/ardour/audioplaylist.h @@ -29,7 +29,6 @@ namespace ARDOUR { class Session; -class Region; class AudioRegion; class Source; class AudioPlaylist; diff --git a/libs/ardour/ardour/backend_search_path.h b/libs/ardour/ardour/backend_search_path.h index 2adc22bd6f..e8a5082c71 100644 --- a/libs/ardour/ardour/backend_search_path.h +++ b/libs/ardour/ardour/backend_search_path.h @@ -32,7 +32,7 @@ namespace ARDOUR { * contain the user and system directories which may contain audio/MIDI * backends. */ - PBD::SearchPath backend_search_path (); + PBD::Searchpath backend_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/ardour/butler.h b/libs/ardour/ardour/butler.h index 21af5fb691..efdaad1621 100644 --- a/libs/ardour/ardour/butler.h +++ b/libs/ardour/ardour/butler.h @@ -20,14 +20,22 @@ #ifndef __ardour_butler_h__ #define __ardour_butler_h__ +#include + #include +#ifdef PLATFORM_WINDOWS +#include "pbd/glib_semaphore.h" +#endif + #include "pbd/ringbuffer.h" #include "pbd/pool.h" #include "ardour/libardour_visibility.h" #include "ardour/types.h" #include "ardour/session_handle.h" + + namespace ARDOUR { /** @@ -72,15 +80,43 @@ class LIBARDOUR_API 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 PLATFORM_WINDOWS + 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 PLATFORM_WINDOWS + int setup_request_pipe (); +#endif + + /** + * 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/ardour/chan_count.h b/libs/ardour/ardour/chan_count.h index 11fb6fea9d..9f9fd07543 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 { diff --git a/libs/ardour/ardour/control_protocol_search_path.h b/libs/ardour/ardour/control_protocol_search_path.h index 8795f4501a..4fe790ef80 100644 --- a/libs/ardour/ardour/control_protocol_search_path.h +++ b/libs/ardour/ardour/control_protocol_search_path.h @@ -25,15 +25,15 @@ namespace ARDOUR { /** - * return a SearchPath containing directories in which to look for + * return a Searchpath containing directories in which to look for * control surface plugins. * - * If ARDOUR_SURFACES_PATH is defined then the SearchPath returned + * If ARDOUR_SURFACES_PATH is defined then the Searchpath returned * will contain only those directories specified in it, otherwise it will * contain the user and system directories which may contain control * surface plugins. */ - PBD::SearchPath control_protocol_search_path (); + PBD::Searchpath control_protocol_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/ardour/coreaudiosource.h b/libs/ardour/ardour/coreaudiosource.h index 84ad434809..f12a67ded7 100644 --- a/libs/ardour/ardour/coreaudiosource.h +++ b/libs/ardour/ardour/coreaudiosource.h @@ -43,6 +43,8 @@ class LIBARDOUR_API CoreAudioSource : public AudioFileSource { void set_header_timeline_position () {}; bool clamped_at_unity () const { return false; } + void flush () {} + static int get_soundfile_info (string path, SoundFileInfo& _info, string& error_msg); protected: diff --git a/libs/ardour/ardour/cycles.h b/libs/ardour/ardour/cycles.h index 01e1d55221..dc1095db7b 100644 --- a/libs/ardour/ardour/cycles.h +++ b/libs/ardour/ardour/cycles.h @@ -216,7 +216,10 @@ static inline cycles_t get_cycles (void) /* debian: sparc, arm, m68k */ +#ifndef COMPILER_MSVC +/* GRRR... Annoyingly, #warning aborts the compilation for MSVC !! */ #warning You are compiling libardour on a platform for which ardour/cycles.h needs work +#endif #include diff --git a/libs/ardour/ardour/export_formats_search_path.h b/libs/ardour/ardour/export_formats_search_path.h index 7b6fcea09b..771c6f9bd3 100644 --- a/libs/ardour/ardour/export_formats_search_path.h +++ b/libs/ardour/ardour/export_formats_search_path.h @@ -24,10 +24,10 @@ namespace ARDOUR { /** - * return a SearchPath containing directories in which to look for + * return a Searchpath containing directories in which to look for * export_formats. */ - PBD::SearchPath export_formats_search_path (); + PBD::Searchpath export_formats_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/ardour/export_profile_manager.h b/libs/ardour/ardour/export_profile_manager.h index 935df25528..2757795ff3 100644 --- a/libs/ardour/ardour/export_profile_manager.h +++ b/libs/ardour/ardour/export_profile_manager.h @@ -103,7 +103,7 @@ class LIBARDOUR_API ExportProfileManager std::vector find_file (std::string const & pattern); std::string export_config_dir; - PBD::SearchPath search_path; + PBD::Searchpath search_path; /* Timespans */ public: diff --git a/libs/ardour/ardour/file_source.h b/libs/ardour/ardour/file_source.h index 568bc3204b..4b1dbf2b6c 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/filesystem_paths.h b/libs/ardour/ardour/filesystem_paths.h index b96cd05137..0bf25c5153 100644 --- a/libs/ardour/ardour/filesystem_paths.h +++ b/libs/ardour/ardour/filesystem_paths.h @@ -43,14 +43,14 @@ namespace ARDOUR { * @return the search path to be used when looking for per-system * configuration files. This may include user configuration files. */ - LIBARDOUR_API PBD::SearchPath ardour_config_search_path (); + LIBARDOUR_API PBD::Searchpath ardour_config_search_path (); /** * @return the search path to be used when looking for data files * that could be shared by systems (h/w and configuration independent * files, such as icons, XML files, etc) */ - LIBARDOUR_API PBD::SearchPath ardour_data_search_path (); + LIBARDOUR_API PBD::Searchpath ardour_data_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/ardour/interthread_info.h b/libs/ardour/ardour/interthread_info.h index 2cc786c6e2..49055de5d0 100644 --- a/libs/ardour/ardour/interthread_info.h +++ b/libs/ardour/ardour/interthread_info.h @@ -30,7 +30,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; diff --git a/libs/ardour/ardour/jack_utils.h b/libs/ardour/ardour/jack_utils.h new file mode 100644 index 0000000000..40eb30f9ea --- /dev/null +++ b/libs/ardour/ardour/jack_utils.h @@ -0,0 +1,253 @@ +/* + 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); +} diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h index 4444686dcb..a3b99575fe 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 LIBARDOUR_API 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 LIBARDOUR_API 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 LIBARDOUR_API 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/ladspa_search_path.h b/libs/ardour/ardour/ladspa_search_path.h new file mode 100644 index 0000000000..bc184b5248 --- /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/ardour/lv2_bundled_search_path.h b/libs/ardour/ardour/lv2_bundled_search_path.h index f5780c5e0e..9314ee27d4 100644 --- a/libs/ardour/ardour/lv2_bundled_search_path.h +++ b/libs/ardour/ardour/lv2_bundled_search_path.h @@ -25,10 +25,10 @@ namespace ARDOUR { /** - * return a SearchPath containing directories in which to look for + * return a Searchpath containing directories in which to look for * lv2 plugins. */ - PBD::SearchPath lv2_bundled_search_path (); + PBD::Searchpath lv2_bundled_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index a9cb2cb260..034101ee41 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -29,6 +29,8 @@ #include "ardour/worker.h" #include "pbd/ringbuffer.h" +typedef struct LV2_Evbuf_Impl LV2_Evbuf; + namespace ARDOUR { // a callback function for lilv_state_new_from_instance(). friend of LV2Plugin diff --git a/libs/ardour/ardour/midi_patch_search_path.h b/libs/ardour/ardour/midi_patch_search_path.h index 5d27823461..168e75af4a 100644 --- a/libs/ardour/ardour/midi_patch_search_path.h +++ b/libs/ardour/ardour/midi_patch_search_path.h @@ -24,15 +24,15 @@ namespace ARDOUR { /** - * return a SearchPath containing directories in which to look for + * return a Searchpath containing directories in which to look for * MIDI patch files ("*.midnam") aka MIDNAM files * - * If ARDOUR_MIDI_PATCH_PATH is defined then the SearchPath returned + * If ARDOUR_MIDI_PATCH_PATH is defined then the Searchpath returned * will contain only those directories specified in it, otherwise it will * contain the user and system directories which may contain control * surface plugins. */ - PBD::SearchPath midi_patch_search_path (); + PBD::Searchpath midi_patch_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index e53b4a4ee0..b118214c9e 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -32,7 +32,6 @@ namespace ARDOUR { class Session; -class Region; class MidiRegion; class Source; template class MidiRingBuffer; diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index 7e53c5a292..cf6d3f7b64 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/ardour/msvc_libardour.h b/libs/ardour/ardour/msvc_libardour.h new file mode 100644 index 0000000000..52aa65d95c --- /dev/null +++ b/libs/ardour/ardour/msvc_libardour.h @@ -0,0 +1,71 @@ +/* + 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_libardour_h__ +#define __msvc_libardour_h__ + +#include "ardour/visibility.h" +#include + +#ifndef _MAX_PATH +#define _MAX_PATH 260 +#endif +#ifndef PATH_MAX +#define PATH_MAX _MAX_PATH +#endif + +namespace ARDOUR { + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +// LIBARDOUR_API char* LIBARDOUR_APICALLTYPE placeholder_for_non_msvc_specific_function(s); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +} // namespace ARDOUR + +#ifdef COMPILER_MSVC +#include +//#include + +#ifndef __THROW +#define __THROW throw() +#endif +#include + +namespace ARDOUR { + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +LIBARDOUR_API int LIBARDOUR_APICALLTYPE symlink(const char *dest, const char *shortcut, const char *working_directory = 0); +LIBARDOUR_API int LIBARDOUR_APICALLTYPE readlink(const char *__restrict shortcut, char *__restrict buf, size_t bufsize); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +} // namespace ARDOUR + +#endif // COMPILER_MSVC +#endif // __mavc_libardour_h__ diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h index 47b102989b..48f583c185 100644 --- a/libs/ardour/ardour/panner.h +++ b/libs/ardour/ardour/panner.h @@ -35,6 +35,18 @@ #include "ardour/automation_control.h" #include "ardour/automatable.h" + +/* This section is for actual panners to use. They will include this file, + * declare ARDOURPANNER_DLL_EXPORTS during compilation, and ... voila. + */ + +#ifdef ARDOURPANNER_DLL_EXPORTS // defined if we are building a panner implementation + #define ARDOURPANNER_API LIBARDOUR_DLL_EXPORT + #else + #define ARDOURPANNER_API LIBARDOUR_DLL_IMPORT + #endif +#define ARDOURPANNER_LOCAL LIBARDOUR_DLL_LOCAL + namespace ARDOUR { class Session; diff --git a/libs/ardour/ardour/panner_manager.h b/libs/ardour/ardour/panner_manager.h index 619beb454f..80f8e8010a 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 LIBARDOUR_API 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/ardour/panner_search_path.h b/libs/ardour/ardour/panner_search_path.h index 889b9efb23..23004223b4 100644 --- a/libs/ardour/ardour/panner_search_path.h +++ b/libs/ardour/ardour/panner_search_path.h @@ -24,15 +24,15 @@ namespace ARDOUR { /** - * return a SearchPath containing directories in which to look for + * return a Searchpath containing directories in which to look for * panner plugins. * - * If ARDOUR_PANNER_PATH is defined then the SearchPath returned + * If ARDOUR_PANNER_PATH is defined then the Searchpath returned * will contain only those directories specified in it, otherwise it will * contain the user and system directories which may contain control * surface plugins. */ - PBD::SearchPath panner_search_path (); + PBD::Searchpath panner_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 08ecd10853..5629a04629 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -41,13 +41,13 @@ #include "evoral/types.hpp" #include "ardour/ardour.h" +#include "ardour/region.h" #include "ardour/session_object.h" #include "ardour/data_type.h" namespace ARDOUR { class Session; -class Region; class Playlist; class Crossfade; diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index 73de0eb704..bee1c68704 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -52,7 +52,6 @@ class LIBARDOUR_API 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); @@ -104,7 +103,6 @@ class LIBARDOUR_API PluginManager : public boost::noncopyable { std::map rdf_type; - std::string ladspa_path; std::string windows_vst_path; std::string lxvst_path; @@ -128,7 +126,6 @@ class LIBARDOUR_API 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/ardour/session.h b/libs/ardour/ardour/session.h index 01a2cc9054..08f4c1315a 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -830,7 +830,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop 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/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h index 0af357a613..cf6462247a 100644 --- a/libs/ardour/ardour/silentfilesource.h +++ b/libs/ardour/ardour/silentfilesource.h @@ -32,6 +32,7 @@ public: float sample_rate () const { return _sample_rate; } void set_length (framecnt_t len) { _length = len; } + void flush () {} bool destructive() const { return false; } bool can_be_analysed() const { return false; } diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h index 9b3da1701d..25b8f003b2 100644 --- a/libs/ardour/ardour/sndfilesource.h +++ b/libs/ardour/ardour/sndfilesource.h @@ -46,6 +46,7 @@ class LIBARDOUR_API SndFileSource : public AudioFileSource { float sample_rate () const; int update_header (framepos_t when, struct tm&, time_t); int flush_header (); + void flush (); framepos_t natural_position () const; diff --git a/libs/ardour/async_midi_port.cc b/libs/ardour/async_midi_port.cc index 5bc8e22833..bd583328c3 100644 --- a/libs/ardour/async_midi_port.cc +++ b/libs/ardour/async_midi_port.cc @@ -19,6 +19,9 @@ */ #include +#include + +#include #include "pbd/error.h" #include "pbd/stacktrace.h" @@ -35,7 +38,7 @@ using namespace std; using namespace PBD; namespace Evoral { - template class EventRingBuffer; + template class EventRingBuffer; } pthread_t AsyncMIDIPort::_process_thread; @@ -49,7 +52,9 @@ AsyncMIDIPort::AsyncMIDIPort (string const & name, PortFlags flags) , _last_write_timestamp (0) , output_fifo (512) , input_fifo (1024) +#ifndef PLATFORM_WINDOWS , xthread (true) +#endif { } @@ -58,7 +63,7 @@ AsyncMIDIPort::~AsyncMIDIPort () } void -AsyncMIDIPort::flush_output_fifo (pframes_t nframes) +AsyncMIDIPort::flush_output_fifo (MIDI::pframes_t nframes) { RingBuffer< Evoral::Event >::rw_vector vec = { { 0, 0 }, { 0, 0 } }; size_t written; @@ -89,7 +94,7 @@ AsyncMIDIPort::flush_output_fifo (pframes_t nframes) } void -AsyncMIDIPort::cycle_start (pframes_t nframes) +AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes) { _currently_in_cycle = true; MidiPort::cycle_start (nframes); @@ -113,16 +118,17 @@ AsyncMIDIPort::cycle_start (pframes_t nframes) for (MidiBuffer::iterator b = mb.begin(); b != mb.end(); ++b) { input_fifo.write (when, (Evoral::EventType) 0, (*b).size(), (*b).buffer()); } - + +#ifndef PLATFORM_WINDOWS if (!mb.empty()) { xthread.wakeup (); } +#endif } - } void -AsyncMIDIPort::cycle_end (pframes_t nframes) +AsyncMIDIPort::cycle_end (MIDI::pframes_t nframes) { if (ARDOUR::Port::sends_output()) { /* move any additional data from output FIFO into the port @@ -161,12 +167,12 @@ AsyncMIDIPort::drain (int check_interval_usecs) if (vec.len[0] + vec.len[1] >= output_fifo.bufsize() - 1) { break; } - usleep (check_interval_usecs); + Glib::usleep (check_interval_usecs); } } int -AsyncMIDIPort::write (const byte * msg, size_t msglen, timestamp_t timestamp) +AsyncMIDIPort::write (const MIDI::byte * msg, size_t msglen, MIDI::timestamp_t timestamp) { int ret = 0; @@ -219,7 +225,7 @@ AsyncMIDIPort::write (const byte * msg, size_t msglen, timestamp_t timestamp) } if (timestamp >= _cycle_nframes) { - std::cerr << "attempting to write MIDI event of " << msglen << " bytes at time " + std::cerr << "attempting to write MIDI event of " << msglen << " MIDI::bytes at time " << timestamp << " of " << _cycle_nframes << " (this will not work - needs a code fix)" << std::endl; @@ -268,9 +274,9 @@ AsyncMIDIPort::read (MIDI::byte *, size_t) timestamp_t time; Evoral::EventType type; uint32_t size; - byte buffer[input_fifo.capacity()]; + vector buffer(input_fifo.capacity()); - while (input_fifo.read (&time, &type, &size, buffer)) { + while (input_fifo.read (&time, &type, &size, &buffer[0])) { _parser->set_timestamp (time); for (uint32_t i = 0; i < size; ++i) { _parser->scanner (buffer[i]); @@ -281,7 +287,7 @@ AsyncMIDIPort::read (MIDI::byte *, size_t) } void -AsyncMIDIPort::parse (framecnt_t) +AsyncMIDIPort::parse (MIDI::framecnt_t) { MIDI::byte buf[1]; diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index a9f9f40d64..f4d10c2043 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" @@ -925,7 +923,7 @@ AudioDiskstream::internal_playback_seek (framecnt_t distance) boost::shared_ptr c = channels.reader(); for (chan = c->begin(); chan != c->end(); ++chan) { - (*chan)->playback_buf->increment_read_ptr (std::llabs(distance)); + (*chan)->playback_buf->increment_read_ptr (llabs(distance)); } if (first_recordable_frame < max_framepos) { 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/audio_track.cc b/libs/ardour/audio_track.cc index 7f77f637a3..a82c109cba 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -315,7 +315,7 @@ AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram if (!lm.locked()) { boost::shared_ptr diskstream = audio_diskstream(); framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes); - if (can_internal_playback_seek(std::llabs(playback_distance))) { + if (can_internal_playback_seek(llabs(playback_distance))) { /* TODO should declick */ internal_playback_seek(playback_distance); } diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 538a905ca2..1a24977399 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include "ardour/ardour.h" #include "ardour/audioengine.h" @@ -2453,7 +2454,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/audioengine.cc b/libs/ardour/audioengine.cc index 82564ebaf2..cb167c9595 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -34,8 +34,6 @@ #include "pbd/stacktrace.h" #include "pbd/unknown_type.h" -#include - #include "midi++/port.h" #include "midi++/mmc.h" @@ -474,8 +472,17 @@ AudioEngine::discover_backends () Glib::PatternSpec so_extension_pattern("*backend.so"); Glib::PatternSpec dylib_extension_pattern("*backend.dylib"); - Glib::PatternSpec dll_extension_pattern("*backend.dll"); +#if defined(PLATFORM_WINDOWS) && defined(DEBUGGABLE_BACKENDS) + #if defined(DEBUG) || defined(_DEBUG) + Glib::PatternSpec dll_extension_pattern("*backendD.dll"); + #else + Glib::PatternSpec dll_extension_pattern("*backendRDC.dll"); + #endif +#else + Glib::PatternSpec dll_extension_pattern("*backend.dll"); +#endif + find_matching_files_in_search_path (backend_search_path (), so_extension_pattern, backend_modules); 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 3c6d4f81b8..d0b6205cb2 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -17,12 +17,15 @@ */ -#include +#ifdef COMPILER_MSVC +#include +#else #include -#include -#include -#include #include +#endif +#include +#include +#include #include #include #include @@ -31,6 +34,12 @@ #include #include +#include +#include + +#include +#include + #include #include @@ -42,6 +51,8 @@ #include "i18n.h" +#include "ardour/debug.h" + using namespace std; using namespace ARDOUR; using namespace PBD; @@ -173,9 +184,9 @@ AudioSource::peaks_ready (boost::function doThisWhenReady, ScopedConnect void AudioSource::touch_peakfile () { - struct stat statbuf; + GStatBuf 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; } @@ -184,7 +195,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 @@ -195,7 +206,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; } @@ -209,17 +220,19 @@ AudioSource::rename_peakfile (string newpath) int AudioSource::initialize_peakfile (string audio_path) { - struct stat statbuf; + GStatBuf statbuf; 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)) { 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 */ @@ -227,7 +240,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; @@ -236,7 +249,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. @@ -248,6 +261,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; @@ -316,28 +330,15 @@ 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; - 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); 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 */ @@ -353,16 +354,15 @@ 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. */ - 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; } @@ -372,43 +372,35 @@ 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; } 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) { error << string_compose(_("AudioSource: cannot open peakpath (a) \"%1\" (%2)"), peakpath, strerror (errno)) << endmsg; - delete peakfile_descriptor; return -1; } -#ifdef DEBUG_READ_PEAKS - cerr << "DIRECT PEAKS\n"; -#endif + DEBUG_TRACE (DEBUG::Peaks, "DIRECT PEAKS\n"); - nread = ::pread (peakfile_fd, peaks, sizeof (PeakData)* npeaks, first_peak_byte); + offset = lseek (peakfile_fd, first_peak_byte, SEEK_SET); - 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; - delete peakfile_descriptor; + 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 != 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; } @@ -416,7 +408,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; } @@ -425,9 +416,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, @@ -440,7 +430,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 */ @@ -461,8 +451,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; } @@ -473,33 +461,27 @@ 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; -#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" + , bytes_to_read, start_byte)); - if ((nread = ::pread (peakfile_fd, staging, 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); - 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; - goto out; + 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)); + return -1; } - i = 0; stored_peaks_read = nread / sizeof(PeakData); } @@ -531,13 +513,10 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t memset (&peaks[npeaks], 0, sizeof (PeakData) * zero_fill); } - ret = 0; - } else { -#ifdef DEBUG_READ_PEAKS - cerr << "UPSAMPLE\n"; -#endif + DEBUG_TRACE (DEBUG::Peaks, "UPSAMPLE\n"); + /* the caller wants - less frames-per-peak (more resolution) @@ -552,7 +531,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); @@ -577,18 +556,18 @@ 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; - goto out; + return -1; } } @@ -616,32 +595,19 @@ 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: - delete peakfile_descriptor; - - delete [] staging; - delete [] raw_staging; - -#ifdef DEBUG_READ_PEAKS - cerr << "RP DONE\n"; -#endif - - return ret; + DEBUG_TRACE (DEBUG::Peaks, "READPEAKS DONE\n"); + return 0; } -#undef DEBUG_PEAK_BUILD - 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"); + int ret = -1; { @@ -657,20 +623,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; } @@ -691,11 +657,10 @@ AudioSource::build_peaks_from_scratch () out: if (ret) { - unlink (peakpath.c_str()); + DEBUG_TRACE (DEBUG::Peaks, string_compose("Could not write peak data, attempting to remove peakfile %1\n", peakpath)); + ::g_unlink (peakpath.c_str()); } - delete [] buf; - return ret; } @@ -739,15 +704,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 (); @@ -770,9 +733,16 @@ AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, frame off_t byte = (peak_leftover_frame / fpp) * sizeof (PeakData); - 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; - goto out; + return -1; } _peak_byte_max = max (_peak_byte_max, (off_t) (byte + sizeof(PeakData))); @@ -798,19 +768,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 */ @@ -820,7 +790,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; @@ -877,18 +847,31 @@ 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 */ } } } - 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; + + 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; } - _peak_byte_max = max (_peak_byte_max, (off_t) (first_peak_byte + sizeof(PeakData)*peaks_computed)); + 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; + } + + _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); @@ -898,13 +881,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 @@ -921,6 +898,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/automation_watch.cc b/libs/ardour/automation_watch.cc index 16e10c95f9..91fe4d38ed 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 ((gulong) floor (Config->get_automation_interval_msecs() * 1000)); timer (); } } diff --git a/libs/ardour/backend_search_path.cc b/libs/ardour/backend_search_path.cc index 9a0425094b..4c5ff40e7d 100644 --- a/libs/ardour/backend_search_path.cc +++ b/libs/ardour/backend_search_path.cc @@ -31,14 +31,14 @@ using namespace PBD; namespace ARDOUR { -SearchPath +Searchpath backend_search_path () { - SearchPath spath(user_config_directory ()); + Searchpath spath(user_config_directory ()); spath += ardour_dll_directory (); spath.add_subdirectory_to_paths(backend_dir_name); - spath += SearchPath(Glib::getenv(backend_env_variable_name)); + spath += Searchpath(Glib::getenv(backend_env_variable_name)); return spath; } diff --git a/libs/ardour/broadcast_info.cc b/libs/ardour/broadcast_info.cc index a7fa41aaf9..a08d2c7991 100644 --- a/libs/ardour/broadcast_info.cc +++ b/libs/ardour/broadcast_info.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -37,15 +38,15 @@ namespace ARDOUR static void snprintf_bounded_null_filled (char* target, size_t target_size, char const * fmt, ...) { - char buf[target_size+1]; + std::vector buf(target_size+1); va_list ap; va_start (ap, fmt); - vsnprintf (buf, target_size+1, fmt, ap); + vsnprintf (&buf[0], target_size+1, fmt, ap); va_end (ap); memset (target, 0, target_size); - memcpy (target, buf, target_size); + memcpy (target, &buf[0], target_size); } @@ -84,7 +85,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/butler.cc b/libs/ardour/butler.cc index 89b2cc1303..1fe1524618 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -20,7 +20,11 @@ #include #include #include + +#ifndef PLATFORM_WINDOWS #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,31 @@ Butler::config_changed (std::string p) } } +#ifndef PLATFORM_WINDOWS +int +Butler::setup_request_pipe () +{ + if (pipe (request_pipe)) { + error << string_compose(_("Cannot create transport request signal pipe (%1)"), + strerror (errno)) << endmsg; + return -1; + } + + if (fcntl (request_pipe[0], F_SETFL, O_NONBLOCK)) { + error << string_compose(_("UI: cannot set O_NONBLOCK on butler request pipe (%1)"), + strerror (errno)) << endmsg; + return -1; + } + + if (fcntl (request_pipe[1], F_SETFL, O_NONBLOCK)) { + error << string_compose(_("UI: cannot set O_NONBLOCK on butler request pipe (%1)"), + strerror (errno)) << endmsg; + return -1; + } + return 0; +} +#endif + int Butler::start_thread() { @@ -87,23 +116,9 @@ Butler::start_thread() should_run = false; - if (pipe (request_pipe)) { - error << string_compose(_("Cannot create transport request signal pipe (%1)"), - strerror (errno)) << endmsg; - return -1; - } - - if (fcntl (request_pipe[0], F_SETFL, O_NONBLOCK)) { - error << string_compose(_("UI: cannot set O_NONBLOCK on butler request pipe (%1)"), - strerror (errno)) << endmsg; - return -1; - } - - if (fcntl (request_pipe[1], F_SETFL, O_NONBLOCK)) { - error << string_compose(_("UI: cannot set O_NONBLOCK on butler request pipe (%1)"), - strerror (errno)) << endmsg; - return -1; - } +#ifndef PLATFORM_WINDOWS + 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; @@ -118,12 +133,9 @@ Butler::start_thread() void Butler::terminate_thread () { - if (thread) { - void* status; - const char c = Request::Quit; - (void) ::write (request_pipe[1], &c, 1); - pthread_join (thread, &status); - } + void* status; + queue_request (Request::Quit); + pthread_join (thread, &status); } void * @@ -134,28 +146,25 @@ Butler::_thread_work (void* arg) return ((Butler *) arg)->thread_work (); } -void * -Butler::thread_work () +bool +Butler::wait_for_requests () { - uint32_t err = 0; - +#ifndef PLATFORM_WINDOWS 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; } @@ -165,16 +174,60 @@ Butler::thread_work () } if (pfd[0].revents & POLLIN) { + return true; + } + } + return false; +#else + m_request_sem.wait (); + return true; +#endif +} - char req; +bool +Butler::dequeue_request (Request::Type& r) +{ +#ifndef PLATFORM_WINDOWS + 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*/ + } +#else + r = (Request::Type) m_request_state.get(); +#endif + return false; +} - /* empty the pipe of all current requests */ + void * +Butler::thread_work () +{ + uint32_t err = 0; - while (1) { - size_t nread = ::read (request_pipe[0], &req, sizeof (req)); - if (nread == 1) { + bool disk_work_outstanding = false; + RouteList::iterator i; - switch ((Request::Type) req) { + while (true) { + if(!disk_work_outstanding) { + if (wait_for_requests ()) { + Request::Type req; + + /* empty the pipe of all current requests */ +#ifdef PLATFORM_WINDOWS + dequeue_request (req); + { +#else + while(dequeue_request(req)) { +#endif + switch (req) { case Request::Run: should_run = true; @@ -192,14 +245,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*/ } } } @@ -337,19 +382,29 @@ Butler::schedule_transport_work () summon (); } +void +Butler::queue_request (Request::Type r) +{ +#ifndef PLATFORM_WINDOWS + char c = r; + (void) ::write (request_pipe[1], &c, 1); +#else + m_request_state.set (r); + m_request_sem.post (); +#endif +} + void Butler::summon () { - char c = Request::Run; - (void) ::write (request_pipe[1], &c, 1); + 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); } @@ -357,8 +412,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); } diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 974258a5c2..d9cefb44f2 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,10 @@ #include "ardour/debug.h" #include "ardour/control_protocol_manager.h" + #include "ardour/control_protocol_search_path.h" + using namespace ARDOUR; using namespace std; using namespace PBD; @@ -211,7 +213,9 @@ ControlProtocolManager::teardown (ControlProtocolInfo& cpi) } cpi.protocol = 0; - dlclose (cpi.descriptor->module); + delete cpi.state; + cpi.state = 0; + delete (Glib::Module*)cpi.descriptor->module; ProtocolStatusChange (&cpi); @@ -296,7 +300,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; @@ -305,31 +309,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/control_protocol_search_path.cc b/libs/ardour/control_protocol_search_path.cc index 254cd03fe9..c5c5d0ba00 100644 --- a/libs/ardour/control_protocol_search_path.cc +++ b/libs/ardour/control_protocol_search_path.cc @@ -33,14 +33,14 @@ using namespace PBD; namespace ARDOUR { -SearchPath +Searchpath control_protocol_search_path () { - SearchPath spath(user_config_directory ()); + Searchpath spath(user_config_directory ()); spath += ardour_dll_directory (); spath.add_subdirectory_to_paths (surfaces_dir_name); - spath += SearchPath(Glib::getenv(surfaces_env_variable_name)); + spath += Searchpath(Glib::getenv(surfaces_env_variable_name)); return spath; } diff --git a/libs/ardour/debug.cc b/libs/ardour/debug.cc index fb122dd83c..dc762299e9 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"); diff --git a/libs/ardour/default_click.cc b/libs/ardour/default_click.cc index fd23f0166d..7e8eca8fd2 100644 --- a/libs/ardour/default_click.cc +++ b/libs/ardour/default_click.cc @@ -21,6 +21,10 @@ #include "ardour/session.h" #include "ardour/types.h" +#ifdef COMPILER_MSVC +#pragma warning(disable:4305) +#endif + using namespace ARDOUR; const Sample Session::default_click_emphasis[] = { diff --git a/libs/ardour/directory_names.cc b/libs/ardour/directory_names.cc index af7f7f550c..f01c024435 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"); const char* const backend_dir_name = X_("backends"); diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index a359f228e8..e046d5a830 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -29,7 +29,6 @@ #include #include #include -#include #include @@ -571,7 +570,7 @@ Diskstream::move_processor_automation (boost::weak_ptr p, list< Evora set const a = processor->what_can_be_automated (); - for (set::iterator i = a.begin (); i != a.end (); ++i) { + for (set::const_iterator i = a.begin (); i != a.end (); ++i) { boost::shared_ptr al = processor->automation_control(*i)->alist(); XMLNode & before = al->get_state (); bool const things_moved = al->move_ranges (movements); @@ -601,7 +600,7 @@ Diskstream::check_record_status (framepos_t transport_frame, bool can_record) */ rolling = _session.transport_speed() != 0.0f; - possibly_recording = (rolling << 2) | (record_enabled() << 1) | can_record; + possibly_recording = (rolling << 2) | ((int)record_enabled() << 1) | (int)can_record; change = possibly_recording ^ last_possibly_recording; if (possibly_recording == last_possibly_recording) { diff --git a/libs/ardour/export_format_base.cc b/libs/ardour/export_format_base.cc index ed8bb9d5f8..1eda449915 100644 --- a/libs/ardour/export_format_base.cc +++ b/libs/ardour/export_format_base.cc @@ -185,7 +185,7 @@ ExportFormatBase::nearest_sample_rate (framecnt_t sample_rate) SampleRate best_match = SR_None; #define DO_SR_COMPARISON(rate) \ - diff = std::fabs((rate) - sample_rate); \ + diff = std::fabs((double)((rate) - sample_rate)); \ if(diff < smallest_diff) { \ smallest_diff = diff; \ best_match = (rate); \ diff --git a/libs/ardour/export_formats_search_path.cc b/libs/ardour/export_formats_search_path.cc index cf18b14a18..ffa096d33a 100644 --- a/libs/ardour/export_formats_search_path.cc +++ b/libs/ardour/export_formats_search_path.cc @@ -32,14 +32,14 @@ using namespace PBD; namespace ARDOUR { -SearchPath +Searchpath export_formats_search_path () { - SearchPath spath (ardour_data_search_path()); + Searchpath spath (ardour_data_search_path()); spath.add_subdirectory_to_paths (export_formats_dir_name); bool export_formats_path_defined = false; - SearchPath spath_env (Glib::getenv(export_env_variable_name, export_formats_path_defined)); + Searchpath spath_env (Glib::getenv(export_env_variable_name, export_formats_path_defined)); if (export_formats_path_defined) { spath += spath_env; diff --git a/libs/ardour/export_graph_builder.cc b/libs/ardour/export_graph_builder.cc index 301914b0ae..2c0c44033d 100644 --- a/libs/ardour/export_graph_builder.cc +++ b/libs/ardour/export_graph_builder.cc @@ -20,6 +20,8 @@ #include "ardour/export_graph_builder.h" +#include + #include #include "audiographer/process_context.h" @@ -317,8 +319,8 @@ ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpe { std::string tmpfile_path = parent.session.session_directory().export_path(); tmpfile_path = Glib::build_filename(tmpfile_path, "XXXXXX"); - char tmpfile_path_buf[tmpfile_path.size() + 1]; - std::copy(tmpfile_path.begin(), tmpfile_path.end(), tmpfile_path_buf); + std::vector tmpfile_path_buf(tmpfile_path.size() + 1); + std::copy(tmpfile_path.begin(), tmpfile_path.end(), tmpfile_path_buf.begin()); tmpfile_path_buf[tmpfile_path.size()] = '\0'; config = new_config; @@ -334,7 +336,7 @@ ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpe normalizer->add_output (threader); int format = ExportFormatBase::F_RAW | ExportFormatBase::SF_Float; - tmp_file.reset (new TmpFile (tmpfile_path_buf, format, channels, config.format->sample_rate())); + tmp_file.reset (new TmpFile (&tmpfile_path_buf[0], format, channels, config.format->sample_rate())); tmp_file->FileWritten.connect_same_thread (post_processing_connection, boost::bind (&Normalizer::start_post_processing, this)); diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index 93f43f33a6..20abc80de1 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 @@ -422,10 +423,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/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(); diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc index 0921498186..e06b3d624e 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; @@ -496,13 +487,14 @@ FileSource::find_2X (Session& s, DataType type, const string& path, bool must_ex goto out; } +#ifndef PLATFORM_WINDOWS 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; diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index 73bfaff137..54f7508b65 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -86,49 +86,71 @@ user_config_directory () std::string ardour_dll_directory () { +#ifdef PLATFORM_WINDOWS + 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 } -SearchPath +#ifdef PLATFORM_WINDOWS +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 () { - static SearchPath search_path; + static Searchpath search_path; if (search_path.empty()) { search_path += user_config_directory(); - +#ifdef PLATFORM_WINDOWS + 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"); ::exit (1); } - search_path += SearchPath (s); + search_path += Searchpath (s); +#endif } return search_path; } -SearchPath +Searchpath ardour_data_search_path () { - static SearchPath search_path; + static Searchpath search_path; if (search_path.empty()) { search_path += user_config_directory(); - +#ifdef PLATFORM_WINDOWS + 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"); ::exit (1); } - search_path += SearchPath (s); + search_path += Searchpath (s); +#endif } return search_path; diff --git a/libs/ardour/find_session.cc b/libs/ardour/find_session.cc index 7a25b1298b..501927c42c 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" @@ -44,16 +45,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/globals.cc b/libs/ardour/globals.cc index 2cd886b03e..5874ac3b1b 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -20,12 +20,18 @@ #include "libardour-config.h" #endif +#ifdef interface +#undef interface +#endif + #include // Needed so that libraptor (included in lrdf) won't complain #include #include #include #include +#ifndef PLATFORM_WINDOWS #include +#endif #include #include #include @@ -43,7 +49,7 @@ #include "ardour/audio_unit.h" #endif -#ifdef __SSE__ +#if defined(__SSE__) || defined(USE_XMMINTRIN) #include #endif @@ -54,7 +60,9 @@ #include #include +#ifdef HAVE_LRDF #include +#endif #include "pbd/cpus.h" #include "pbd/error.h" @@ -196,6 +204,7 @@ setup_hardware_optimization (bool try_optimization) static void lotsa_files_please () { +#ifndef PLATFORM_WINDOWS struct rlimit rl; if (getrlimit (RLIMIT_NOFILE, &rl) == 0) { @@ -216,6 +225,7 @@ lotsa_files_please () } else { error << string_compose (_("Could not get system open files limit (%1)"), strerror (errno)) << endmsg; } +#endif } bool @@ -262,7 +272,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")); @@ -364,7 +376,9 @@ ARDOUR::cleanup () ARDOUR::AudioEngine::destroy (); delete Library; +#ifdef HAVE_LRDF lrdf_cleanup (); +#endif delete &ControlProtocolManager::instance(); #ifdef WINDOWS_VST_SUPPORT fst_exit (); @@ -382,7 +396,7 @@ void ARDOUR::find_bindings_files (map& files) { vector found; - SearchPath spath = ardour_config_search_path(); + Searchpath spath = ardour_config_search_path(); if (getenv ("ARDOUR_SAE")) { Glib::PatternSpec pattern("*SAE-*.bindings"); @@ -581,10 +595,21 @@ clock_gettime (int /*clk_id*/, struct timespec *t) microseconds_t ARDOUR::get_microseconds () { +#ifdef PLATFORM_WINDOWS + microseconds_t ret = 0; + LARGE_INTEGER freq, time; + + if (QueryPerformanceFrequency(&freq)) + if (QueryPerformanceCounter(&time)) + ret = (microseconds_t)((time.QuadPart * 1000000) / freq.QuadPart); + + return ret; +#else struct timespec ts; if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0) { /* EEEK! */ return 0; } return (microseconds_t) ts.tv_sec * 1000000 + (ts.tv_nsec/1000); +#endif } diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index d183bcd7d2..f8a1d51e10 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" @@ -358,7 +359,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 (); @@ -367,12 +368,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(); @@ -384,7 +385,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; } @@ -552,7 +553,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); diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 047b46f553..b66f354224 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -117,7 +118,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 +173,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 +197,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 +216,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 +254,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 +275,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 +301,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,15 +325,23 @@ 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) { +#ifdef PLATFORM_WINDOWS + /* Flush the data once we've finished importing the file. Windows can */ + /* cache the data for very long periods of time (perhaps not writing */ + /* it to disk until Ardour closes). So let's force it to flush now. */ + for (chn = 0; chn < channels; ++chn) + if ((afs = boost::dynamic_pointer_cast(newfiles[chn])) != 0) + afs->flush (); +#endif break; } @@ -464,7 +473,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()); } } @@ -479,7 +488,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/io.cc b/libs/ardour/io.cc index 6f5b5a63da..ebd295411e 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -395,7 +396,9 @@ IO::disconnect (void* src) int IO::ensure_ports_locked (ChanCount count, bool clear, bool& changed) { +#ifndef PLATFORM_WINDOWS assert (!AudioEngine::instance()->process_lock().trylock()); +#endif boost::shared_ptr port; @@ -466,7 +469,9 @@ IO::ensure_ports_locked (ChanCount count, bool clear, bool& changed) int IO::ensure_ports (ChanCount count, bool clear, void* src) { +#ifndef PLATFORM_WINDOWS assert (!AudioEngine::instance()->process_lock().trylock()); +#endif bool changed = false; @@ -501,7 +506,9 @@ IO::ensure_ports (ChanCount count, bool clear, void* src) int IO::ensure_io (ChanCount count, bool clear, void* src) { +#ifndef PLATFORM_WINDOWS assert (!AudioEngine::instance()->process_lock().trylock()); +#endif return ensure_ports (count, clear, src); } @@ -1373,20 +1380,20 @@ IO::build_legal_port_name (DataType type) limit = name_size - AudioEngine::instance()->my_name().length() - (suffix.length() + 5); - char buf1[name_size+1]; - char buf2[name_size+1]; + std::vector buf1(name_size+1); + std::vector buf2(name_size+1); /* colons are illegal in port names, so fix that */ string nom = _name.val(); replace_all (nom, ":", ";"); - snprintf (buf1, name_size+1, ("%.*s/%s"), limit, nom.c_str(), suffix.c_str()); + snprintf (&buf1[0], name_size+1, ("%.*s/%s"), limit, nom.c_str(), suffix.c_str()); - int port_number = find_port_hole (buf1); - snprintf (buf2, name_size+1, "%s %d", buf1, port_number); + int port_number = find_port_hole (&buf1[0]); + snprintf (&buf2[0], name_size+1, "%s %d", &buf1[0], port_number); - return string (buf2); + return string (&buf2[0]); } int32_t @@ -1404,14 +1411,13 @@ IO::find_port_hole (const char* base) */ for (n = 1; n < 9999; ++n) { - size_t size = AudioEngine::instance()->port_name_size() + 1; - char buf[size]; + std::vector buf (AudioEngine::instance()->port_name_size()); PortSet::iterator i = _ports.begin(); - snprintf (buf, size, _("%s %u"), base, n); + snprintf (&buf[0], jack_port_name_size(), _("%s %u"), base, n); for ( ; i != _ports.end(); ++i) { - if (i->name() == buf) { + if (string(i->name()) == string(&buf[0])) { break; } } diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index bc3a83799b..8b089929b5 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 @@ -25,11 +29,15 @@ #include #include // so libraptor doesn't complain #include +#ifndef COMPILER_MSVC #include +#endif #include #include +#ifdef HAVE_LRDF #include +#endif #include "pbd/compose.h" #include "pbd/error.h" @@ -50,16 +58,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]; @@ -68,25 +76,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(); @@ -142,9 +157,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; @@ -629,10 +643,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; } @@ -645,6 +660,7 @@ LadspaPlugin::get_scale_points(uint32_t port_index) const } lrdf_free_setting_values(points); +#endif return ret; } @@ -710,17 +726,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; } @@ -739,6 +745,7 @@ LadspaPluginInfo::LadspaPluginInfo() void LadspaPlugin::find_presets () { +#ifdef HAVE_LRDF uint32_t id; std::string unique (unique_id()); @@ -759,12 +766,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) { @@ -777,6 +786,7 @@ LadspaPlugin::load_preset (PresetRecord r) } Plugin::load_preset (r); +#endif return true; } @@ -784,6 +794,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; @@ -817,11 +828,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; @@ -837,6 +850,7 @@ LadspaPlugin::do_remove_preset (string name) lrdf_remove_preset (source.c_str(), p->uri.c_str ()); write_preset_file (envvar); +#endif } string @@ -859,6 +873,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; @@ -879,11 +894,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) { @@ -902,8 +921,8 @@ LadspaPlugin::do_save_preset (string name) lrdf_defaults defaults; defaults.count = input_parameter_pids.size (); - lrdf_portvalue portvalues[input_parameter_pids.size()]; - defaults.items = portvalues; + std::vector portvalues(input_parameter_pids.size()); + defaults.items = &portvalues[0]; for (vector::size_type i = 0; i < input_parameter_pids.size(); ++i) { portvalues[i].pid = input_parameter_pids[i]; @@ -927,6 +946,9 @@ LadspaPlugin::do_save_preset (string name) } return uri; +#else + return string(); +#endif } LADSPA_PortDescriptor diff --git a/libs/ardour/ladspa_search_path.cc b/libs/ardour/ladspa_search_path.cc new file mode 100644 index 0000000000..49a2645f5d --- /dev/null +++ b/libs/ardour/ladspa_search_path.cc @@ -0,0 +1,61 @@ +/* + 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 "pbd/pathexpand.h" + +#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 PLATFORM_WINDOWS + 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"); +#endif + +#ifdef __APPLE__ + spath.push_back (path_expand ("~/Library/Audio/Plug-Ins/LADSPA")); + spath.push_back ("/Library/Audio/Plug-Ins/LADSPA"); +#endif + + return spath_env + spath; +} + +} // namespace ARDOUR diff --git a/libs/ardour/ltc_slave.cc b/libs/ardour/ltc_slave.cc index b4c4a1446b..ced0226d00 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" @@ -150,7 +150,7 @@ LTC_Slave::reset() } void -LTC_Slave::parse_ltc(const pframes_t nframes, const Sample* const in, const framecnt_t posinfo) +LTC_Slave::parse_ltc(const ARDOUR::pframes_t nframes, const Sample* const in, const ARDOUR::framecnt_t posinfo) { pframes_t i; unsigned char sound[8192]; @@ -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; @@ -591,7 +591,7 @@ LTC_Slave::approximate_current_delta() const snprintf(delta, sizeof(delta), "%s", _("flywheel")); } else { snprintf(delta, sizeof(delta), "\u0394%s%s%" PRIi64 "sm", - LEADINGZERO(abs(current_delta)), PLUSMINUS(-current_delta), abs(current_delta)); + LEADINGZERO(llabs(current_delta)), PLUSMINUS(-current_delta), llabs(current_delta)); } return std::string(delta); } diff --git a/libs/ardour/lv2_bundled_search_path.cc b/libs/ardour/lv2_bundled_search_path.cc index d8cd1c1075..2454ea2ae1 100644 --- a/libs/ardour/lv2_bundled_search_path.cc +++ b/libs/ardour/lv2_bundled_search_path.cc @@ -29,10 +29,10 @@ using namespace PBD; namespace ARDOUR { -SearchPath +Searchpath lv2_bundled_search_path () { - SearchPath spath( ardour_dll_directory () ); + Searchpath spath( ardour_dll_directory () ); spath.add_subdirectory_to_paths ("LV2"); return spath; diff --git a/libs/ardour/lv2_evbuf.c b/libs/ardour/lv2_evbuf.c index 8942d19a9b..fba7fd521d 100644 --- a/libs/ardour/lv2_evbuf.c +++ b/libs/ardour/lv2_evbuf.c @@ -219,7 +219,7 @@ lv2_evbuf_get(LV2_Evbuf_Iterator iter, *subframes = 0; *type = aev->body.type; *size = aev->body.size; - *data = LV2_ATOM_BODY(&aev->body); + *data = (uint8_t*)LV2_ATOM_BODY(&aev->body); break; } diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index dc7805c273..e6b3c2d56e 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -1111,7 +1112,7 @@ LV2Plugin::do_remove_preset(string name) name + ".ttl" ) ); - unlink(preset_file.c_str()); + ::g_unlink(preset_file.c_str()); } bool @@ -1139,16 +1140,16 @@ LV2Plugin::write_to(RingBuffer* dest, uint32_t size, const uint8_t* body) { - const uint32_t buf_size = sizeof(UIMessage) + size; - uint8_t buf[buf_size]; + const uint32_t buf_size = sizeof(UIMessage) + size; + vector buf(buf_size); - UIMessage* msg = (UIMessage*)buf; + UIMessage* msg = (UIMessage*)&buf[0]; msg->index = index; msg->protocol = protocol; msg->size = size; memcpy(msg + 1, body, size); - return (dest->write(buf, buf_size) == buf_size); + return (dest->write(&buf[0], buf_size) == buf_size); } bool @@ -1227,13 +1228,13 @@ LV2Plugin::emit_to_ui(void* controller, UIMessageSink sink) error << "Error reading from Plugin=>UI RingBuffer" << endmsg; break; } - uint8_t body[msg.size]; - if (_to_ui->read(body, msg.size) != msg.size) { + vector body(msg.size); + if (_to_ui->read(&body[0], msg.size) != msg.size) { error << "Error reading from Plugin=>UI RingBuffer" << endmsg; break; } - sink(controller, msg.index, msg.size, msg.protocol, body); + sink(controller, msg.index, msg.size, msg.protocol, &body[0]); read_space -= sizeof(msg) + msg.size; } @@ -1716,15 +1717,15 @@ LV2Plugin::connect_and_run(BufferSet& bufs, error << "Error reading from UI=>Plugin RingBuffer" << endmsg; break; } - uint8_t body[msg.size]; - if (_from_ui->read(body, msg.size) != msg.size) { + vector body(msg.size); + if (_from_ui->read(&body[0], msg.size) != msg.size) { error << "Error reading from UI=>Plugin RingBuffer" << endmsg; break; } if (msg.protocol == urids.atom_eventTransfer) { LV2_Evbuf* buf = _ev_buffers[msg.index]; LV2_Evbuf_Iterator i = lv2_evbuf_end(buf); - const LV2_Atom* const atom = (const LV2_Atom*)body; + const LV2_Atom* const atom = (const LV2_Atom*)&body[0]; if (!lv2_evbuf_write(&i, nframes, 0, atom->type, atom->size, (const uint8_t*)(atom + 1))) { error << "Failed to write data to LV2 event buffer\n"; @@ -2034,7 +2035,7 @@ LV2World::load_bundled_plugins() vector *plugin_objects = scanner (ARDOUR::lv2_bundled_search_path().to_string(), lv2_filter, 0, true, true); if (plugin_objects) { for ( vector::iterator x = plugin_objects->begin(); x != plugin_objects->end (); ++x) { -#ifdef WINDOWS +#ifdef PLATFORM_WINDOWS string uri = "file:///" + **x + "/"; #else string uri = "file://" + **x + "/"; diff --git a/libs/ardour/meter.cc b/libs/ardour/meter.cc index ec736fef69..80690bd744 100644 --- a/libs/ardour/meter.cc +++ b/libs/ardour/meter.cc @@ -18,6 +18,7 @@ #include #include +#include #include "pbd/compose.h" @@ -153,7 +154,7 @@ void PeakMeter::reset_max () { for (size_t i = 0; i < _max_peak_power.size(); ++i) { - _max_peak_power[i] = -INFINITY; + _max_peak_power[i] = -std::numeric_limits::infinity(); _max_peak_signal[i] = 0; } @@ -163,7 +164,7 @@ PeakMeter::reset_max () if (n < n_midi) { _visible_peak_power[n] = 0; } else { - _visible_peak_power[n] = -INFINITY; + _visible_peak_power[n] = -std::numeric_limits::infinity(); } } } @@ -302,7 +303,7 @@ PeakMeter::meter () _peak_signal[n] = 0; /* ... to here */ if (n < n_midi) { - _max_peak_power[n] = -INFINITY; // std::max (new_peak, _max_peak_power[n]); // XXX + _max_peak_power[n] = -std::numeric_limits::infinity(); // std::max (new_peak, _max_peak_power[n]); // XXX _max_peak_signal[n] = 0; if (midi_meter_falloff == 0.0f || new_peak > _visible_peak_power[n]) { ; @@ -336,7 +337,7 @@ PeakMeter::meter () } else { // do falloff new_peak = _visible_peak_power[n] - (audio_meter_falloff); - _visible_peak_power[n] = std::max (new_peak, -INFINITY); + _visible_peak_power[n] = std::max (new_peak, -std::numeric_limits::infinity()); } } } diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc index 762d94469c..8c95272fde 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" @@ -261,7 +260,7 @@ MIDIClock_Slave::stop (Parser& /*parser*/, framepos_t /*timestamp*/) } void -MIDIClock_Slave::position (Parser& /*parser*/, byte* message, size_t size) +MIDIClock_Slave::position (Parser& /*parser*/, MIDI::byte* message, size_t size) { // we are note supposed to get position messages while we are running // so lets be robust and ignore those @@ -270,8 +269,8 @@ MIDIClock_Slave::position (Parser& /*parser*/, byte* message, size_t size) } assert(size == 3); - byte lsb = message[1]; - byte msb = message[2]; + MIDI::byte lsb = message[1]; + MIDI::byte msb = message[2]; assert((lsb <= 0x7f) && (msb <= 0x7f)); uint16_t position_in_sixteenth_notes = (uint16_t(msb) << 7) | uint16_t(lsb); diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 4771f7128c..a1a640cd1c 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -26,11 +26,10 @@ #include #include #include -#include // for ffs(3) #include -#include #include "pbd/error.h" +#include "pbd/ffs.h" #include "pbd/basename.h" #include #include "pbd/xml++.h" @@ -439,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_patch_manager.cc b/libs/ardour/midi_patch_manager.cc index 4bced4e46d..f2d964bb77 100644 --- a/libs/ardour/midi_patch_manager.cc +++ b/libs/ardour/midi_patch_manager.cc @@ -28,6 +28,7 @@ #include "ardour/session.h" #include "ardour/session_directory.h" #include "ardour/midi_patch_manager.h" + #include "ardour/midi_patch_search_path.h" #include "i18n.h" @@ -102,7 +103,7 @@ MidiPatchManager::refresh() _master_devices_by_model.clear(); _all_models.clear(); - SearchPath search_path = midi_patch_search_path (); + Searchpath search_path = midi_patch_search_path (); Glib::PatternSpec pattern (string("*.midnam")); vector result; diff --git a/libs/ardour/midi_patch_search_path.cc b/libs/ardour/midi_patch_search_path.cc index ccad1de466..c099c379e9 100644 --- a/libs/ardour/midi_patch_search_path.cc +++ b/libs/ardour/midi_patch_search_path.cc @@ -31,14 +31,14 @@ using namespace PBD; namespace ARDOUR { -SearchPath +Searchpath midi_patch_search_path () { - SearchPath spath (ardour_data_search_path()); + Searchpath spath (ardour_data_search_path()); spath.add_subdirectory_to_paths(midi_patch_dir_name); bool midi_patch_path_defined = false; - SearchPath spath_env (Glib::getenv(midi_patch_env_variable_name, midi_patch_path_defined)); + Searchpath spath_env (Glib::getenv(midi_patch_env_variable_name, midi_patch_path_defined)); if (midi_patch_path_defined) { spath += spath_env; 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/midi_track.cc b/libs/ardour/midi_track.cc index 7dff7ac639..6a998de90e 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" @@ -321,7 +320,7 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame if (!lm.locked()) { boost::shared_ptr diskstream = midi_diskstream(); framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes); - if (can_internal_playback_seek(std::llabs(playback_distance))) { + if (can_internal_playback_seek(llabs(playback_distance))) { /* TODO should declick, and/or note-off */ internal_playback_seek(playback_distance); } @@ -513,7 +512,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: @@ -633,9 +632,9 @@ void MidiTrack::MidiControl::set_value(double val) { bool valid = false; - if (std::isinf(val)) { + if (isinf(val)) { cerr << "MIDIControl value is infinity" << endl; - } else if (std::isnan(val)) { + } else if (isnan(val)) { cerr << "MIDIControl value is NaN" << endl; } else if (val < _list->parameter().min()) { cerr << "MIDIControl value is < " << _list->parameter().min() << endl; diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc index b80370ec6a..06940c1e34 100644 --- a/libs/ardour/midi_ui.cc +++ b/libs/ardour/midi_ui.cc @@ -77,7 +77,9 @@ MidiControlUI::midi_input_handler (IOCondition ioc, AsyncMIDIPort* port) if (ioc & IO_IN) { +#ifndef PLATFORM_WINDOWS CrossThreadChannel::drain (port->selectable()); +#endif DEBUG_TRACE (DEBUG::MidiIO, string_compose ("data available on %1\n", ((ARDOUR::Port*)port)->name())); framepos_t now = _session.engine().sample_time(); diff --git a/libs/ardour/mix.cc b/libs/ardour/mix.cc index 3a873a8e50..220cd0660c 100644 --- a/libs/ardour/mix.cc +++ b/libs/ardour/mix.cc @@ -24,6 +24,8 @@ #include "ardour/runtime_functions.h" #include +using std::min; +using std::max; using namespace ARDOUR; #if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS) @@ -93,22 +95,22 @@ default_compute_peak (const ARDOUR::Sample * buf, pframes_t nsamples, float curr } void -default_find_peaks (const ARDOUR::Sample * buf, pframes_t nframes, float *min, float *max) +default_find_peaks (const ARDOUR::Sample * buf, pframes_t nframes, float *minf, float *maxf) { pframes_t i; float a, b; - a = *max; - b = *min; + a = *maxf; + b = *minf; for (i = 0; i < nframes; i++) { - a = fmax (buf[i], a); - b = fmin (buf[i], b); + a = max (buf[i], a); + b = min (buf[i], b); } - *max = a; - *min = b; + *maxf = a; + *minf = b; } void diff --git a/libs/ardour/msvc/msvc_libardour.cc b/libs/ardour/msvc/msvc_libardour.cc new file mode 100644 index 0000000000..bd186728ea --- /dev/null +++ b/libs/ardour/msvc/msvc_libardour.cc @@ -0,0 +1,276 @@ +/* + 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. + +*/ + +#if (defined(PLATFORM_WINDOWS) && !defined(COMPILER_CYGWIN)) +#include +#include +#ifdef COMPILER_MSVC +#pragma warning(disable:4996) +#endif +#else +#include +#endif + +#include +#include +#include + +namespace ARDOUR { + +//*************************************************************** +// +// placeholder_for_non_msvc_specific_function() +// +// Description +// +// Returns: +// +// On Success: +// +// On Failure: +// +/* LIBARDOUR_API char* LIBARDOUR_APICALLTYPE + placeholder_for_non_msvc_specific_function() +{ +char *pRet = buffer; + + return (pRet); +} +*/ + +} // namespace ARDOUR + +#ifdef COMPILER_MSVC + +#include + +namespace ARDOUR { + +//*************************************************************** +// +// symlink() +// +// Emulates POSIX symlink() but creates a Windows shortcut. To +// create a Windows shortcut the supplied shortcut name must end +// in ".lnk" +// Note that you can only create a shortcut in a folder for which +// you have appropriate access rights. Note also that the folder +// must already exist. If it doesn't exist or if you don't have +// sufficient access rights to it, symlink() will generate an +// error (in common with its POSIX counterpart). +// +// Returns: +// +// On Success: Zero +// On Failure: -1 ('errno' will contain the specific error) +// +LIBARDOUR_API int LIBARDOUR_APICALLTYPE +symlink(const char *dest, const char *shortcut, const char *working_directory /*= NULL */) +{ +IShellLinkA *pISL = NULL; +IPersistFile *ppf = NULL; +int ret = (-1); + + if ((NULL == dest) || (NULL == shortcut) || (strlen(shortcut) < 5) || (strlen(dest) == 0)) + _set_errno(EINVAL); + else if ((strlen(shortcut) > _MAX_PATH) || (strlen(dest) > _MAX_PATH)) + _set_errno(ENAMETOOLONG); + else if (Glib::file_test(shortcut, Glib::FILE_TEST_EXISTS)) + _set_errno(EEXIST); + else + { + HRESULT hRet = 0; + + if (SUCCEEDED (hRet = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pISL))) + { + if (SUCCEEDED (pISL->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf))) + { + char sc_path_lower_case[_MAX_PATH]; + WCHAR shortcut_path[_MAX_PATH]; + + // Fail if the path isn't a shortcut + strcpy(sc_path_lower_case, shortcut); + strlwr(sc_path_lower_case); + const char *p = strlen(sc_path_lower_case) + sc_path_lower_case - 4; + + if (0 == strcmp(p, ".lnk")) + { + HRESULT hr; + + // We're apparently been given valid Windows shortcut name + MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, shortcut, -1, shortcut_path, _MAX_PATH); + + // Create the shortcut + if (FAILED (hr = ppf->Load(shortcut_path, STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE))) + hr = ppf->Save(shortcut_path, TRUE); + + if (S_OK == hr) + { + // Set its target path + if (S_OK == pISL->SetPath(dest)) + { + // Set its working directory + if (working_directory) + p = working_directory; + else + p = ""; + + if (S_OK == pISL->SetWorkingDirectory(p)) + { + // Set its 'Show' command + if (S_OK == pISL->SetShowCmd(SW_SHOWNORMAL)) + { + // And finally, set its icon to the same file as the target. + // For the time being, don't fail if the target has no icon. + if (Glib::file_test(dest, Glib::FILE_TEST_IS_DIR)) + pISL->SetIconLocation("%SystemRoot%\\system32\\shell32.dll", 1); + else + pISL->SetIconLocation(dest, 0); + + if (S_OK == ppf->Save(shortcut_path, FALSE)) + { + Sleep(1500); + + ret = 0; + // _set_errno(0); + } + else + _set_errno(EACCES); + } + else + _set_errno(EACCES); + } + else + _set_errno(EACCES); + } + else + _set_errno(EACCES); + } + else + _set_errno(EBADF); + } + else + _set_errno(EACCES); + } + else + _set_errno(EBADF); + } + else + { + if (E_POINTER == hRet) + _set_errno(EINVAL); + else + _set_errno(EIO); + } + } + + return (ret); +} + + +//*************************************************************** +// +// readlink() +// +// Emulates POSIX readlink() but using Windows shortcuts +// Doesn't (currently) resolve shortcuts to shortcuts. This would +// be quite simple to incorporate but we'd need to check for +// recursion (i.e. a shortcut that points to an earlier shortcut +// in the same chain). +// +// Returns: +// +// On Success: Zero +// On Failure: -1 ('errno' will contain the specific error) +// +LIBARDOUR_API int LIBARDOUR_APICALLTYPE +readlink(const char *__restrict shortcut, char *__restrict buf, size_t bufsize) +{ +IShellLinkA *pISL = NULL; +IPersistFile *ppf = NULL; +int ret = (-1); + + if ((NULL == shortcut) || (NULL == buf) || (strlen(shortcut) < 5) || (bufsize == 0)) + _set_errno(EINVAL); + else if ((bufsize > _MAX_PATH) || (strlen(shortcut) > _MAX_PATH)) + _set_errno(ENAMETOOLONG); + else + { + HRESULT hRet = 0; + + if (SUCCEEDED (hRet = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pISL))) + { + if (SUCCEEDED (pISL->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf))) + { + char target_path[_MAX_PATH]; + WCHAR shortcut_path[_MAX_PATH]; + + // Fail if the path isn't a shortcut + strcpy(target_path, shortcut); // Use 'target_path' temporarily + strlwr(target_path); + const char *p = strlen(target_path) + target_path - 4; + + if (0 == strcmp(p, ".lnk")) + { + // We're apparently pointing to a valid Windows shortcut + MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, shortcut, -1, shortcut_path, _MAX_PATH); + + // Load the shortcut into our persistent file + if (SUCCEEDED (ppf->Load(shortcut_path, 0))) + { + // Read the target information from the shortcut object + if (S_OK == (pISL->GetPath (target_path, _MAX_PATH, NULL, SLGP_UNCPRIORITY))) + { + strncpy(buf, target_path, bufsize); + ret = ((ret = strlen(buf)) > bufsize) ? bufsize : ret; + // _set_errno(0); + } + else + _set_errno(EACCES); + } + else + _set_errno(EBADF); + } + else + _set_errno(EINVAL); + } + else + _set_errno(EBADF); + } + else + { + if (E_POINTER == hRet) + _set_errno(EINVAL); + else + _set_errno(EIO); + } + + if (ppf) + ppf->Release(); + + if (pISL) + pISL->Release(); + } + + return (ret); +} + +} // namespace ARDOUR + +#endif // COMPILER_MSVC diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc index e9071af619..0dee2a071b 100644 --- a/libs/ardour/mtc_slave.cc +++ b/libs/ardour/mtc_slave.cc @@ -19,11 +19,11 @@ */ #include #include -#include #include #include #include "pbd/error.h" +#include "pbd/pthread_utils.h" #include "ardour/audioengine.h" #include "ardour/debug.h" @@ -32,6 +32,8 @@ #include "ardour/session.h" #include "ardour/slave.h" +#include + #include "i18n.h" using namespace std; @@ -236,7 +238,7 @@ MTC_Slave::read_current (SafeTime *st) const do { if (tries == 10) { error << _("MTC Slave: atomic read of current time failed, sleeping!") << endmsg; - usleep (20); + Glib::usleep (20); tries = 0; } *st = current; @@ -299,7 +301,7 @@ MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr, framepos_t now) * when a full TC has been received * OR on locate */ void -MTC_Slave::update_mtc_time (const byte *msg, bool was_full, framepos_t now) +MTC_Slave::update_mtc_time (const MIDI::byte *msg, bool was_full, framepos_t now) { busy_guard1++; @@ -307,8 +309,11 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full, framepos_t now) to use a timestamp indicating when this MTC time was received. example: when we received a locate command via MMC. */ - +#ifdef COMPILER_MSVC + DEBUG_TRACE (DEBUG::MTC, string_compose ("MTC::update_mtc_time - TID:%1\n", ::pthread_self().p)); +#else DEBUG_TRACE (DEBUG::MTC, string_compose ("MTC::update_mtc_time - TID:%1\n", ::pthread_self())); +#endif TimecodeFormat tc_format; bool reset_tc = true; @@ -488,7 +493,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++; diff --git a/libs/ardour/panner_manager.cc b/libs/ardour/panner_manager.cc index 24fa10e225..3c9623f3e6 100644 --- a/libs/ardour/panner_manager.cc +++ b/libs/ardour/panner_manager.cc @@ -29,6 +29,7 @@ #include "ardour/debug.h" #include "ardour/panner_manager.h" + #include "ardour/panner_search_path.h" #include "i18n.h" @@ -65,7 +66,7 @@ static bool panner_filter (const string& str, void */*arg*/) #ifdef __APPLE__ return str[0] != '.' && (str.length() > 6 && str.find (".dylib") == (str.length() - 6)); #else - return str[0] != '.' && (str.length() > 3 && str.find (".so") == (str.length() - 3)); + return str[0] != '.' && (str.length() > 3 && (str.find (".so") == (str.length() - 3) || str.find (".dll") == (str.length() - 4))); #endif } @@ -83,6 +84,7 @@ PannerManager::discover_panners () for (vector::iterator i = panner_modules->begin(); i != panner_modules->end(); ++i) { panner_discover (**i); } + vector_delete (panner_modules); } @@ -113,31 +115,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/panner_search_path.cc b/libs/ardour/panner_search_path.cc index 49349238e4..2889063ca4 100644 --- a/libs/ardour/panner_search_path.cc +++ b/libs/ardour/panner_search_path.cc @@ -31,13 +31,18 @@ using namespace PBD; namespace ARDOUR { -SearchPath +Searchpath panner_search_path () { - SearchPath spath(user_config_directory ()); + Searchpath spath(user_config_directory ()); spath += ardour_dll_directory (); spath.add_subdirectory_to_paths(panner_dir_name); +<<<<<<< HEAD spath += SearchPath(Glib::getenv(panner_env_variable_name)); +======= + + spath += Searchpath(Glib::getenv(panner_env_variable_name)); +>>>>>>> windows+cc return spath; } diff --git a/libs/ardour/pcm_utils.cc b/libs/ardour/pcm_utils.cc index de3497d977..ae3bd4a4e0 100644 --- a/libs/ardour/pcm_utils.cc +++ b/libs/ardour/pcm_utils.cc @@ -17,8 +17,10 @@ */ +#ifdef COMPILER_MSVC +#include +#endif #include "ardour/pcm_utils.h" - #include using namespace std; diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index bb79801c9f..47462a3575 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -1997,11 +1997,11 @@ Playlist::find_next_region (framepos_t frame, RegionPoint point, int dir) freeze (); /* add the added regions */ - for (RegionListProperty::ChangeContainer::iterator i = change.added.begin(); i != change.added.end(); ++i) { + for (RegionListProperty::ChangeContainer::const_iterator i = change.added.begin(); i != change.added.end(); ++i) { add_region_internal ((*i), (*i)->position()); } /* remove the removed regions */ - for (RegionListProperty::ChangeContainer::iterator i = change.removed.begin(); i != change.removed.end(); ++i) { + for (RegionListProperty::ChangeContainer::const_iterator i = change.removed.begin(); i != change.removed.end(); ++i) { remove_region (*i); } @@ -2488,7 +2488,7 @@ Playlist::uses_source (boost::shared_ptr src) const { RegionReadLock rlock (const_cast (this)); - for (set >::iterator r = all_regions.begin(); r != all_regions.end(); ++r) { + for (set >::const_iterator r = all_regions.begin(); r != all_regions.end(); ++r) { if ((*r)->uses_source (src)) { return true; } @@ -2533,7 +2533,7 @@ Playlist::region_by_id (const ID& id) const { /* searches all regions ever added to this playlist */ - for (set >::iterator i = all_regions.begin(); i != all_regions.end(); ++i) { + for (set >::const_iterator i = all_regions.begin(); i != all_regions.end(); ++i) { if ((*i)->id() == id) { return *i; } diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc index 9b2170c349..11d859ed8c 100644 --- a/libs/ardour/plugin.cc +++ b/libs/ardour/plugin.cc @@ -27,12 +27,16 @@ #include #include // so libraptor doesn't complain #include +#ifndef COMPILER_MSVC #include +#endif #include #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 b5be296b1a..e93566068b 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -25,11 +25,13 @@ #include #include -#include -#include #include #include +#ifdef HAVE_LRDF +#include +#endif + #ifdef WINDOWS_VST_SUPPORT #include "fst.h" #include "pbd/basename.h" @@ -43,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" @@ -55,6 +59,8 @@ #include "ardour/plugin_manager.h" #include "ardour/rc_configuration.h" +#include "ardour/ladspa_search_path.h" + #ifdef LV2_SUPPORT #include "ardour/lv2_plugin.h" #endif @@ -77,6 +83,8 @@ #include "i18n.h" +#include "ardour/debug.h" + using namespace ARDOUR; using namespace PBD; using namespace std; @@ -126,10 +134,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"))) { @@ -198,91 +202,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 += ":"; + DEBUG_TRACE (DEBUG::PluginManager, string_compose ("LADSPA: search along: [%1]\n", ladspa_search_path().to_string())); - ladspa_path += standard_paths[i]; + Glib::PatternSpec so_extension_pattern("*.so"); + Glib::PatternSpec dylib_extension_pattern("*.dylib"); + Glib::PatternSpec dll_extension_pattern("*.dll"); + find_matching_files_in_search_path (ladspa_search_path (), + so_extension_pattern, ladspa_modules); + + 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); + + for (vector::iterator i = ladspa_modules.begin(); i != ladspa_modules.end(); ++i) { + ladspa_discover (*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)); -} - -int -PluginManager::ladspa_discover_from_path (string /*path*/) -{ - PathScanner scanner; - vector *plugin_objects; - vector::iterator x; - int ret = 0; - - plugin_objects = scanner (ladspa_path, ladspa_filter, 0, false, true); - - if (plugin_objects) { - for (x = plugin_objects->begin(); x != plugin_objects->end (); ++x) { - ladspa_discover (**x); - } - - vector_delete (plugin_objects); - } - - return ret; } static bool rdf_filter (const string &str, void* /*arg*/) @@ -315,7 +266,7 @@ PluginManager::add_lxvst_presets() void PluginManager::add_presets(string domain) { - +#ifdef HAVE_LRDF PathScanner scanner; vector *presets; vector::iterator x; @@ -338,11 +289,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; @@ -360,30 +313,36 @@ PluginManager::add_lrdf_data (const string &path) vector_delete (rdf_files); } +#endif } int PluginManager::ladspa_discover (string path) { - void *module; + 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; - 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; + + 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; @@ -437,6 +396,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 @@ -448,6 +409,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 +467,9 @@ PluginManager::get_ladspa_category (uint32_t plugin_id) } else { return label; } +#else + return ("Unknown"); +#endif } #ifdef LV2_SUPPORT diff --git a/libs/ardour/port.cc b/libs/ardour/port.cc index cf961d6828..bc5d26fb80 100644 --- a/libs/ardour/port.cc +++ b/libs/ardour/port.cc @@ -21,7 +21,9 @@ #include "libardour-config.h" #endif +#ifndef PLATFORM_WINDOWS #include // so that we can test for new functions at runtime +#endif #include "pbd/compose.h" #include "pbd/error.h" diff --git a/libs/ardour/port_insert.cc b/libs/ardour/port_insert.cc index c352e22e55..fa09ea05ac 100644 --- a/libs/ardour/port_insert.cc +++ b/libs/ardour/port_insert.cc @@ -249,7 +249,9 @@ PortInsert::signal_latency() const bool PortInsert::configure_io (ChanCount in, ChanCount out) { +#ifndef PLATFORM_WINDOWS assert (!AudioEngine::instance()->process_lock().trylock()); +#endif /* for an insert, processor input corresponds to IO output, and vice versa */ diff --git a/libs/ardour/port_set.cc b/libs/ardour/port_set.cc index 6096e356f5..c7f5e2e674 100644 --- a/libs/ardour/port_set.cc +++ b/libs/ardour/port_set.cc @@ -56,7 +56,7 @@ static bool sort_ports_by_name (boost::shared_ptr a, boost::shared_ptr buf(len); if ((last_period = old.find_last_of ('.')) == string::npos) { @@ -603,8 +603,8 @@ RegionFactory::new_region_name (string old) number++; - snprintf (buf, len, "%s%" PRIu32 "%s", old.substr (0, last_period + 1).c_str(), number, remainder.c_str()); - sbuf = buf; + snprintf (&buf[0], len, "%s%" PRIu32 "%s", old.substr (0, last_period + 1).c_str(), number, remainder.c_str()); + sbuf = &buf[0]; if (region_name_map.find (sbuf) == region_name_map.end ()) { break; @@ -612,7 +612,7 @@ RegionFactory::new_region_name (string old) } if (number != (UINT_MAX-1)) { - return buf; + return &buf[0]; } error << string_compose (_("cannot create new name for region \"%1\""), old) << endmsg; diff --git a/libs/ardour/resampled_source.cc b/libs/ardour/resampled_source.cc index 6184e1a3d6..0a81319108 100644 --- a/libs/ardour/resampled_source.cc +++ b/libs/ardour/resampled_source.cc @@ -26,7 +26,11 @@ using namespace ARDOUR; using namespace PBD; +#ifdef PLATFORM_WINDOWS +const uint32_t ResampledImportableSource::blocksize = 524288U; +#else const uint32_t ResampledImportableSource::blocksize = 16384U; +#endif ResampledImportableSource::ResampledImportableSource (boost::shared_ptr src, framecnt_t rate, SrcQuality srcq) : source (src) diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 6f23e920d4..4b9285c1c8 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1639,7 +1639,9 @@ Route::reset_instrument_info () int Route::configure_processors (ProcessorStreams* err) { +#ifndef PLATFORM_WINDOWS assert (!AudioEngine::instance()->process_lock().trylock()); +#endif if (!_in_configure_processors) { Glib::Threads::RWLock::WriterLock lm (_processor_lock); @@ -1710,7 +1712,9 @@ Route::try_configure_processors_unlocked (ChanCount in, ProcessorStreams* err) int Route::configure_processors_unlocked (ProcessorStreams* err) { +#ifndef PLATFORM_WINDOWS assert (!AudioEngine::instance()->process_lock().trylock()); +#endif if (_in_configure_processors) { return 0; @@ -2850,7 +2854,7 @@ Route::feeds (boost::shared_ptr other, bool* via_sends_only) { const FedBy& fed_by (other->fed_by()); - for (FedBy::iterator f = fed_by.begin(); f != fed_by.end(); ++f) { + for (FedBy::const_iterator f = fed_by.begin(); f != fed_by.end(); ++f) { boost::shared_ptr sr = f->r.lock(); if (sr && (sr.get() == this)) { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 115fcd750a..b880883e09 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" @@ -4581,18 +4581,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 { @@ -4600,10 +4600,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; } } @@ -4612,49 +4612,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; @@ -4662,16 +4643,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. @@ -4683,18 +4662,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; } } 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_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 diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc index b2fbaf602c..2ce25b5a48 100644 --- a/libs/ardour/session_ltc.cc +++ b/libs/ardour/session_ltc.cc @@ -31,7 +31,6 @@ using namespace std; using namespace ARDOUR; -using namespace MIDI; using namespace PBD; using namespace Timecode; diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 6d3083df77..ea6dfe81cf 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include @@ -34,6 +32,7 @@ #include "pbd/error.h" #include "pbd/pthread_utils.h" +#include "pbd/timersub.h" #include "timecode/time.h" @@ -349,7 +348,7 @@ Session::mmc_record_enable (MIDI::MachineControl &mmc, size_t trk, bool enabled) * @param t time to send. */ int -Session::send_full_time_code (framepos_t const t, pframes_t nframes) +Session::send_full_time_code (framepos_t const t, MIDI::pframes_t nframes) { /* This function could easily send at a given frame offset, but would * that be useful? Does ardour do sub-block accurate locating? [DR] */ @@ -440,7 +439,7 @@ Session::send_full_time_code (framepos_t const t, pframes_t nframes) * earlier already this cycle by send_full_time_code) */ int -Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_frame, pframes_t nframes) +Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_frame, ARDOUR::pframes_t nframes) { if (_engine.freewheeling() || !_send_qf_mtc || transmitting_timecode_time.negative || (next_quarter_frame_to_send < 0)) { // cerr << "(MTC) Not sending MTC\n"; @@ -512,7 +511,7 @@ Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_f assert (msg_time < end_frame); /* convert from session frames back to JACK frames using the transport speed */ - pframes_t const out_stamp = (msg_time - start_frame) / _transport_speed; + ARDOUR::pframes_t const out_stamp = (msg_time - start_frame) / _transport_speed; assert (out_stamp < nframes); MidiBuffer& mb (_midi_ports->mtc_output_port()->get_midi_buffer(nframes)); diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index b2c4640880..b586ab196e 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -221,11 +221,11 @@ SessionPlaylists::get (vector >& s) const { Glib::Threads::Mutex::Lock lm (lock); - for (List::iterator i = playlists.begin(); i != playlists.end(); ++i) { + for (List::const_iterator i = playlists.begin(); i != playlists.end(); ++i) { s.push_back (*i); } - for (List::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) { + for (List::const_iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) { s.push_back (*i); } } @@ -448,11 +448,11 @@ SessionPlaylists::region_use_count (boost::shared_ptr region) const Glib::Threads::Mutex::Lock lm (lock); uint32_t cnt = 0; - for (List::iterator i = playlists.begin(); i != playlists.end(); ++i) { + for (List::const_iterator i = playlists.begin(); i != playlists.end(); ++i) { cnt += (*i)->region_use_count (region); } - for (List::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) { + for (List::const_iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) { cnt += (*i)->region_use_count (region); } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index f3ad9d66dd..bbd3432205 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -33,15 +33,14 @@ #include #include #include -#include -#include #include -#include #include #ifdef HAVE_SYS_VFS_H #include -#else +#endif + +#ifdef __APPLE__ #include #include #endif @@ -69,11 +68,13 @@ #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" #include "pbd/convert.h" #include "pbd/clear_dir.h" +#include "pbd/localtime_r.h" #include "ardour/amp.h" #include "ardour/audio_diskstream.h" @@ -355,7 +356,7 @@ Session::post_engine_init () string Session::raid_path () const { - SearchPath raid_search_path; + Searchpath raid_search_path; for (vector::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) { raid_search_path += (*i).path; @@ -376,11 +377,11 @@ Session::setup_raid_path (string path) session_dirs.clear (); - SearchPath search_path(path); - SearchPath sound_search_path; - SearchPath midi_search_path; + Searchpath search_path(path); + Searchpath sound_search_path; + Searchpath midi_search_path; - for (SearchPath::const_iterator i = search_path.begin(); i != search_path.end(); ++i) { + for (Searchpath::const_iterator i = search_path.begin(); i != search_path.end(); ++i) { sp.path = *i; sp.blocks = 0; // not needed session_dirs.push_back (sp); @@ -726,9 +727,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; @@ -2041,6 +2042,54 @@ Session::refresh_disk_space () _total_free_4k_blocks_uncertain = true; } } +#elif defined (COMPILER_MSVC) + vector scanned_volumes; + vector::iterator j; + vector::iterator i; + DWORD nSectorsPerCluster, nBytesPerSector, + nFreeClusters, nTotalClusters; + char disk_drive[4]; + bool volume_found; + + _total_free_4k_blocks = 0; + + for (i = session_dirs.begin(); i != session_dirs.end(); i++) { + strncpy (disk_drive, (*i).path.c_str(), 3); + disk_drive[3] = 0; + strupr(disk_drive); + + volume_found = false; + if (0 != (GetDiskFreeSpace(disk_drive, &nSectorsPerCluster, &nBytesPerSector, &nFreeClusters, &nTotalClusters))) + { + int64_t nBytesPerCluster = nBytesPerSector * nSectorsPerCluster; + int64_t nFreeBytes = nBytesPerCluster * (int64_t)nFreeClusters; + i->blocks = (uint32_t)(nFreeBytes / 4096); + + for (j = scanned_volumes.begin(); j != scanned_volumes.end(); j++) { + if (0 == j->compare(disk_drive)) { + volume_found = true; + break; + } + } + + if (!volume_found) { + scanned_volumes.push_back(disk_drive); + _total_free_4k_blocks += i->blocks; + } + } + } + + if (0 == _total_free_4k_blocks) { + strncpy (disk_drive, path().c_str(), 3); + disk_drive[3] = 0; + + if (0 != (GetDiskFreeSpace(disk_drive, &nSectorsPerCluster, &nBytesPerSector, &nFreeClusters, &nTotalClusters))) + { + int64_t nBytesPerCluster = nBytesPerSector * nSectorsPerCluster; + int64_t nFreeBytes = nBytesPerCluster * (int64_t)nFreeClusters; + _total_free_4k_blocks = (uint32_t)(nFreeBytes / 4096); + } + } #endif } @@ -2227,7 +2276,7 @@ Session::auto_save() } static bool -state_file_filter (const string &str, void */*arg*/) +state_file_filter (const string &str, void* /*arg*/) { return (str.length() > strlen(statefile_suffix) && str.find (statefile_suffix) == (str.length() - strlen (statefile_suffix))); @@ -2404,7 +2453,7 @@ Session::commit_reversible_command (Command *cmd) } static bool -accept_all_audio_files (const string& path, void */*arg*/) +accept_all_audio_files (const string& path, void* /*arg*/) { if (!Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR)) { return false; @@ -2418,7 +2467,7 @@ accept_all_audio_files (const string& path, void */*arg*/) } static bool -accept_all_midi_files (const string& path, void */*arg*/) +accept_all_midi_files (const string& path, void* /*arg*/) { if (!Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR)) { return false; @@ -2430,7 +2479,7 @@ accept_all_midi_files (const string& path, void */*arg*/) } static bool -accept_all_state_files (const string& path, void */*arg*/) +accept_all_state_files (const string& path, void* /*arg*/) { if (!Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR)) { return false; @@ -2586,6 +2635,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); @@ -2710,9 +2761,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) { @@ -2721,19 +2769,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; - } + tmppath1 = canonical_path (spath); + tmppath2 = canonical_path ((*i)); - if (realpath((*i).c_str(), tmppath2) == 0) { - error << string_compose (_("Cannot expand path %1 (%2)"), - (*i), strerror (errno)) << endmsg; - continue; - } - - if (strcmp(tmppath1, tmppath2) == 0) { + if (tmppath1 == tmppath2) { used = true; break; } @@ -2837,7 +2876,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/session_vst.cc b/libs/ardour/session_vst.cc index 644fb19ffb..06a6b80e99 100644 --- a/libs/ardour/session_vst.cc +++ b/libs/ardour/session_vst.cc @@ -17,7 +17,9 @@ */ +#ifndef COMPILER_MSVC #include +#endif #include #include "ardour/session.h" @@ -59,11 +61,19 @@ intptr_t Session::vst_callback ( if (effect && effect->user) { plug = (VSTPlugin *) (effect->user); session = &plug->session(); +#ifdef COMPILER_MSVC + SHOW_CALLBACK ("am callback 0x%x, opcode = %d, plugin = \"%s\" ", (int) pthread_self().p, opcode, plug->name()); +#else SHOW_CALLBACK ("am callback 0x%x, opcode = %d, plugin = \"%s\" ", (int) pthread_self(), opcode, plug->name()); +#endif } else { plug = 0; session = 0; +#ifdef COMPILER_MSVC + SHOW_CALLBACK ("am callback 0x%x, opcode = %d", (int) pthread_self().p, opcode); +#else SHOW_CALLBACK ("am callback 0x%x, opcode = %d", (int) pthread_self(), opcode); +#endif } switch(opcode){ 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/ardour/sndfile_helpers.cc b/libs/ardour/sndfile_helpers.cc index 459890e829..2e618e043b 100644 --- a/libs/ardour/sndfile_helpers.cc +++ b/libs/ardour/sndfile_helpers.cc @@ -17,7 +17,9 @@ */ +#ifndef COMPILER_MSVC #include +#endif #include #include 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/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index cf75cffba3..1c3144f164 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -26,10 +26,11 @@ #include #include -#include -#include #include +#ifdef PLATFORM_WINDOWS +#include +#endif #include #include "ardour/sndfilesource.h" @@ -184,22 +185,30 @@ SndFileSource::init_sndfile () int SndFileSource::open () { - _descriptor = new SndFileDescriptor (_path, writable(), &_info); + string path_to_open; + +#ifdef PLATFORM_WINDOWS + path_to_open = Glib::locale_from_utf8(_path); +#else + path_to_open = _path; +#endif + + _descriptor = new SndFileDescriptor (path_to_open.c_str(), writable(), &_info); _descriptor->Closed.connect_same_thread (file_manager_connection, boost::bind (&SndFileSource::file_closed, this)); SNDFILE* sf = _descriptor->allocate (); if (sf == 0) { - char errbuf[256]; + char errbuf[1024]; sf_error_str (0, errbuf, sizeof (errbuf) - 1); #ifndef HAVE_COREAUDIO /* if we have CoreAudio, we will be falling back to that if libsndfile fails, so we don't want to see this message. */ - cerr << "failed to open " << _path << " with name " << _name << endl; + cerr << "failed to open " << path_to_open << " with name " << _name << endl; error << string_compose(_("SndFileSource: cannot open file \"%1\" for %2 (%3)"), - _path, (writable() ? "read+write" : "reading"), errbuf) << endmsg; + path_to_open, (writable() ? "read+write" : "reading"), errbuf) << endmsg; #endif return -1; } @@ -253,7 +262,7 @@ SndFileSource::open () if (!_broadcast_info->write_to_file (sf)) { error << string_compose (_("cannot set broadcast info for audio file %1 (%2); dropping broadcast info for this file"), - _path, _broadcast_info->get_error()) + path_to_open, _broadcast_info->get_error()) << endmsg; _flags = Flag (_flags & ~Broadcast); delete _broadcast_info; @@ -541,6 +550,30 @@ SndFileSource::flush_header () return r; } +void +SndFileSource::flush () +{ + if (!_open) { + warning << string_compose (_("attempt to flush an un-opened audio file source (%1)"), _path) << endmsg; + return; + } + + if (!writable()) { + warning << string_compose (_("attempt to flush a non-writable audio file source (%1)"), _path) << endmsg; + return; + } + + SNDFILE* sf = _descriptor->allocate (); + if (sf == 0) { + error << string_compose (_("could not allocate file %1 to flush contents"), _path) << endmsg; + return; + } + + // Hopefully everything OK + sf_write_sync (sf); + _descriptor->release (); +} + int SndFileSource::setup_broadcast_info (framepos_t /*when*/, struct tm& now, time_t /*tnow*/) { @@ -768,12 +801,12 @@ SndFileSource::crossfade (Sample* data, framecnt_t cnt, int fade_in) } else if (xfade < xfade_frames) { - gain_t in[xfade]; - gain_t out[xfade]; + std::vector in(xfade); + std::vector out(xfade); /* short xfade, compute custom curve */ - compute_equal_power_fades (xfade, in, out); + compute_equal_power_fades (xfade, &in[0], &out[0]); for (framecnt_t n = 0; n < xfade; ++n) { xfade_buf[n] = (xfade_buf[n] * out[n]) + (fade_data[n] * in[n]); 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/ardour/sse_functions_xmm.cc b/libs/ardour/sse_functions_xmm.cc index 48212ea8e1..f8a53cc6f8 100644 --- a/libs/ardour/sse_functions_xmm.cc +++ b/libs/ardour/sse_functions_xmm.cc @@ -45,8 +45,11 @@ x86_sse_find_peaks(const ARDOUR::Sample* buf, ARDOUR::pframes_t nframes, float * // use 64 byte prefetch for quadruple quads while (nframes >= 16) { +#ifdef COMPILER_MSVC + _mm_prefetch(((char*)buf+64), 0); // A total guess! Assumed to be eqivalent to +#else // the line below but waiting to be tested !! __builtin_prefetch(buf+64,0,0); - +#endif work = _mm_load_ps(buf); current_min = _mm_min_ps(current_min, work); current_max = _mm_max_ps(current_max, work); diff --git a/libs/ardour/template_utils.cc b/libs/ardour/template_utils.cc index 05007b0ade..b912fdc446 100644 --- a/libs/ardour/template_utils.cc +++ b/libs/ardour/template_utils.cc @@ -37,18 +37,18 @@ using namespace PBD; namespace ARDOUR { -SearchPath +Searchpath template_search_path () { - SearchPath spath (ardour_data_search_path()); + Searchpath spath (ardour_data_search_path()); spath.add_subdirectory_to_paths(templates_dir_name); return spath; } -SearchPath +Searchpath route_template_search_path () { - SearchPath spath (ardour_data_search_path()); + Searchpath spath (ardour_data_search_path()); spath.add_subdirectory_to_paths(route_templates_dir_name); return spath; } @@ -66,7 +66,7 @@ user_route_template_directory () } static bool -template_filter (const string &str, void */*arg*/) +template_filter (const string &str, void* /*arg*/) { if (!Glib::file_test (str, Glib::FILE_TEST_IS_DIR)) { return false; @@ -76,7 +76,7 @@ template_filter (const string &str, void */*arg*/) } static bool -route_template_filter (const string &str, void */*arg*/) +route_template_filter (const string &str, void* /*arg*/) { if (str.find (template_suffix) == str.length() - strlen (template_suffix)) { return true; @@ -97,7 +97,7 @@ find_session_templates (vector& template_names) { vector *templates; PathScanner scanner; - SearchPath spath (template_search_path()); + Searchpath spath (template_search_path()); templates = scanner (spath.to_string(), template_filter, 0, true, true); @@ -133,7 +133,7 @@ find_route_templates (vector& template_names) { vector *templates; PathScanner scanner; - SearchPath spath (route_template_search_path()); + Searchpath spath (route_template_search_path()); templates = scanner (spath.to_string(), route_template_filter, 0, false, true); diff --git a/libs/ardour/test/jack_utils_test.cc b/libs/ardour/test/jack_utils_test.cc new file mode 100644 index 0000000000..7645df6ff3 --- /dev/null +++ b/libs/ardour/test/jack_utils_test.cc @@ -0,0 +1,290 @@ + +#include + +#ifdef PLATFORM_WINDOWS +#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; +} + +bool +get_default_jack_command_line (std::string& command_line) +{ + cout << endl; + + JackCommandLineOptions options; + + CPPUNIT_ASSERT (get_jack_default_server_path (options.server_path)); + + get_jack_default_audio_driver_name (options.driver); + + + // 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 + return get_jack_command_line_string (options, command_line); + +} + +void +JackUtilsTest::test_config () +{ + std::string config_path(get_jack_server_user_config_file_path()); + + cout << "Jack server config file path: " << config_path << endl; + + std::string command_line; + + CPPUNIT_ASSERT (get_default_jack_command_line (command_line)); + + CPPUNIT_ASSERT (write_jack_config_file (config_path, command_line)); +} + + +void +JackUtilsTest::test_command_line () +{ + string command_line; + + // this at least should create a valid jack command line + CPPUNIT_ASSERT (get_default_jack_command_line (command_line)); + + cout << "Default JACK command line: " << command_line << endl; +} diff --git a/libs/ardour/test/jack_utils_test.h b/libs/ardour/test/jack_utils_test.h new file mode 100644 index 0000000000..08fad2fc36 --- /dev/null +++ b/libs/ardour/test/jack_utils_test.h @@ -0,0 +1,31 @@ + +#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_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 (); +}; 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); diff --git a/libs/ardour/test/plugins_test.cc b/libs/ardour/test/plugins_test.cc new file mode 100644 index 0000000000..0e4bddcda6 --- /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/test/resampled_source_test.cc b/libs/ardour/test/resampled_source_test.cc index 5aaf71b7aa..c8ef0f4a95 100644 --- a/libs/ardour/test/resampled_source_test.cc +++ b/libs/ardour/test/resampled_source_test.cc @@ -1,4 +1,4 @@ -// this is included first to avoid SearchPath definition on windows +// this is included first to avoid Searchpath definition on windows #include "test_common.h" #include "pbd/file_utils.h" diff --git a/libs/ardour/test/test_common.cc b/libs/ardour/test/test_common.cc index 61f92972d1..71eba65bbb 100644 --- a/libs/ardour/test/test_common.cc +++ b/libs/ardour/test/test_common.cc @@ -25,10 +25,10 @@ using namespace std; -PBD::SearchPath +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, "ardour_testdata"); #else diff --git a/libs/ardour/test/test_common.h b/libs/ardour/test/test_common.h index 91fd066ac2..bfda543508 100644 --- a/libs/ardour/test/test_common.h +++ b/libs/ardour/test/test_common.h @@ -21,7 +21,7 @@ #include "pbd/search_path.h" -PBD::SearchPath test_search_path (); +PBD::Searchpath test_search_path (); std::string new_test_output_dir (std::string prefix = ""); diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index aa06912913..d1d2372977 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -36,7 +36,9 @@ #include #include #include +#ifndef COMPILER_MSVC #include +#endif #include #include diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index cb40d6eac8..168bd0506e 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -528,8 +528,9 @@ VSTPlugin::connect_and_run (BufferSet& bufs, { Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset); - float *ins[_plugin->numInputs]; - float *outs[_plugin->numOutputs]; + // VC++ doesn't support this C99 extension. Use alloca instead of dynamic array (rather than std::vector which allocs on the heap) + float** ins = (float**)alloca(_plugin->numInputs*sizeof(float*)); + float** outs = (float**)alloca(_plugin->numInputs*sizeof(float*)); int32_t i; const uint32_t nbufs = bufs.count().n_audio(); @@ -552,7 +553,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs, } /* we already know it can support processReplacing */ - _plugin->processReplacing (_plugin, ins, outs, nframes); + _plugin->processReplacing (_plugin, &ins[0], &outs[0], nframes); return 0; } diff --git a/libs/ardour/worker.cc b/libs/ardour/worker.cc index b13398c69d..d5238adb60 100644 --- a/libs/ardour/worker.cc +++ b/libs/ardour/worker.cc @@ -23,6 +23,8 @@ #include "ardour/worker.h" #include "pbd/error.h" +#include + namespace ARDOUR { Worker::Worker(Workee* workee, uint32_t ring_size) @@ -128,7 +130,7 @@ Worker::run() continue; } while (!verify_message_completeness(_requests)) { - ::usleep(2000); + Glib::usleep(2000); if (_exit) { return; } diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 18c2188f6a..21f745e20b 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 import sys @@ -106,6 +107,7 @@ libardour_sources = [ 'io_processor.cc', 'kmeterdsp.cc', 'ladspa_plugin.cc', + 'ladspa_search_path.cc', 'location.cc', 'location_importer.cc', 'ltc_slave.cc', @@ -247,8 +249,11 @@ def configure(conf): autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', exact_version='0.3.2') 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', @@ -451,6 +456,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']) @@ -468,6 +474,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 diff --git a/libs/audiographer/audiographer/broadcast_info.h b/libs/audiographer/audiographer/broadcast_info.h index cdc0aaac3a..dd776d17af 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 diff --git a/libs/audiographer/audiographer/debug_utils.h b/libs/audiographer/audiographer/debug_utils.h index b11f065b42..a8c63e85b6 100644 --- a/libs/audiographer/audiographer/debug_utils.h +++ b/libs/audiographer/audiographer/debug_utils.h @@ -8,6 +8,7 @@ #ifdef __GNUC__ #include +#include #endif #include "audiographer/visibility.h" 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) {} diff --git a/libs/audiographer/private/gdither/gdither.cc b/libs/audiographer/private/gdither/gdither.cc index fe9ecc655a..75e16d7863 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); @@ -292,7 +292,7 @@ inline static void gdither_innner_loop_fp(const GDitherType dt, break; } - clamped = rintf(tmp); + clamped = (double)lrintf(tmp); if (clamped > clamp_u) { clamped = clamp_u; } else if (clamped < clamp_l) { diff --git a/libs/audiographer/src/general/broadcast_info.cc b/libs/audiographer/src/general/broadcast_info.cc index 43e5008e52..df69ac9c79 100644 --- a/libs/audiographer/src/general/broadcast_info.cc +++ b/libs/audiographer/src/general/broadcast_info.cc @@ -34,7 +34,7 @@ namespace AudioGrapher static void snprintf_bounded_null_filled (char* target, size_t target_size, char const * fmt, ...) { - char buf[target_size+1]; + char *buf = (char*)alloca(target_size+1); va_list ap; va_start (ap, fmt); 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); diff --git a/libs/backends/jack/jack_utils.cc b/libs/backends/jack/jack_utils.cc index e009b05cd7..331c164353 100644 --- a/libs/backends/jack/jack_utils.cc +++ b/libs/backends/jack/jack_utils.cc @@ -558,7 +558,7 @@ 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().c_str(), 1); + setenv ("PATH", Searchpath(dirs).to_string().c_str(), 1); #else /* silence a compiler unused variable warning */ (void) dirs; @@ -581,7 +581,7 @@ ARDOUR::get_jack_server_dir_paths (vector& server_dir_paths) server_dir_paths.push_back (Glib::path_get_dirname (execpath)); #endif - SearchPath sp(string(g_getenv("PATH"))); + Searchpath sp(string(g_getenv("PATH"))); #ifdef WIN32 gchar *install_dir = g_win32_get_package_installation_directory_of_module (NULL); diff --git a/libs/backends/jack/wscript b/libs/backends/jack/wscript index 111ecf3218..4e54af0be5 100644 --- a/libs/backends/jack/wscript +++ b/libs/backends/jack/wscript @@ -1,5 +1,6 @@ #!/usr/bin/env python from waflib.extras import autowaf as autowaf +from waflib import Options import os import sys import re @@ -19,7 +20,14 @@ def options(opt): autowaf.set_options(opt) def configure(conf): - autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.121.0') + # + # PortAudio is currently used to get a list of audio device names. + # We should find a better way to do this that doesn't involve this + # kind of dependency. + # + if Options.options.dist_target == 'mingw': + autowaf.check_pkg(conf, 'portaudio-2.0', uselib_store='PORTAUDIO', + atleast_version='19') autowaf.configure(conf) def build(bld): @@ -35,7 +43,10 @@ def build(bld): obj.includes = ['.'] obj.name = 'jack_audiobackend' obj.target = 'jack_audiobackend' - obj.uselib = [ 'JACK' ] + if Options.options.dist_target == 'mingw': + obj.uselib = [ 'JACK', 'PORTAUDIO' ] + else: + obj.uselib = [ 'JACK' ] obj.use = 'libardour libpbd' obj.vnum = JACKBACKEND_VERSION obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3', 'backends') diff --git a/libs/clearlooks-newer/animation.c b/libs/clearlooks-newer/animation.c index 2c6a6fdc42..8339ed7c19 100644 --- a/libs/clearlooks-newer/animation.c +++ b/libs/clearlooks-newer/animation.c @@ -159,11 +159,12 @@ add_animation (const GtkWidget *widget, gdouble stop_time) static gboolean update_animation_info (gpointer key, gpointer value, gpointer user_data) { - (void) user_data; - - AnimationInfo *animation_info = value; + AnimationInfo *animation_info; GtkWidget *widget = key; + animation_info = value; + (void) user_data; + g_assert ((widget != NULL) && (animation_info != NULL)); /* remove the widget from the hash table if it is not drawable */ @@ -217,9 +218,10 @@ animation_timeout_handler (gpointer data) static void on_checkbox_toggle (GtkWidget *widget, gpointer data) { + AnimationInfo *animation_info; (void) data; - AnimationInfo *animation_info = lookup_animation_info (widget); + animation_info = lookup_animation_info (widget); if (animation_info != NULL) { diff --git a/libs/clearlooks-newer/clearlooks_draw.c b/libs/clearlooks-newer/clearlooks_draw.c index e44610b4ee..1f98485ce5 100644 --- a/libs/clearlooks-newer/clearlooks_draw.c +++ b/libs/clearlooks-newer/clearlooks_draw.c @@ -945,12 +945,12 @@ clearlooks_draw_menubar0 (cairo_t *cr, const MenuBarParameters *menubar, int x, int y, int width, int height) { - (void) params; - (void) menubar; - /* const CairoColor *light = &colors->shade[0]; */ const CairoColor *dark = &colors->shade[3]; + (void) params; + (void) menubar; + cairo_set_line_width (cr, 1); cairo_translate (cr, x, y+0.5); @@ -972,12 +972,12 @@ clearlooks_draw_menubar2 (cairo_t *cr, const MenuBarParameters *menubar, int x, int y, int width, int height) { - (void) params; - (void) menubar; - CairoColor lower; cairo_pattern_t *pattern; + (void) params; + (void) menubar; + ge_shade_color (&colors->bg[0], 0.96, &lower); cairo_translate (cr, x, y); @@ -1316,10 +1316,10 @@ clearlooks_draw_separator (cairo_t *cr, const SeparatorParameters *separator, int x, int y, int width, int height) { - (void) widget; - + CairoColor hilight; CairoColor color = colors->shade[3]; - CairoColor hilight; + + (void) widget; ge_shade_color (&color, 1.4, &hilight); cairo_save (cr); @@ -1432,11 +1432,12 @@ clearlooks_draw_toolbar (cairo_t *cr, const ToolbarParameters *toolbar, int x, int y, int width, int height) { - (void) widget; - - const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL]; - const CairoColor *dark = &colors->shade[3]; CairoColor light; + const CairoColor *dark; + const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL]; + + (void) widget; + dark = &colors->shade[3]; ge_shade_color (fill, 1.1, &light); cairo_set_line_width (cr, 1.0); @@ -1575,13 +1576,13 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr, const ScrollBarParameters *scrollbar, int x, int y, int width, int height) { - (void) widget; - - const CairoColor *bg = &colors->shade[2]; - const CairoColor *border = &colors->shade[5]; + const CairoColor *bg; CairoColor bg_shade; - cairo_pattern_t *pattern; + cairo_pattern_t *pattern; + const CairoColor *border = &colors->shade[5]; + (void) widget; + bg = &colors->shade[2]; ge_shade_color (bg, 0.95, &bg_shade); cairo_set_line_width (cr, 1); @@ -1809,11 +1810,11 @@ clearlooks_draw_statusbar (cairo_t *cr, const WidgetParameters *widget, int x, int y, int width, int height) { + CairoColor hilight; + const CairoColor *dark = &colors->shade[3]; + (void) widget; (void) height; - - const CairoColor *dark = &colors->shade[3]; - CairoColor hilight; ge_shade_color (dark, 1.4, &hilight); @@ -1837,9 +1838,9 @@ clearlooks_draw_menu_frame (cairo_t *cr, const WidgetParameters *widget, int x, int y, int width, int height) { + const CairoColor *border = &colors->shade[5]; (void) widget; - const CairoColor *border = &colors->shade[5]; cairo_translate (cr, x, y); cairo_set_line_width (cr, 1); /* @@ -1924,15 +1925,15 @@ clearlooks_draw_resize_grip (cairo_t *cr, const ResizeGripParameters *grip, int x, int y, int width, int height) { - (void) widget; - - const CairoColor *dark = &colors->shade[4]; CairoColor hilight; int lx, ly; int x_down; int y_down; int dots; - + const CairoColor *dark = &colors->shade[4]; + + (void) widget; + ge_shade_color (dark, 1.5, &hilight); /* The number of dots fitting into the area. Just hardcoded to 4 right now. */ @@ -1996,17 +1997,18 @@ clearlooks_draw_radiobutton (cairo_t *cr, const CheckboxParameters *checkbox, int x, int y, int width, int height) { - (void) width; - (void) height; - const CairoColor *border; const CairoColor *dot; CairoColor shadow; CairoColor highlight; cairo_pattern_t *pt; gboolean inconsistent; + gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN); + (void) width; + (void) height; + inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN); draw_bullet |= inconsistent; diff --git a/libs/clearlooks-newer/clearlooks_draw_glossy.c b/libs/clearlooks-newer/clearlooks_draw_glossy.c index a0e250ee64..a8dd9ef7a3 100644 --- a/libs/clearlooks-newer/clearlooks_draw_glossy.c +++ b/libs/clearlooks-newer/clearlooks_draw_glossy.c @@ -1088,13 +1088,16 @@ clearlooks_glossy_draw_toolbar (cairo_t *cr, const ToolbarParameters *toolbar, int x, int y, int width, int height) { + CairoColor light; + const CairoColor *dark; + + const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL]; + dark = &colors->shade[3]; + (void) widget; (void) width; (void) height; - - const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL]; - const CairoColor *dark = &colors->shade[3]; - CairoColor light; + ge_shade_color (fill, 1.1, &light); cairo_set_line_width (cr, 1.0); @@ -1232,9 +1235,6 @@ clearlooks_glossy_draw_radiobutton (cairo_t *cr, const CheckboxParameters *checkbox, int x, int y, int width, int height) { - (void) width; - (void) height; - const CairoColor *border; const CairoColor *dot; CairoColor shadow; @@ -1243,6 +1243,9 @@ clearlooks_glossy_draw_radiobutton (cairo_t *cr, gboolean inconsistent; gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN); + (void) width; + (void) height; + inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN); draw_bullet |= inconsistent; diff --git a/libs/clearlooks-newer/clearlooks_draw_gummy.c b/libs/clearlooks-newer/clearlooks_draw_gummy.c index 0d736b5acc..ca208c2ebc 100644 --- a/libs/clearlooks-newer/clearlooks_draw_gummy.c +++ b/libs/clearlooks-newer/clearlooks_draw_gummy.c @@ -790,10 +790,10 @@ clearlooks_gummy_draw_separator (cairo_t *cr, const SeparatorParameters *separator, int x, int y, int width, int height) { - (void) widget; - - CairoColor color = colors->shade[3]; CairoColor hilight; + CairoColor color = colors->shade[3]; + + (void) widget; ge_shade_color (&color, 1.3, &hilight); cairo_save (cr); @@ -1162,11 +1162,14 @@ clearlooks_gummy_draw_toolbar (cairo_t *cr, const ToolbarParameters *toolbar, int x, int y, int width, int height) { - (void) widget; - - const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL]; - const CairoColor *dark = &colors->shade[3]; CairoColor light; + const CairoColor *dark; + const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL]; + + (void) widget; + + dark = &colors->shade[3]; + ge_shade_color (fill, toolbar->style == 1 ? 1.1 : 1.05, &light); cairo_set_line_width (cr, 1.0); @@ -1302,12 +1305,12 @@ clearlooks_gummy_draw_statusbar (cairo_t *cr, const WidgetParameters *widget, int x, int y, int width, int height) { + CairoColor hilight; + const CairoColor *dark = &colors->shade[3]; + (void) widget; (void) height; - const CairoColor *dark = &colors->shade[3]; - CairoColor hilight; - ge_shade_color (dark, 1.3, &hilight); cairo_set_line_width (cr, 1); @@ -1331,9 +1334,6 @@ clearlooks_gummy_draw_radiobutton (cairo_t *cr, const CheckboxParameters *checkbox, int x, int y, int width, int height) { - (void) width; - (void) height; - const CairoColor *border; const CairoColor *dot; CairoColor shadow; @@ -1342,6 +1342,9 @@ clearlooks_gummy_draw_radiobutton (cairo_t *cr, gboolean inconsistent; gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN); + (void) width; + (void) height; + inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN); draw_bullet |= inconsistent; diff --git a/libs/clearlooks-newer/clearlooks_rc_style.c b/libs/clearlooks-newer/clearlooks_rc_style.c index 9f8fbd4945..8d6e0aa898 100644 --- a/libs/clearlooks-newer/clearlooks_rc_style.c +++ b/libs/clearlooks-newer/clearlooks_rc_style.c @@ -173,9 +173,9 @@ clearlooks_gtk2_rc_parse_boolean (GtkSettings *settings, GScanner *scanner, gboolean *retval) { - (void) settings; - guint token; + + (void) settings; token = g_scanner_get_next_token(scanner); token = g_scanner_get_next_token(scanner); @@ -198,10 +198,10 @@ clearlooks_gtk2_rc_parse_color(GtkSettings *settings, GScanner *scanner, GdkColor *color) { - (void) settings; - guint token; + (void) settings; + /* Skip 'blah_color' */ token = g_scanner_get_next_token(scanner); @@ -217,10 +217,10 @@ clearlooks_gtk2_rc_parse_double (GtkSettings *settings, GScanner *scanner, gdouble *val) { - (void) settings; - guint token; + (void) settings; + /* Skip 'blah' */ token = g_scanner_get_next_token(scanner); @@ -242,10 +242,10 @@ clearlooks_gtk2_rc_parse_int (GtkSettings *settings, GScanner *scanner, guint8 *progressbarstyle) { - (void) settings; - guint token; + (void) settings; + /* Skip 'sunkenmenubar' */ token = g_scanner_get_next_token(scanner); @@ -267,10 +267,10 @@ clearlooks_gtk2_rc_parse_style (GtkSettings *settings, GScanner *scanner, ClearlooksStyles *style) { - (void) settings; - guint token; + (void) settings; + g_assert (CL_NUM_STYLES == CL_STYLE_GUMMY + 1); /* so that people don't forget ;-) */ /* Skip 'style' */ @@ -308,10 +308,10 @@ clearlooks_gtk2_rc_parse_dummy (GtkSettings *settings, GScanner *scanner, const gchar *name) { - (void) settings; - guint token; + (void) settings; + /* Skip option */ token = g_scanner_get_next_token (scanner); diff --git a/libs/clearlooks-newer/clearlooks_style.c b/libs/clearlooks-newer/clearlooks_style.c index f1b46a5426..d1ac8d5d39 100644 --- a/libs/clearlooks-newer/clearlooks_style.c +++ b/libs/clearlooks-newer/clearlooks_style.c @@ -956,14 +956,14 @@ clearlooks_style_draw_slider (DRAW_ARGS, GtkOrientation orientation) static void clearlooks_style_draw_option (DRAW_ARGS) { - (void) detail; - - ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); const ClearlooksColors *colors; WidgetParameters params; CheckboxParameters checkbox; cairo_t *cr; + ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); + (void) detail; + CHECK_ARGS SANITIZE_SIZE @@ -1019,14 +1019,17 @@ clearlooks_style_draw_vline (GtkStyle *style, gint y2, gint x) { + const ClearlooksColors *colors; + SeparatorParameters separator; + cairo_t *cr; + + ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); + (void) state_type; (void) widget; (void) detail; - - ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); - const ClearlooksColors *colors; - SeparatorParameters separator = { FALSE }; - cairo_t *cr; + + separator.horizontal = FALSE; CHECK_ARGS @@ -1053,13 +1056,13 @@ clearlooks_style_draw_hline (GtkStyle *style, gint x2, gint y) { - (void) state_type; - (void) widget; - - ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); const ClearlooksColors *colors; cairo_t *cr; SeparatorParameters separator; + ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); + + (void) state_type; + (void) widget; CHECK_ARGS @@ -1136,13 +1139,14 @@ clearlooks_style_draw_resize_grip (GtkStyle *style, gint width, gint height) { - (void) detail; - - ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); - ClearlooksColors *colors = &clearlooks_style->colors; + ClearlooksColors *colors; cairo_t *cr; WidgetParameters params; ResizeGripParameters grip; + ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); + + (void) detail; + colors = &clearlooks_style->colors; CHECK_ARGS SANITIZE_SIZE @@ -1164,14 +1168,15 @@ clearlooks_style_draw_resize_grip (GtkStyle *style, static void clearlooks_style_draw_tab (DRAW_ARGS) { - (void) shadow_type; - (void) detail; - - ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); - ClearlooksColors *colors = &clearlooks_style->colors; + ClearlooksColors *colors; WidgetParameters params; ArrowParameters arrow; cairo_t *cr; + ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); + + (void) shadow_type; + (void) detail; + colors = &clearlooks_style->colors; CHECK_ARGS SANITIZE_SIZE @@ -1202,15 +1207,18 @@ clearlooks_style_draw_arrow (GtkStyle *style, gint width, gint height) { + ClearlooksColors *colors; + WidgetParameters params; + ArrowParameters arrow; + cairo_t *cr; + ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); + (void) shadow; (void) detail; (void) fill; - - ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); - ClearlooksColors *colors = &clearlooks_style->colors; - WidgetParameters params; - ArrowParameters arrow; - cairo_t *cr = ge_gdk_drawable_to_cairo (window, area); + + cr = ge_gdk_drawable_to_cairo (window, area); + colors = &clearlooks_style->colors; CHECK_ARGS SANITIZE_SIZE @@ -1475,10 +1483,9 @@ clearlooks_style_draw_layout (GtkStyle * style, GtkWidget * widget, const gchar * detail, gint x, gint y, PangoLayout * layout) { - (void) detail; - GdkGC *gc; + (void) detail; g_return_if_fail (GTK_IS_STYLE (style)); g_return_if_fail (window != NULL); @@ -1525,17 +1532,20 @@ clearlooks_style_draw_render_icon (GtkStyle *style, GtkWidget *widget, const char *detail) { - (void) direction; - (void) detail; - - int width = 1; - int height = 1; + int width; + int height; GdkPixbuf *scaled; GdkPixbuf *stated; GdkPixbuf *base_pixbuf; GdkScreen *screen; GtkSettings *settings; - + + width = 1; + height = 1; + + (void) direction; + (void) detail; + /* Oddly, style can be NULL in this function, because * GtkIconSet can be used without a style and if so * it uses this function. diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index de8f97a297..e762d64ad1 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -181,7 +181,7 @@ public: OverlapPitchResolution overlap_pitch_resolution() const { return _overlap_pitch_resolution; } void set_overlap_pitch_resolution(OverlapPitchResolution opr); - void set_notes (const Sequence