+++ /dev/null
-/*
- Copyright (C) 2004 Paul Davis
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- $Id$
-
-*/
-
-#include <gtkmm/stock.h>
-
-#include "ardour_message.h"
-#include "i18n.h"
-
-using namespace std;
-using namespace Gtk;
-
-ArdourMessage::ArdourMessage (Gtk::Window* parent,
- string name, string msg,
- bool grab_focus, bool auto_run)
- : ArdourDialog (name),
- label (msg)
-{
- label.set_name (X_("PrompterLabel"));
- label.set_justify (JUSTIFY_CENTER);
- label.show ();
-
- get_vbox()->pack_start (label);
-
- Button* ok_button = add_button (Stock::OK, RESPONSE_ACCEPT);
-
- set_name (X_("Prompter"));
- set_position (Gtk::WIN_POS_MOUSE);
- set_modal (true);
- set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU);
-
- if (grab_focus) {
- ok_button->grab_focus ();
- }
-
- if (parent) {
- set_transient_for (*parent);
- }
-
- if (auto_run) {
- run ();
- }
-}
-
-ArdourMessage::~ArdourMessage()
-{
-}
+++ /dev/null
-/*
- Copyright (C) 2004 Paul Davis
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- $Id$
-
-*/
-
-#ifndef __ardour_message_h__
-#define __ardour_message_h__
-
-#include <string>
-
-#include <gtkmm/box.h>
-#include <gtkmm/button.h>
-#include <gtkmm/label.h>
-
-#include "ardour_dialog.h"
-
-class ArdourMessage : public ArdourDialog
-{
- public:
- ArdourMessage (Gtk::Window* parent,
- std::string name, std::string msg,
- bool grabfocus = true,
- bool autorun = true);
- ~ArdourMessage();
-
- private:
- Gtk::Label label;
-
-};
-
-#endif // __ardour_message_h__
/*
- Copyright (C) 1999-2002 Paul Davis
+ Copyright (C) 1999-2007 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <iostream>
+#include <sys/resource.h>
+
#include <gtkmm/messagedialog.h>
#include <gtkmm/accelmap.h>
sigc::signal<void,bool> ARDOUR_UI::Blink;
sigc::signal<void> ARDOUR_UI::RapidScreenUpdate;
+sigc::signal<void> ARDOUR_UI::MidRapidScreenUpdate;
sigc::signal<void> ARDOUR_UI::SuperRapidScreenUpdate;
sigc::signal<void,nframes_t> ARDOUR_UI::Clock;
void
ARDOUR_UI::startup ()
{
- // relax
+ if (engine->is_realtime()) {
+
+ struct rlimit limits;
+
+ if (getrlimit (RLIMIT_MEMLOCK, &limits)) {
+ return;
+ }
+
+ if (limits.rlim_cur != RLIM_INFINITY) {
+ MessageDialog msg (_("WARNING: Your system has a limit for maximum amount of locked memory. "
+ "This might cause Ardour to run out of memory before your system "
+ "runs out of memory. \n\n"
+ "You can view the memory limit with 'ulimit -l', "
+ "and it is normally controlled by /etc/security/limits.conf"));
+
+ msg.run ();
+ }
+ }
}
void
return TRUE;
}
+gint
+ARDOUR_UI::every_point_oh_five_seconds ()
+{
+ MidRapidScreenUpdate(); /* EMIT_SIGNAL */
+ return true;
+}
+
gint
ARDOUR_UI::every_point_zero_one_seconds ()
{
ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::engine_running));
ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, true);
ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, false);
+
+ Glib::RefPtr<Action> action;
+ char* action_name = 0;
+
+ switch (engine->frames_per_cycle()) {
+ case 32:
+ action_name = X_("JACKLatency32");
+ break;
+ case 64:
+ action_name = X_("JACKLatency64");
+ break;
+ case 128:
+ action_name = X_("JACKLatency128");
+ break;
+ case 512:
+ action_name = X_("JACKLatency512");
+ break;
+ case 1024:
+ action_name = X_("JACKLatency1024");
+ break;
+ case 2048:
+ action_name = X_("JACKLatency2048");
+ break;
+ case 4096:
+ action_name = X_("JACKLatency4096");
+ break;
+ case 8192:
+ action_name = X_("JACKLatency8192");
+ break;
+ default:
+ /* XXX can we do anything useful ? */
+ break;
+ }
+
+ if (action_name) {
+
+ action = ActionManager::get_action (X_("JACK"), action_name);
+
+ if (action) {
+ Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (action);
+ ract->set_active ();
+ }
+ }
}
void
{
ArdourPrompter prompter (true);
string snapname;
- string now;
+ char timebuf[128];
time_t n;
+ struct tm local_time;
time (&n);
- now = ctime (&n);
- now = now.substr (20, 4) + now.substr (3, 16) + " (" + now.substr (0, 3) + ")";
+ localtime_r (&n, &local_time);
+ strftime (timebuf, sizeof(timebuf), "%FT%T", &local_time);
prompter.set_name ("Prompter");
prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
prompter.set_prompt (_("Name of New Snapshot"));
- prompter.set_initial_text (now);
+ prompter.set_initial_text (timebuf);
switch (prompter.run()) {
case RESPONSE_ACCEPT:
}
}
-void
-ARDOUR_UI::set_jack_buffer_size (nframes_t nframes)
-{
- engine->request_buffer_size (nframes);
- update_sample_rate (0);
-}
-
int
ARDOUR_UI::cmdline_new_session (string path)
{
static sigc::signal<void,bool> Blink;
static sigc::signal<void> RapidScreenUpdate;
+ static sigc::signal<void> MidRapidScreenUpdate;
static sigc::signal<void> SuperRapidScreenUpdate;
static sigc::signal<void,nframes_t> Clock;
gint every_second ();
gint every_point_one_seconds ();
+ gint every_point_oh_five_seconds ();
gint every_point_zero_one_seconds ();
sigc::connection second_connection;
sigc::connection point_one_second_connection;
+ sigc::connection point_oh_five_second_connection;
sigc::connection point_zero_one_second_connection;
gint session_menu (GdkEventButton *);
second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_second), 1000);
point_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
+ // point_oh_five_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_oh_five_seconds), 50);
point_zero_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
}
editor->hide ();
second_connection.disconnect ();
point_one_second_connection.disconnect ();
+ point_oh_five_second_connection.disconnect ();
point_zero_one_second_connection.disconnect();
ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false);
#include "actions.h"
#include <ardour/session.h>
+#include <ardour/audioengine.h>
#include <ardour/control_protocol_manager.h>
#include <control_protocol/control_protocol.h>
}
}
+void
+ARDOUR_UI::set_jack_buffer_size (nframes_t nframes)
+{
+ Glib::RefPtr<Action> action;
+ char* action_name = 0;
+
+ switch (nframes) {
+ case 32:
+ action_name = X_("JACKLatency32");
+ break;
+ case 64:
+ action_name = X_("JACKLatency64");
+ break;
+ case 128:
+ action_name = X_("JACKLatency128");
+ break;
+ case 512:
+ action_name = X_("JACKLatency512");
+ break;
+ case 1024:
+ action_name = X_("JACKLatency1024");
+ break;
+ case 2048:
+ action_name = X_("JACKLatency2048");
+ break;
+ case 4096:
+ action_name = X_("JACKLatency4096");
+ break;
+ case 8192:
+ action_name = X_("JACKLatency8192");
+ break;
+ default:
+ /* XXX can we do anything useful ? */
+ break;
+ }
+
+ if (action_name) {
+
+ action = ActionManager::get_action (X_("JACK"), action_name);
+
+ if (action) {
+ Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (action);
+
+ if (ract && ract->get_active()) {
+ engine->request_buffer_size (nframes);
+ update_sample_rate (0);
+ }
+ }
+ }
+}
+
void
ARDOUR_UI::build_control_surface_menu ()
{
button_release_can_deselect = true;
canvas_idle_queued = false;
_dragging_playhead = false;
+ _dragging_hscrollbar = false;
location_marker_color = color_map[cLocationMarker];
location_range_color = color_map[cLocationRange];
edit_vscrollbar.set_adjustment (vertical_adjustment);
edit_hscrollbar.set_adjustment (horizontal_adjustment);
- edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press));
- edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release));
+ edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press), false);
+ edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release), false);
edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
edit_hscrollbar.set_name ("EditorHScrollbar");
if (new_end > last_canvas_frame) {
last_canvas_frame = new_end;
+ horizontal_adjustment.set_upper (last_canvas_frame / frames_per_unit);
reset_scrolling_region ();
}
instant_save ();
}
-void
-Editor::canvas_horizontally_scrolled ()
-{
- /* this is the core function that controls horizontal scrolling of the canvas. it is called
- whenever the horizontal_adjustment emits its "value_changed" signal. it executes in an
- idle handler, which is important because tempo_map_changed() should issue redraws immediately
- and not defer them to an idle handler.
- */
-
- leftmost_frame = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
- nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
-
- if (rightmost_frame > last_canvas_frame) {
- last_canvas_frame = rightmost_frame;
- reset_scrolling_region ();
- }
-
- update_fixed_rulers ();
- tempo_map_changed (Change (0), true);
-}
-
void
Editor::queue_visual_change (nframes_t where)
{
void controls_layout_size_request (Gtk::Requisition*);
Gtk::HScrollbar edit_hscrollbar;
+ bool _dragging_hscrollbar;
void reset_hscrollbar_stepping ();
}
+void
+Editor::canvas_horizontally_scrolled ()
+{
+ /* this is the core function that controls horizontal scrolling of the canvas. it is called
+ whenever the horizontal_adjustment emits its "value_changed" signal. it typically executes in an
+ idle handler, which is important because tempo_map_changed() should issue redraws immediately
+ and not defer them to an idle handler.
+ */
+
+ leftmost_frame = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
+ nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
+
+ if (rightmost_frame > last_canvas_frame) {
+ last_canvas_frame = rightmost_frame;
+ reset_scrolling_region ();
+ }
+
+ update_fixed_rulers ();
+
+ tempo_map_changed (Change (0), !_dragging_hscrollbar);
+}
+
bool
Editor::hscrollbar_button_press (GdkEventButton *ev)
{
- return true;
+ _dragging_hscrollbar = true;
+ return false;
}
bool
Editor::hscrollbar_button_release (GdkEventButton *ev)
{
+ _dragging_hscrollbar = false;
+
if (session) {
}
- return true;
+ return false;
}
void
}
playhead_cursor->set_position (frame);
+
+#undef CONTINUOUS_SCROLL
+#ifdef CONTINUOUS_SCROLL
+
+ /* don't do continuous scroll till the new position is in the rightmost quarter of the
+ editor canvas
+ */
+
+#if 0
+ if (frame > leftmost_frame + (3 * current_page_frames() / 4)) {
+
+ if (frame > playhead_cursor->current_frame) {
+ nframes_t delta = frame - playhead_cursor->current_frame;
+ horizontal_adjustment.set_value (horizontal_adjustment.get_value() + (delta/frames_per_unit));
+ } else {
+ nframes_t delta = playhead_cursor->current_frame - frame;
+ horizontal_adjustment.set_value (horizontal_adjustment.get_value() - (delta/frames_per_unit));
+ }
+ }
+#else
+ horizontal_adjustment.set_value (frame / frames_per_unit);
+#endif
+
+#endif // CONTINUOUS_SCROLL
+
}
} else {
end_dialog ();
}
-
void
ExportDialog::end_dialog ()
{
string dir = session->path();
string::size_type last_slash;
- if ((last_slash = dir.find_last_of ('/')) != string::npos) {
+ if ((last_slash = dir.find_last_of ('/')) != string::npos && last_slash != 0) {
dir = dir.substr (0, last_slash+1);
}
- dir = dir + "export.wav";
+ if (!wants_dir()) {
+ dir = dir + "export.wav";
+ }
file_entry.set_text (dir);
}
// audio data. spec has already been filled with user input before calling
// this method. The dialog will be closed after this function exited.
virtual void export_audio_data() = 0;
+
+ virtual bool wants_dir() { return false; }
// reads the user input and fills spec with the according values
// filepath: complete path to the target file, including filename
}
}
- getSession().engine().freewheel (false);
current_range_marker_index++;
}
}
if ( (stat (filepath.c_str(), &statbuf) != 0) ||
(!S_ISDIR (statbuf.st_mode)) ) {
- string txt = _("Please select an existing target directory. Files\n"
- "are not allowed!");
+ string txt = _("Please select an existing target directory. Files are not allowed!");
MessageDialog msg (*this, txt, false, MESSAGE_ERROR, BUTTONS_OK, true);
msg.run();
return false;
virtual bool is_filepath_valid(string &filepath);
void export_audio_data();
+
+ bool wants_dir() { return true; }
private:
// keeps the duration of all range_markers before the current
return false;
}
+
ustring
short_path (ustring path, uint32_t target_characters)
{
- ustring::size_type slash;
+ ustring::size_type last_sep;
ustring::size_type len = path.length();
-
+ const char separator = '/';
+
if (len <= target_characters) {
return path;
}
+ if ((last_sep = path.find_last_of (separator)) == ustring::npos) {
- slash = path.find_last_of ('/');
+ /* just a filename, but its too long anyway */
- if (len - slash > target_characters) {
- /* even the filename itself is too long, so just return it - its
- the best we can do
- */
- return path.substr (slash);
+ if (target_characters > 3) {
+ return path.substr (0, target_characters - 3) + ustring ("...");
+ } else {
+ /* stupid caller, just hand back the whole thing */
+ return path;
+ }
+ }
+
+ if (len - last_sep >= target_characters) {
+
+ /* even the filename itself is too long */
+
+ if (target_characters > 3) {
+ return path.substr (last_sep+1, target_characters - 3) + ustring ("...");
+ } else {
+ /* stupid caller, just hand back the whole thing */
+ return path;
+ }
}
- uint32_t so_far = (len - slash) + 4; // allow for .../
+ uint32_t so_far = (len - last_sep);
uint32_t space_for = target_characters - so_far;
-
- if (slash < target_characters) {
- return path;
- }
- string res = ".../";
- res += path.substr (slash - space_for);
-
- return res;
+ if (space_for >= 3) {
+ ustring res = "...";
+ res += path.substr (last_sep - space_for);
+ return res;
+ } else {
+ /* remove part of the end */
+ ustring res = "...";
+ res += path.substr (last_sep - space_for, len - last_sep + space_for - 3);
+ res += "...";
+ return res;
+
+ }
}
jack_client_t* jack() const { return _jack; }
bool connected() const { return _jack != 0; }
+ bool is_realtime () const;
+
std::string client_name() const { return jack_client_name; }
int reconnect_to_jack ();
#include <glibmm/timer.h>
#include <pbd/pthread_utils.h>
+#include <pbd/stacktrace.h>
#include <ardour/audioengine.h>
#include <ardour/buffer.h>
if (_freewheeling) {
if (Freewheel (nframes)) {
+ cerr << "Freewheeling returned non-zero!\n";
_freewheeling = false;
jack_set_freewheel (_jack, false);
}
_freewheel_thread_registered = false;
}
+ if (!onoff) {
+ stacktrace (cout);
+ }
+
return jack_set_freewheel (_jack, onoff);
} else {
AudioEngine::request_buffer_size (nframes_t nframes)
{
if (_jack) {
- int ret = jack_set_buffer_size (_jack, nframes);
- return ret;
+
+ if (nframes == jack_get_buffer_size (_jack)) {
+ return 0;
+ }
+
+ return jack_set_buffer_size (_jack, nframes);
+
} else {
return -1;
}
return str;
}
+bool
+AudioEngine::is_realtime () const
+{
+ if (_jack) {
+ return jack_is_realtime (_jack);
+ } else {
+ return false;
+ }
+}