marlin r1325 - in trunk: marlin src



Author: iain
Date: Wed Oct 22 00:24:08 2008
New Revision: 1325
URL: http://svn.gnome.org/viewvc/marlin?rev=1325&view=rev

Log:
Make reverse work correctly


Modified:
   trunk/marlin/ChangeLog
   trunk/marlin/marlin-channel.c
   trunk/marlin/marlin-sample.c
   trunk/src/marlin-window-menu.c

Modified: trunk/marlin/marlin-channel.c
==============================================================================
--- trunk/marlin/marlin-channel.c	(original)
+++ trunk/marlin/marlin-channel.c	Wed Oct 22 00:24:08 2008
@@ -1537,14 +1537,8 @@
 		frames_needed -= got_frames;
 		insert_point += got_frames;
 
-		if (block != next_block) {
-			block = next_block;
-			if (block != NULL) {
-				block_start = (block_start + got_frames);
-			}
-		} else {
-			block_start += got_frames;
-		}
+		block = next_block;
+		block_start += got_frames;
 	}
 
 	g_free (buf);
@@ -2003,7 +1997,7 @@
 			      GError **error)
 {
 	MarlinBlock *block, *b;
-	guint64 frames_needed, insert_point;
+	guint64 frames_needed, insert_point, block_start;
 	float *buf;
 	gboolean ret;
 
@@ -2016,17 +2010,20 @@
 	lockless_unlink_range (channel, start, finish, &block, ctxt);
 	b = block;
 
+	/* When the blocks are unlinked the ranges are recalculated, so
+	   start no longer equals block->start */
+	block_start = block->start;
 	insert_point = start;
 
 	/* We get a block size, reverse it and insert it before all the other
 	   reversed blocks */
-	while (frames_needed > 0) {
+	while (frames_needed > 0 && block) {
 		MarlinBlock *next_block;
 		guint got_frames, frames_avail;
 		int i;
 
 		frames_avail = MIN (frames_needed, MARLIN_BLOCK_SIZE);
-		got_frames = marlin_block_get_buffer (block, buf, start,
+		got_frames = marlin_block_get_buffer (block, buf, block_start,
 						      frames_avail,
 						      &next_block);
 
@@ -2044,9 +2041,10 @@
 		ret = lockless_insert_data (channel, buf, got_frames,
 					    insert_point, ctxt, error);
 
-		block = next_block;
 		frames_needed -= got_frames;
-		start += got_frames;
+
+		block = next_block;
+		block_start += got_frames;
 
 		memset (buf, 0, MARLIN_BLOCK_SIZE * sizeof (float));
 	}

Modified: trunk/marlin/marlin-sample.c
==============================================================================
--- trunk/marlin/marlin-sample.c	(original)
+++ trunk/marlin/marlin-sample.c	Wed Oct 22 00:24:08 2008
@@ -2576,7 +2576,7 @@
 	case MARLIN_COVERAGE_BOTH:
 		for (i = 0; i < sample->priv->channels; i++) {
 			marlin_channel_reverse_range (sample->priv->channel_data->pdata[i],
-						      range->start, 
+						      range->start,
 						      range->finish,
 						      operation, ctxt, error);
 		}
@@ -2584,7 +2584,7 @@
 
 	case MARLIN_COVERAGE_LEFT:
 		marlin_channel_reverse_range (sample->priv->channel_data->pdata[0],
-					      range->start, range->finish, 
+					      range->start, range->finish,
 					      operation, ctxt, error);
 		break;
 
@@ -2597,7 +2597,7 @@
 		}
 
 		marlin_channel_reverse_range (sample->priv->channel_data->pdata[1],
-					      range->start, range->finish, 
+					      range->start, range->finish,
 					      operation, ctxt, error);
 		break;
 

Modified: trunk/src/marlin-window-menu.c
==============================================================================
--- trunk/src/marlin-window-menu.c	(original)
+++ trunk/src/marlin-window-menu.c	Wed Oct 22 00:24:08 2008
@@ -1072,19 +1072,19 @@
 };
 
 static GtkActionEntry process_entries[] = {
-	{ "ProcessMute", NULL, N_("Mute Sample"), NULL, 
+	{ "ProcessMute", NULL, N_("Mute Sample"), NULL,
 	  N_("Mute the selection"),
 	  G_CALLBACK (process_mute) },
-	{ "ProcessInvert", NULL, N_("Invert Sample"), NULL, 
+	{ "ProcessInvert", NULL, N_("Invert Sample"), NULL,
 	  N_("Invert the selection"),
 	  G_CALLBACK (process_invert) },
-	{ "ProcessSwapChannels", NULL, N_("Swap Sample Channels"), NULL, 
+	{ "ProcessSwapChannels", NULL, N_("Swap Sample Channels"), NULL,
 	  N_("Swap the samples channels"),
 	  G_CALLBACK (process_swap_channels) },
-	{ "ProcessVolume", NULL, N_("Adjust Sample Volume..."), NULL, 
+	{ "ProcessVolume", NULL, N_("Adjust Sample Volume..."), NULL,
 	  N_("Adjust the volume of the sample"),
 	  G_CALLBACK (process_adjust_volume) },
-	{ "ProcessInsertSilence", NULL, N_("Insert Silence..."), NULL, 
+	{ "ProcessInsertSilence", NULL, N_("Insert Silence..."), NULL,
 	  N_("Insert silence into the sample"),
 	  G_CALLBACK (process_insert_silence) },
 	{ "ProcessAdjustChannels", NULL, N_("Adjust Number of Channels..."), NULL,
@@ -1108,16 +1108,16 @@
 	{ "ZoomOut", MARLIN_STOCK_HZOOM_OUT, N_("Zoom Out"), "<control>minus",
 	  N_("Zoom out of the sample"),
 	  G_CALLBACK (zoom_out) },
-	{ "ShowAll", NULL, N_("Show All"), NULL, 
+	{ "ShowAll", NULL, N_("Show All"), NULL,
 	  N_("Show the whole sample"),
 	  G_CALLBACK (zoom_all) },
-	{ "ZoomSelection", NULL, N_("Zoom Selection"), NULL, 
+	{ "ZoomSelection", NULL, N_("Zoom Selection"), NULL,
 	  N_("Zoom in on the selection"),
 	  G_CALLBACK (zoom_selection) },
-	{ "ViewClipboard", NULL, N_("Clipboard Info"), NULL, 
+	{ "ViewClipboard", NULL, N_("Clipboard Info"), NULL,
 	  N_("Show information about the clipboard"),
 	  G_CALLBACK (view_clipboard_info) },
-	{ "ViewCentre", NULL, N_("Centre on Cursor"), NULL, 
+	{ "ViewCentre", NULL, N_("Centre on Cursor"), NULL,
 	  N_("Centre the sample view on the cursor"),
 	  G_CALLBACK (view_centre) },
 	{ "ViewVZoomIn", MARLIN_STOCK_VZOOM_IN, N_("Vertical Zoom In"), "<control><shift>plus",
@@ -1216,10 +1216,10 @@
 	{ "MarkerAdd", GTK_STOCK_ADD, N_("Add Marker"), NULL,
 	  N_("Add a marker to the sample"),
 	  G_CALLBACK (marker_view_add_marker) },
-	{ "MarkerDelete", GTK_STOCK_REMOVE, N_("Remove Marker"), NULL, 
+	{ "MarkerDelete", GTK_STOCK_REMOVE, N_("Remove Marker"), NULL,
 	  N_("Remove this marker from the sample"),
 	  G_CALLBACK (marker_view_remove_marker) },
-	{ "MarkerGoto", GTK_STOCK_JUMP_TO, N_("Goto Marker"), NULL, 
+	{ "MarkerGoto", GTK_STOCK_JUMP_TO, N_("Goto Marker"), NULL,
 	  N_("Move the cursor to this marker's location"),
 	  G_CALLBACK (marker_view_goto_marker) },
 	{ "MarkerEdit", NULL, N_("Edit Marker"), NULL,
@@ -1238,10 +1238,10 @@
 
 	gtk_action_group_add_actions (ag, popup_toplevel_entries, G_N_ELEMENTS (popup_toplevel_entries), window);
 
-	gtk_action_group_add_radio_actions (ag, scale_popup_radio_entries, 
-					    G_N_ELEMENTS (scale_popup_radio_entries), 
-					    scale, 
-					    G_CALLBACK (scale_action_changed), 
+	gtk_action_group_add_radio_actions (ag, scale_popup_radio_entries,
+					    G_N_ELEMENTS (scale_popup_radio_entries),
+					    scale,
+					    G_CALLBACK (scale_action_changed),
 					    window);
 	gtk_action_group_add_actions (ag, marker_entries, G_N_ELEMENTS (marker_entries), window);
 	gtk_action_group_add_toggle_actions (ag, popup_toggle_entries, G_N_ELEMENTS (popup_toggle_entries), window);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]