marlin r1321 - trunk/marlin



Author: iain
Date: Tue Oct 21 00:41:38 2008
New Revision: 1321
URL: http://svn.gnome.org/viewvc/marlin?rev=1321&view=rev

Log:
Fix crash when searching for previous zero crossing


Modified:
   trunk/marlin/ChangeLog
   trunk/marlin/marlin-channel.c
   trunk/marlin/marlin-sample.c

Modified: trunk/marlin/marlin-channel.c
==============================================================================
--- trunk/marlin/marlin-channel.c	(original)
+++ trunk/marlin/marlin-channel.c	Tue Oct 21 00:41:38 2008
@@ -1891,22 +1891,22 @@
 			position++;
 			pos_in_block++;
 		}
-		
+
 		/* Get the previous block */
 		READ_UNLOCK (block->lock);
 		block = block->next;
 
 		if (block) {
 			READ_LOCK (block->lock);
-			
+
 			/* Reset everything */
 			position = block->start;
 			data = marlin_block_get_frame_data (block);
 		}
 	}
-		
+
 	/* If we're here, we didn't find a 0 */
-	
+
 	READ_UNLOCK (channel->lock);
 	return orig;
 }
@@ -1919,7 +1919,7 @@
  */
 guint64
 marlin_channel_previous_zero (MarlinChannel *channel,
-			      guint64 position)
+			      guint64        position)
 {
 	MarlinBlock *block;
 	float *data;
@@ -1952,25 +1952,29 @@
 				READ_UNLOCK (channel->lock);
 				return position;
 			}
+
+			if (pos_in_block == 0) {
+				break;
+			}
+
 			position--;
 			pos_in_block--;
 		}
-		
+
 		/* Get the previous block */
 		READ_UNLOCK (block->lock);
 		block = block->previous;
 
 		if (block) {
 			READ_LOCK (block->lock);
-			
+
 			/* Reset everything */
 			position = block->end;
 			data = marlin_block_get_frame_data (block);
 		}
 	}
-		
+
 	/* If we're here, we didn't find a 0 */
-	
 	READ_UNLOCK (channel->lock);
 	return orig;
 }

Modified: trunk/marlin/marlin-sample.c
==============================================================================
--- trunk/marlin/marlin-sample.c	(original)
+++ trunk/marlin/marlin-sample.c	Tue Oct 21 00:41:38 2008
@@ -2485,9 +2485,7 @@
 		for (i = 0; i < priv->channels; i++) {
 			new_pos = marlin_channel_previous_zero (priv->channel_data->pdata[i],
 								position);
-			if (pos == position) {
-				pos = new_pos;
-			} else {
+			if (new_pos != position) {
 				pos = MAX (new_pos, pos);
 			}
 		}



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