enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / backends / jack / jack_utils.cc
index 727ff90bc83d6a94de525803b9fa4d34c05613fa..b26cb4036797194112457aba6ea1c4a53396773a 100644 (file)
 #include <portaudio.h>
 #endif
 
-#include <fstream>
-
 #include <boost/scoped_ptr.hpp>
 
+#include "pbd/gstdio_compat.h"
 #include <glibmm/miscutils.h>
 
 #include "pbd/epa.h"
@@ -56,7 +55,7 @@
 #include <CFBundle.h>
 #endif
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace PBD;
@@ -536,7 +535,7 @@ ARDOUR::get_jack_server_dir_paths (vector<std::string>& server_dir_paths)
 #ifdef PLATFORM_WINDOWS
 // N.B. The #define (immediately below) can be safely removed once we know that this code builds okay with mingw
 #ifdef COMPILER_MSVC
-       IShellLinkA  *pISL = NULL;    
+       IShellLinkA  *pISL = NULL;
        IPersistFile *ppf  = NULL;
 
        // Mixbus creates a Windows shortcut giving the location of its
@@ -689,7 +688,7 @@ ARDOUR::JackCommandLineOptions::JackCommandLineOptions ()
 }
 
 bool
-ARDOUR::get_jack_command_line_string (JackCommandLineOptions& options, string& command_line, bool for_latency_measurement)
+ARDOUR::get_jack_command_line_string (JackCommandLineOptions& options, string& command_line)
 {
        vector<string> args;
 
@@ -698,8 +697,10 @@ ARDOUR::get_jack_command_line_string (JackCommandLineOptions& options, string& c
 #ifdef PLATFORM_WINDOWS
        // must use sync mode on windows
        args.push_back ("-S");
+#endif
 
-       // this needs to be added now on windows
+#if (defined PLATFORM_WINDOWS || defined __APPLE__)
+       // midi systems needs to be added before the audio driver for jack2
        if (!options.midi_driver.empty () && options.midi_driver != get_none_string ()) {
                args.push_back ("-X");
                args.push_back (options.midi_driver);
@@ -840,7 +841,7 @@ ARDOUR::get_jack_command_line_string (JackCommandLineOptions& options, string& c
        args.push_back ("-p");
        args.push_back (to_string (options.period_size, std::dec));
 
-       if (!for_latency_measurement && get_jack_audio_driver_supports_latency_adjustment (options.driver)) {
+       if (get_jack_audio_driver_supports_latency_adjustment (options.driver)) {
                if (options.input_latency) {
                        args.push_back ("-I");
                        args.push_back (to_string (options.input_latency, std::dec));
@@ -879,7 +880,7 @@ ARDOUR::get_jack_command_line_string (JackCommandLineOptions& options, string& c
                }
        }
 
-       if (options.driver == alsa_driver_name || options.driver == coreaudio_driver_name) {
+       if (options.driver == alsa_driver_name) {
 
                if (options.midi_driver != alsa_seq_midi_driver_name) {
                        if (!options.midi_driver.empty() && options.midi_driver != get_none_string ()) {
@@ -925,20 +926,15 @@ ARDOUR::get_jack_server_user_config_file_path ()
 bool
 ARDOUR::write_jack_config_file (const std::string& config_file_path, const string& command_line)
 {
-       ofstream jackdrc (config_file_path.c_str());
-
-       if (!jackdrc) {
+       if (!g_file_set_contents (config_file_path.c_str(), command_line.c_str(), -1, NULL)) {
                error << string_compose (_("cannot open JACK rc file %1 to store parameters"), config_file_path) << endmsg;
                return false;
        }
-
-       jackdrc << command_line << endl;
-       jackdrc.close ();
        return true;
 }
 
 vector<string>
-ARDOUR::enumerate_midi_options () 
+ARDOUR::enumerate_midi_options ()
 {
        if (midi_options.empty()) {
 #ifdef HAVE_ALSA
@@ -951,7 +947,7 @@ ARDOUR::enumerate_midi_options ()
                /* Windows folks: what name makes sense here? Are there other
                   choices as well ?
                */
-               midi_options.push_back (make_pair (_("Multimedia Extension"), winmme_midi_driver_name));
+               midi_options.push_back (make_pair (_("System MIDI (MME)"), winmme_midi_driver_name));
 #endif
 #ifdef __APPLE__
                midi_options.push_back (make_pair (_("CoreMIDI"), coremidi_midi_driver_name));