summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-05-30 17:46:33 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-05-30 17:46:33 +0000
commit1fedefc78592a1c1cde15891b699c75b384704f0 (patch)
treece29a2b4357aa0c70ae17cbb5aa578375071f678
parent1493c901e9733d1250d93beca1958d3decfd1928 (diff)
more use of int64_t to fix frame offset values
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@1931 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/draginfo.h10
-rw-r--r--gtk2_ardour/editor.cc12
-rw-r--r--gtk2_ardour/editor.h9
-rw-r--r--gtk2_ardour/editor_mouse.cc22
-rw-r--r--gtk2_ardour/editor_rulers.cc25
-rw-r--r--libs/ardour/ardour/types.h6
6 files changed, 40 insertions, 44 deletions
diff --git a/gtk2_ardour/draginfo.h b/gtk2_ardour/draginfo.h
index c38c2aaa65..0b9648a81c 100644
--- a/gtk2_ardour/draginfo.h
+++ b/gtk2_ardour/draginfo.h
@@ -39,11 +39,11 @@ struct DragInfo {
ArdourCanvas::Item* item;
ItemType item_type;
void* data;
- nframes_t last_frame_position;
- int64_t pointer_frame_offset;
- nframes_t grab_frame;
- nframes_t last_pointer_frame;
- nframes_t current_pointer_frame;
+ nframes64_t last_frame_position;
+ nframes64_t pointer_frame_offset;
+ nframes64_t grab_frame;
+ nframes64_t last_pointer_frame;
+ nframes64_t current_pointer_frame;
double grab_x, grab_y;
double cumulative_x_drag;
double cumulative_y_drag;
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index d79bd5b2c7..f621638bba 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -2236,7 +2236,7 @@ Editor::trackview_by_y_position (double y)
}
void
-Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
+Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
{
Location* before = 0;
Location* after = 0;
@@ -2245,11 +2245,11 @@ Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
return;
}
- const nframes_t one_second = session->frame_rate();
- const nframes_t one_minute = session->frame_rate() * 60;
- const nframes_t one_smpte_second = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
- nframes_t one_smpte_minute = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
- nframes_t presnap = start;
+ const nframes64_t one_second = session->frame_rate();
+ const nframes64_t one_minute = session->frame_rate() * 60;
+ const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
+ nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
+ nframes64_t presnap = start;
switch (snap_type) {
case SnapToFrame:
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index bbdc107652..44f105865c 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1288,7 +1288,14 @@ class Editor : public PublicEditor
void tempo_map_changed (ARDOUR::Change);
void redisplay_tempo (bool immediate_redraw);
- void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false);
+ void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
+ void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false) {
+ /* XXX remove this function when everything moves to 64 bit frame counts */
+ nframes64_t first64 = first;
+ snap_to (first64, direction, for_mark);
+ first = (nframes_t) first64;
+ }
+
uint32_t bbt_beat_subdivision;
/* toolbar */
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index 8744659b58..3a07700383 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -1449,9 +1449,9 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item
*/
if (!drag_info.move_threshold_passed) {
- bool x_threshold_passed = (abs ((int64_t) (drag_info.current_pointer_x - drag_info.grab_x)) > 4LL);
- bool y_threshold_passed = (abs ((int64_t) (drag_info.current_pointer_y - drag_info.grab_y)) > 4LL);
-
+ bool x_threshold_passed = (abs ((nframes64_t) (drag_info.current_pointer_x - drag_info.grab_x)) > 4LL);
+ bool y_threshold_passed = (abs ((nframes64_t) (drag_info.current_pointer_y - drag_info.grab_y)) > 4LL);
+
drag_info.move_threshold_passed = (x_threshold_passed || y_threshold_passed);
// and change the initial grab loc/frame if this drag info wants us to
@@ -1563,7 +1563,7 @@ Editor::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
drag_info.y_constrained = false;
}
- drag_info.grab_frame = event_frame(event, &drag_info.grab_x, &drag_info.grab_y);
+ drag_info.grab_frame = event_frame (event, &drag_info.grab_x, &drag_info.grab_y);
drag_info.last_pointer_frame = drag_info.grab_frame;
drag_info.current_pointer_frame = drag_info.grab_frame;
drag_info.current_pointer_x = drag_info.grab_x;
@@ -1814,10 +1814,9 @@ Editor::fade_out_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event
nframes_t pos;
nframes_t fade_length;
- if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
+ if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
- }
- else {
+ } else {
pos = 0;
}
@@ -2062,8 +2061,7 @@ Editor::marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
nframes_t newframe;
if (drag_info.pointer_frame_offset <= drag_info.current_pointer_frame) {
newframe = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
- }
- else {
+ } else {
newframe = 0;
}
@@ -2995,7 +2993,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
int32_t sync_dir;
pending_region_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
-
+
sync_offset = rv->region()->sync_offset (sync_dir);
sync_frame = rv->region()->adjust_to_sync (pending_region_position);
@@ -3033,7 +3031,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
} else {
x_delta = -((double) (drag_info.last_frame_position - pending_region_position) / frames_per_unit);
}
-
+
drag_info.last_frame_position = pending_region_position;
} else {
@@ -3057,6 +3055,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
return;
}
+
if (x_delta < 0) {
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
@@ -3183,6 +3182,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
x_delta = max_frames - rv->region()->last_frame();
}
+
if (drag_info.first_move) {
/* hide any dependent views */
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc
index 6f4f4bdb68..2370d8406c 100644
--- a/gtk2_ardour/editor_rulers.cc
+++ b/gtk2_ardour/editor_rulers.cc
@@ -268,8 +268,7 @@ Editor::ruler_mouse_motion (GdkEventMotion* ev)
nframes_t where = leftmost_frame + pixel_to_frame (x);
/// ripped from maybe_autoscroll, and adapted to work here
- nframes_t one_page = (nframes_t) rint (canvas_width * frames_per_unit);
- nframes_t rightmost_frame = leftmost_frame + one_page;
+ nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
if (autoscroll_timeout_tag < 0) {
if (where > rightmost_frame) {
@@ -728,12 +727,7 @@ Editor::update_just_smpte ()
return;
}
- /* XXX Note the potential loss of accuracy here as we convert from
- an uint32_t (or larger) to a float ... what to do ?
- */
-
- nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
- nframes_t rightmost_frame = leftmost_frame + page;
+ nframes_t rightmost_frame = leftmost_frame + current_page_frames();
if (ruler_shown[ruler_metric_smpte]) {
gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_smpte_ruler), leftmost_frame, rightmost_frame,
@@ -750,17 +744,11 @@ Editor::update_fixed_rulers ()
return;
}
- /* XXX Note the potential loss of accuracy here as we convert from
- an uint32_t (or larger) to a float ... what to do ?
- */
-
- nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
-
ruler_metrics[ruler_metric_smpte].units_per_pixel = frames_per_unit;
ruler_metrics[ruler_metric_frames].units_per_pixel = frames_per_unit;
ruler_metrics[ruler_metric_minsec].units_per_pixel = frames_per_unit;
- rightmost_frame = leftmost_frame + page;
+ rightmost_frame = leftmost_frame + current_page_frames ();
/* these force a redraw, which in turn will force execution of the metric callbacks
to compute the relevant ticks to display.
@@ -789,15 +777,10 @@ Editor::update_tempo_based_rulers ()
return;
}
- /* XXX Note the potential loss of accuracy here as we convert from
- an uint32_t (or larger) to a float ... what to do ?
- */
-
- nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
ruler_metrics[ruler_metric_bbt].units_per_pixel = frames_per_unit;
if (ruler_shown[ruler_metric_bbt]) {
- gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_bbt_ruler), leftmost_frame, leftmost_frame+page,
+ gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_bbt_ruler), leftmost_frame, leftmost_frame+current_page_frames(),
leftmost_frame, session->current_end_frame());
}
}
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 05956336b6..7655f486e9 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -47,6 +47,12 @@ typedef int intptr_t;
typedef uint32_t nframes_t;
+/* eventually, we'd like everything (including JACK) to
+ move to this. for now, its a dedicated type.
+*/
+
+typedef int64_t nframes64_t;
+
namespace ARDOUR {
class Source;