fix conflicts and merge with master
[ardour.git] / gtk2_ardour / ardour_ui.cc
index 4992e0a14b5df87d860a407a940b1f1611fcdb0d..c3d3211db1d04843a4ddcc783d35f0eb774141cf 100644 (file)
 #include <cerrno>
 #include <fstream>
 
+#ifndef WIN32
+#include <sys/resource.h>
+#endif
+
 #include <stdint.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <unistd.h>
 #include <time.h>
 
-#include <sys/resource.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
+#include <glib.h>
+#include <glib/gstdio.h>
 
 #include <gtkmm/messagedialog.h>
 #include <gtkmm/accelmap.h>
@@ -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"
@@ -289,7 +293,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 */
 
@@ -384,25 +388,8 @@ ARDOUR_UI::create_global_port_matrix (ARDOUR::DataType type)
 void
 ARDOUR_UI::attach_to_engine ()
 {
-       AudioEngine::instance()->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context());
        AudioEngine::instance()->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this), gui_context());
-       AudioEngine::instance()->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
-
-       AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
-
        ARDOUR::Port::set_connecting_blocked (ARDOUR_COMMAND_LINE::no_connect_ports);
-
-       /* if there is only one audio/midi backend, and it does not require setup, get our use of it underway
-        * right here (we need to know the client name and potential session ID
-        * to do this, which is why this is here, rather than in, say,
-        * ARDOUR::init().
-        */
-
-       if (!AudioEngine::instance()->setup_required()) {
-               const AudioBackendInfo* backend = AudioEngine::instance()->available_backends().front();
-               AudioEngine::instance()->set_backend (backend->name, ARDOUR_COMMAND_LINE::backend_client_name, ARDOUR_COMMAND_LINE::backend_session_uuid);
-               AudioEngine::instance()->start ();
-       }
 }
 
 void
@@ -524,6 +511,12 @@ ARDOUR_UI::post_engine ()
         */
 
        ARDOUR::init_post_engine ();
+       
+       /* connect to important signals */
+
+       AudioEngine::instance()->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context());
+       AudioEngine::instance()->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
+       AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
 
        _tooltips.enable();
 
@@ -862,7 +855,7 @@ ARDOUR_UI::no_memory_warning ()
 void
 ARDOUR_UI::check_memory_locking ()
 {
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(WIN32)
        /* OS X doesn't support mlockall(2), and so testing for memory locking capability there is pointless */
        return;
 #else // !__APPLE__
@@ -3378,15 +3371,23 @@ ARDOUR_UI::start_video_server (Gtk::Window* float_window, bool popup_msg)
                if (icsd_docroot.empty()) {icsd_docroot = X_("/");}
 
                struct stat sb;
-               if (!lstat (icsd_docroot.c_str(), &sb) == 0 || !S_ISDIR(sb.st_mode)) {
+               if (!g_lstat (icsd_docroot.c_str(), &sb) == 0 || !S_ISDIR(sb.st_mode)) {
                        warning << _("Specified docroot is not an existing directory.") << endmsg;
                        continue;
                }
-               if ( (!lstat (icsd_exec.c_str(), &sb) == 0)
+#ifndef WIN32
+               if ( (!g_lstat (icsd_exec.c_str(), &sb) == 0)
                     || (sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0 ) {
                        warning << _("Given Video Server is not an executable file.") << endmsg;
                        continue;
                }
+#else
+               if ( (!g_lstat (icsd_exec.c_str(), &sb) == 0)
+                    || (sb.st_mode & (S_IXUSR)) == 0 ) {
+                       warning << _("Given Video Server is not an executable file.") << endmsg;
+                       continue;
+               }
+#endif
 
                char **argp;
                argp=(char**) calloc(9,sizeof(char*));
@@ -4039,7 +4040,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<std::string> hits)
+ARDOUR_UI::ambiguous_file (std::string file, std::vector<std::string> hits)
 {
        AmbiguousFileDialog dialog (file, hits);
 
@@ -4165,9 +4166,7 @@ ARDOUR_UI::do_audio_midi_setup (uint32_t desired_sample_rate)
 
        _audio_midi_setup->set_desired_sample_rate (desired_sample_rate);
 
-       int r = _audio_midi_setup->run ();
-
-       switch (r) {
+       switch (_audio_midi_setup->run()) {
        case Gtk::RESPONSE_OK:
                return 0;
        case Gtk::RESPONSE_APPLY: