save/restore I/O latency values in audio/midi setup
[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 class EngineControl : public Gtk::VBox {
37   public:
38         EngineControl ();
39         ~EngineControl ();
40
41         static bool need_setup ();
42         int setup_engine (bool start);
43
44         XMLNode& get_state ();
45         void set_state (const XMLNode&);
46
47   private:
48     Gtk::Notebook notebook;
49
50     /* core fields used by all backends */
51
52     Gtk::ComboBoxText backend_combo;
53     Gtk::ComboBoxText input_device_combo;
54     Gtk::ComboBoxText output_device_combo;
55     Gtk::ComboBoxText sample_rate_combo;
56     Gtk::ComboBoxText buffer_size_combo;
57     Gtk::Adjustment input_latency_adjustment;
58     Gtk::SpinButton input_latency;
59     Gtk::Adjustment output_latency_adjustment;
60     Gtk::SpinButton output_latency;
61     Gtk::Adjustment input_channels_adjustment;
62     Gtk::SpinButton input_channels;
63     Gtk::Adjustment output_channels_adjustment;
64     Gtk::SpinButton output_channels;
65     Gtk::Adjustment ports_adjustment;
66     Gtk::SpinButton ports_spinner;
67
68     /* JACK specific */
69     
70     Gtk::CheckButton realtime_button;
71     Gtk::CheckButton no_memory_lock_button;
72     Gtk::CheckButton unlock_memory_button;
73     Gtk::CheckButton soft_mode_button;
74     Gtk::CheckButton monitor_button;
75     Gtk::CheckButton force16bit_button;
76     Gtk::CheckButton hw_monitor_button;
77     Gtk::CheckButton hw_meter_button;
78     Gtk::CheckButton verbose_output_button;
79     
80     
81     Gtk::ComboBoxText preset_combo;
82     Gtk::ComboBoxText serverpath_combo;
83     Gtk::ComboBoxText driver_combo;
84     Gtk::ComboBoxText device_combo;
85     Gtk::ComboBoxText timeout_combo;
86     Gtk::ComboBoxText dither_mode_combo;
87     Gtk::ComboBoxText audio_mode_combo;
88     Gtk::ComboBoxText midi_driver_combo;
89     
90     Gtk::Table basic_packer;
91     Gtk::Table midi_packer;
92     Gtk::HBox basic_hbox;
93     Gtk::HBox midi_hbox;
94
95     sigc::connection sr_connection;
96     sigc::connection bs_connection;
97     
98     static bool engine_running ();
99     
100     void driver_changed ();
101     void backend_changed ();
102     void sample_rate_changed ();
103     void buffer_size_changed ();
104
105     uint32_t get_rate() const;
106     uint32_t get_buffer_size() const;
107     uint32_t get_input_channels() const;
108     uint32_t get_output_channels() const;
109     uint32_t get_input_latency() const;
110     uint32_t get_output_latency() const;
111     std::string get_device_name() const;
112     std::string get_driver() const;
113
114     void audio_mode_changed ();
115     void device_changed ();
116     void list_devices ();
117     void reshow_buffer_sizes (bool choice_changed);
118
119     struct State {
120         std::string backend;
121         std::string driver;
122         std::string device;
123         std::string sample_rate;
124         std::string buffer_size;
125         uint32_t input_latency;
126         uint32_t output_latency;
127         uint32_t input_channels;
128         uint32_t output_channels;
129         bool active;
130
131         State() : active (false) {};
132     };
133     
134     typedef std::list<State> StateList;
135
136     StateList states;
137
138     State* get_matching_state (const std::string& backend,
139                                const std::string& driver,
140                                const std::string& device);
141     State* get_current_state ();
142     void maybe_set_state ();
143     void save_state ();
144 };
145
146 #endif /* __gtk2_ardour_engine_dialog_h__ */