fix crash when unconditionally using null env var; tweak packing of control app button
[ardour.git] / gtk2_ardour / engine_dialog.h
1 /*
2     Copyright (C) 2010 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtk2_ardour_engine_dialog_h__
21 #define __gtk2_ardour_engine_dialog_h__
22
23 #include <map>
24 #include <vector>
25 #include <string>
26
27 #include <gtkmm/checkbutton.h>
28 #include <gtkmm/spinbutton.h>
29 #include <gtkmm/comboboxtext.h>
30 #include <gtkmm/table.h>
31 #include <gtkmm/expander.h>
32 #include <gtkmm/box.h>
33 #include <gtkmm/buttonbox.h>
34 #include <gtkmm/button.h>
35
36 #include "ardour_dialog.h"
37
38 class EngineControl : public ArdourDialog {
39   public:
40         EngineControl ();
41         ~EngineControl ();
42
43         static bool need_setup ();
44         int setup_engine (bool start);
45
46         XMLNode& get_state ();
47         void set_state (const XMLNode&);
48
49   private:
50     Gtk::Notebook notebook;
51
52     /* core fields used by all backends */
53
54     Gtk::ComboBoxText backend_combo;
55     Gtk::ComboBoxText input_device_combo;
56     Gtk::ComboBoxText output_device_combo;
57     Gtk::ComboBoxText sample_rate_combo;
58     Gtk::ComboBoxText buffer_size_combo;
59     Gtk::Label        buffer_size_duration_label;
60     Gtk::Adjustment input_latency_adjustment;
61     Gtk::SpinButton input_latency;
62     Gtk::Adjustment output_latency_adjustment;
63     Gtk::SpinButton output_latency;
64     Gtk::Adjustment input_channels_adjustment;
65     Gtk::SpinButton input_channels;
66     Gtk::Adjustment output_channels_adjustment;
67     Gtk::SpinButton output_channels;
68     Gtk::Adjustment ports_adjustment;
69     Gtk::SpinButton ports_spinner;
70
71     Gtk::Button     control_app_button;
72
73     /* JACK specific */
74     
75     Gtk::CheckButton realtime_button;
76     Gtk::CheckButton no_memory_lock_button;
77     Gtk::CheckButton unlock_memory_button;
78     Gtk::CheckButton soft_mode_button;
79     Gtk::CheckButton monitor_button;
80     Gtk::CheckButton force16bit_button;
81     Gtk::CheckButton hw_monitor_button;
82     Gtk::CheckButton hw_meter_button;
83     Gtk::CheckButton verbose_output_button;
84     
85     Gtk::ComboBoxText preset_combo;
86     Gtk::ComboBoxText serverpath_combo;
87     Gtk::ComboBoxText driver_combo;
88     Gtk::ComboBoxText device_combo;
89     Gtk::ComboBoxText timeout_combo;
90     Gtk::ComboBoxText dither_mode_combo;
91     Gtk::ComboBoxText audio_mode_combo;
92     Gtk::ComboBoxText midi_driver_combo;
93     
94     Gtk::Table basic_packer;
95     Gtk::Table midi_packer;
96     Gtk::HBox basic_hbox;
97     Gtk::VBox basic_vbox;
98     Gtk::HBox midi_hbox;
99
100     sigc::connection sr_connection;
101     sigc::connection bs_connection;
102     
103     static bool engine_running ();
104     
105     void driver_changed ();
106     void backend_changed ();
107     void sample_rate_changed ();
108     void buffer_size_changed ();
109
110     uint32_t get_rate() const;
111     uint32_t get_buffer_size() const;
112     uint32_t get_input_channels() const;
113     uint32_t get_output_channels() const;
114     uint32_t get_input_latency() const;
115     uint32_t get_output_latency() const;
116     std::string get_device_name() const;
117     std::string get_driver() const;
118
119     void audio_mode_changed ();
120     void device_changed ();
121     void list_devices ();
122     void show_buffer_duration ();
123
124     struct State {
125         std::string backend;
126         std::string driver;
127         std::string device;
128         std::string sample_rate;
129         std::string buffer_size;
130         uint32_t input_latency;
131         uint32_t output_latency;
132         uint32_t input_channels;
133         uint32_t output_channels;
134         bool active;
135
136         State() : active (false) {};
137     };
138     
139     typedef std::list<State> StateList;
140
141     StateList states;
142
143     State* get_matching_state (const std::string& backend,
144                                const std::string& driver,
145                                const std::string& device);
146     State* get_current_state ();
147     void maybe_set_state ();
148     void save_state ();
149
150     static bool print_channel_count (Gtk::SpinButton*);
151
152     void build_notebook ();
153
154     void on_response (int);
155     void control_app_button_clicked ();
156     void manage_control_app_sensitivity ();
157 };
158
159 #endif /* __gtk2_ardour_engine_dialog_h__ */