summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-08-05 12:51:51 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-08-05 12:51:51 -0400
commita66e3859e1415cb992320089004eb8a9903cf721 (patch)
treef93b5f05ccf26e6b91ed0a2b99a5d8603cc73131 /gtk2_ardour
parent7218bd91de3b69032e515617449702f368db59d2 (diff)
can now start JACK based on config dialog
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui.cc32
-rw-r--r--gtk2_ardour/engine_dialog.cc151
-rw-r--r--gtk2_ardour/engine_dialog.h13
-rw-r--r--gtk2_ardour/startup.cc4
4 files changed, 135 insertions, 65 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index fca86c585b..c4e037a5bf 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -490,17 +490,6 @@ ARDOUR_UI::post_engine ()
Config->ParameterChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
Config->map_parameters (pc);
-
- /* now start and maybe save state */
-
- if (do_engine_start () == 0) {
- if (_session && _session_is_new) {
- /* we need to retain initial visual
- settings for a new session
- */
- _session->save_state ("");
- }
- }
}
ARDOUR_UI::~ARDOUR_UI ()
@@ -2035,7 +2024,8 @@ ARDOUR_UI::engine_stopped ()
void
ARDOUR_UI::engine_running ()
{
- ENSURE_GUI_THREAD (*this, &ARDOUR_UI::engine_running)
+ post_engine();
+
ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, true);
ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, false);
@@ -2127,24 +2117,6 @@ JACK, reconnect and save the session."), PROGRAM_NAME);
}
}
-int32_t
-ARDOUR_UI::do_engine_start ()
-{
- try {
- engine->start();
- }
-
- catch (...) {
- engine->stop ();
- error << _("Unable to start the session running")
- << endmsg;
- unload_session ();
- return -2;
- }
-
- return 0;
-}
-
void
ARDOUR_UI::update_clocks ()
{
diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc
index b4e5c72050..3a06fb5072 100644
--- a/gtk2_ardour/engine_dialog.cc
+++ b/gtk2_ardour/engine_dialog.cc
@@ -17,6 +17,7 @@
*/
+#include <exception>
#include <vector>
#include <cmath>
#include <fstream>
@@ -27,20 +28,9 @@
#include <glibmm.h>
#include <gtkmm/messagedialog.h>
-#include "pbd/epa.h"
+#include "pbd/error.h"
#include "pbd/xml++.h"
-#ifdef __APPLE__
-#include <CoreAudio/CoreAudio.h>
-#include <CoreFoundation/CFString.h>
-#include <sys/param.h>
-#include <mach-o/dyld.h>
-#elif !defined(__FreeBSD__)
-#include <alsa/asoundlib.h>
-#endif
-
-#include <jack/jack.h>
-
#include <gtkmm/stock.h>
#include <gtkmm2ext/utils.h>
@@ -50,11 +40,6 @@
#include "pbd/convert.h"
#include "pbd/error.h"
-#include "pbd/pathscanner.h"
-
-#ifdef __APPLE
-#include <CFBundle.h>
-#endif
#include "engine_dialog.h"
#include "i18n.h"
@@ -355,19 +340,6 @@ EngineControl::interface_changed ()
buffer_size_combo.set_active_text (s.front());
}
-uint32_t
-EngineControl::get_rate ()
-{
- double r = atof (sample_rate_combo.get_active_text ());
- /* the string may have been translated with an abbreviation for
- * thousands, so use a crude heuristic to fix this.
- */
- if (r < 1000.0) {
- r *= 1000.0;
- }
- return lrint (r);
-}
-
void
EngineControl::redisplay_latency ()
{
@@ -507,6 +479,7 @@ EngineControl::get_state ()
void
EngineControl::set_state (const XMLNode& root)
{
+#if 0
XMLNodeList clist;
XMLNodeConstIterator citer;
XMLNode* child;
@@ -516,7 +489,7 @@ EngineControl::set_state (const XMLNode& root)
int val;
string strval;
-#if 0
+
if ( (child = root.child ("driver"))){
prop = child->property("val");
@@ -655,6 +628,120 @@ EngineControl::set_state (const XMLNode& root)
}
int
-EngineControl::setup_engine ()
+EngineControl::setup_engine (bool start)
{
+ boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
+ assert (backend);
+
+ /* grab the parameters from the GUI and apply them */
+
+ try {
+ if (backend->requires_driver_selection()) {
+ if (backend->set_driver (get_driver())) {
+ return -1;
+ }
+ }
+
+ if (backend->set_device_name (get_device_name())) {
+ return -1;
+ }
+
+ if (backend->set_sample_rate (get_rate())) {
+ error << string_compose (_("Cannot set sample rate to %1"), get_rate()) << endmsg;
+ return -1;
+ }
+ if (backend->set_buffer_size (get_buffer_size())) {
+ error << string_compose (_("Cannot set buffer size to %1"), get_buffer_size()) << endmsg;
+ return -1;
+ }
+ if (backend->set_input_channels (get_input_channels())) {
+ error << string_compose (_("Cannot set input channels to %1"), get_input_channels()) << endmsg;
+ return -1;
+ }
+ if (backend->set_output_channels (get_output_channels())) {
+ error << string_compose (_("Cannot set output channels to %1"), get_output_channels()) << endmsg;
+ return -1;
+ }
+ if (backend->set_systemic_input_latency (get_input_latency())) {
+ error << string_compose (_("Cannot set input latency to %1"), get_input_latency()) << endmsg;
+ return -1;
+ }
+ if (backend->set_systemic_output_latency (get_output_latency())) {
+ error << string_compose (_("Cannot set output latency to %1"), get_output_latency()) << endmsg;
+ return -1;
+ }
+
+ if (start) {
+ return ARDOUR::AudioEngine::instance()->start();
+ }
+
+ return 0;
+
+ } catch (...) {
+ cerr << "exception thrown...\n";
+ return -1;
+ }
}
+
+uint32_t
+EngineControl::get_rate () const
+{
+ double r = atof (sample_rate_combo.get_active_text ());
+ /* the string may have been translated with an abbreviation for
+ * thousands, so use a crude heuristic to fix this.
+ */
+ if (r < 1000.0) {
+ r *= 1000.0;
+ }
+ return lrint (r);
+}
+
+uint32_t
+EngineControl::get_buffer_size () const
+{
+ string txt = buffer_size_combo.get_active_text ();
+ uint32_t samples;
+
+ if (sscanf (txt.c_str(), "%d", &samples) != 1) {
+ throw exception ();
+ }
+
+ return samples;
+}
+
+uint32_t
+EngineControl::get_input_channels() const
+{
+ return (uint32_t) input_channels_adjustment.get_value();
+}
+
+uint32_t
+EngineControl::get_output_channels() const
+{
+ return (uint32_t) output_channels_adjustment.get_value();
+}
+
+uint32_t
+EngineControl::get_input_latency() const
+{
+ return (uint32_t) input_latency_adjustment.get_value();
+}
+
+uint32_t
+EngineControl::get_output_latency() const
+{
+ return (uint32_t) output_latency_adjustment.get_value();
+}
+
+string
+EngineControl::get_driver () const
+{
+ return driver_combo.get_active_text ();
+}
+
+string
+EngineControl::get_device_name () const
+{
+ return interface_combo.get_active_text ();
+}
+
diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h
index ac96fbc520..07cf0afa8f 100644
--- a/gtk2_ardour/engine_dialog.h
+++ b/gtk2_ardour/engine_dialog.h
@@ -40,7 +40,7 @@ class EngineControl : public Gtk::VBox {
~EngineControl ();
static bool need_setup ();
- int setup_engine ();
+ int setup_engine (bool start);
bool was_used() const { return _used; }
XMLNode& get_state ();
@@ -104,7 +104,16 @@ class EngineControl : public Gtk::VBox {
void backend_changed ();
void redisplay_latency ();
- uint32_t get_rate();
+
+ uint32_t get_rate() const;
+ uint32_t get_buffer_size() const;
+ uint32_t get_input_channels() const;
+ uint32_t get_output_channels() const;
+ uint32_t get_input_latency() const;
+ uint32_t get_output_latency() const;
+ std::string get_device_name() const;
+ std::string get_driver() const;
+
void audio_mode_changed ();
void interface_changed ();
void list_devices ();
diff --git a/gtk2_ardour/startup.cc b/gtk2_ardour/startup.cc
index 8314a0986e..bfd9c88633 100644
--- a/gtk2_ardour/startup.cc
+++ b/gtk2_ardour/startup.cc
@@ -662,8 +662,10 @@ ArdourStartup::on_delete_event (GdkEventAny*)
void
ArdourStartup::on_apply ()
{
+ cerr << "apply, engine = " << engine_dialog << endl;
if (engine_dialog) {
- if (engine_dialog->setup_engine ()) {
+ cerr << "Set up engine\n";
+ if (engine_dialog->setup_engine (true)) {
set_current_page (audio_page_index);
return;
}