X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fbackends%2Fjack%2Fjack_utils.cc;h=b26cb4036797194112457aba6ea1c4a53396773a;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=fcb0d7a169702858eaa3fe6e8911df4ab786d2fb;hpb=8c9749e42faf7808034ed8b7afce4a2fe6dc6f33;p=ardour.git diff --git a/libs/backends/jack/jack_utils.cc b/libs/backends/jack/jack_utils.cc index fcb0d7a169..b26cb40367 100644 --- a/libs/backends/jack/jack_utils.cc +++ b/libs/backends/jack/jack_utils.cc @@ -19,7 +19,7 @@ */ #ifdef HAVE_ALSA -#include +#include "ardouralsautil/devicelist.h" #endif #ifdef __APPLE__ @@ -34,16 +34,13 @@ #include // 'IShellLink' #endif -#ifdef HAVE_PORTAUDIO +#if (defined PLATFORM_WINDOWS && defined HAVE_PORTAUDIO) #include #endif -#include - -#include - #include +#include "pbd/gstdio_compat.h" #include #include "pbd/epa.h" @@ -58,7 +55,7 @@ #include #endif -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace PBD; @@ -276,60 +273,7 @@ void ARDOUR::get_jack_alsa_device_names (device_map_t& devices) { #ifdef HAVE_ALSA - snd_ctl_t *handle; - snd_ctl_card_info_t *info; - snd_pcm_info_t *pcminfo; - snd_ctl_card_info_alloca(&info); - snd_pcm_info_alloca(&pcminfo); - string devname; - int cardnum = -1; - int device = -1; - - while (snd_card_next (&cardnum) >= 0 && cardnum >= 0) { - - devname = "hw:"; - devname += PBD::to_string (cardnum, std::dec); - - if (snd_ctl_open (&handle, devname.c_str(), 0) >= 0 && snd_ctl_card_info (handle, info) >= 0) { - - if (snd_ctl_card_info (handle, info) < 0) { - continue; - } - - string card_name = snd_ctl_card_info_get_name (info); - - /* change devname to use ID, not number */ - - devname = "hw:"; - devname += snd_ctl_card_info_get_id (info); - - while (snd_ctl_pcm_next_device (handle, &device) >= 0 && device >= 0) { - - /* only detect duplex devices here. more - * complex arrangements are beyond our scope - */ - - snd_pcm_info_set_device (pcminfo, device); - snd_pcm_info_set_subdevice (pcminfo, 0); - snd_pcm_info_set_stream (pcminfo, SND_PCM_STREAM_CAPTURE); - - if (snd_ctl_pcm_info (handle, pcminfo) >= 0) { - - snd_pcm_info_set_device (pcminfo, device); - snd_pcm_info_set_subdevice (pcminfo, 0); - snd_pcm_info_set_stream (pcminfo, SND_PCM_STREAM_PLAYBACK); - - if (snd_ctl_pcm_info (handle, pcminfo) >= 0) { - devname += ','; - devname += PBD::to_string (device, std::dec); - devices.insert (std::make_pair (card_name, devname)); - } - } - } - - snd_ctl_close(handle); - } - } + get_alsa_audio_device_names(devices); #else /* silence a compiler unused variable warning */ (void) devices; @@ -428,7 +372,7 @@ ARDOUR::get_jack_coreaudio_device_names (device_map_t& devices) void ARDOUR::get_jack_portaudio_device_names (device_map_t& devices) { -#ifdef HAVE_PORTAUDIO +#if (defined PLATFORM_WINDOWS && defined HAVE_PORTAUDIO) if (Pa_Initialize() != paNoError) { return; } @@ -591,7 +535,7 @@ ARDOUR::get_jack_server_dir_paths (vector& 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 @@ -669,8 +613,7 @@ ARDOUR::get_jack_server_paths (const vector& server_dir_paths, vector& server_paths) { for (vector::const_iterator i = server_names.begin(); i != server_names.end(); ++i) { - Glib::PatternSpec ps (*i); - find_matching_files_in_directories (server_dir_paths, ps, server_paths); + find_files_matching_pattern (server_paths, server_dir_paths, *i); } return !server_paths.empty(); } @@ -745,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 args; @@ -754,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); @@ -896,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)); @@ -935,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 ()) { @@ -948,7 +893,11 @@ ARDOUR::get_jack_command_line_string (JackCommandLineOptions& options, string& c ostringstream oss; for (vector::const_iterator i = args.begin(); i != args.end();) { - oss << *i; + if (i->find_first_of(' ') != string::npos) { + oss << "\"" << *i << "\""; + } else { + oss << *i; + } if (++i != args.end()) oss << ' '; } @@ -977,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 -ARDOUR::enumerate_midi_options () +ARDOUR::enumerate_midi_options () { if (midi_options.empty()) { #ifdef HAVE_ALSA @@ -999,11 +943,11 @@ ARDOUR::enumerate_midi_options () midi_options.push_back (make_pair (_("ALSA (JACK1, 0.124 and later)"), alsa_seq_midi_driver_name)); midi_options.push_back (make_pair (_("ALSA (JACK2, 1.9.8 and later)"), alsa_raw_midi_driver_name)); #endif -#ifdef HAVE_PORTAUDIO +#if (defined PLATFORM_WINDOWS && defined HAVE_PORTAUDIO) /* 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)); @@ -1012,12 +956,12 @@ ARDOUR::enumerate_midi_options () vector v; - v.push_back (get_none_string()); - for (MidiOptions::const_iterator i = midi_options.begin(); i != midi_options.end(); ++i) { v.push_back (i->first); } + v.push_back (get_none_string()); + return v; }