changeset 861:59a876be8550 trunk

[svn] - refine watchdog thread.
author yaz
date Thu, 15 Mar 2007 08:04:47 -0700
parents cafc7d5769f9
children baa22cb0216d
files ChangeLog src/cue/cuesheet.c
diffstat 2 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 15 04:43:58 2007 -0700
+++ b/ChangeLog	Thu Mar 15 08:04:47 2007 -0700
@@ -1,3 +1,13 @@
+2007-03-15 11:43:58 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [1820]
+  - support "Repeat".
+  - fill index of last_cue_tack before activate watchdog thread.
+  - improve handling of last track.
+  
+  trunk/src/cue/cuesheet.c |   39 ++++++++++++++++++++++++---------------
+  1 file changed, 24 insertions(+), 15 deletions(-)
+
+
 2007-03-15 06:50:12 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
   revision [1818]
   - make use of playlist_set_position() instead of playlist_prev/next(). now cuesheet directly jumps to the objective track.
--- a/src/cue/cuesheet.c	Thu Mar 15 04:43:58 2007 -0700
+++ b/src/cue/cuesheet.c	Thu Mar 15 08:04:47 2007 -0700
@@ -341,6 +341,7 @@
 static gpointer do_stop(gpointer data)
 {
     InputPlayback *playback = (InputPlayback *)data;
+    Playlist *playlist = playlist_get_active();
 #ifdef DEBUG
     g_print("f: do_stop\n");
 #endif
@@ -348,9 +349,11 @@
     playback_stop();
     ip_data.stop = FALSE;
 
+    PLAYLIST_LOCK(playlist->mutex);
     gdk_threads_enter();
     mainwin_clear_song_info();
     gdk_threads_leave();
+    PLAYLIST_UNLOCK(playlist->mutex);
 
 #ifdef DEBUG
     g_print("e: do_stop\n");
@@ -574,7 +577,7 @@
         }
 
         // next track
-        if (time > cue_tracks[cur_cue_track + 1].index)
+        if (cur_cue_track + 1 < last_cue_track && time > cue_tracks[cur_cue_track + 1].index)
         {
             guint pos;
 #ifdef DEBUG
@@ -585,9 +588,6 @@
                     last_cue_track, cue_tracks[last_cue_track].index);
 #endif
             while(time > cue_tracks[cur_cue_track + 1].index) {
-                if(cur_cue_track + 1 == last_cue_track) {
-                    goto END_OF_CUE;
-                }
                 cur_cue_track++;
                 pos = cur_cue_track;
                 if (time <= cue_tracks[cur_cue_track].index)
@@ -603,19 +603,16 @@
             }
         }
 
-    END_OF_CUE:
-        // end of file
+        // last track
         if (cur_cue_track + 1 == last_cue_track &&
-            abs(cue_tracks[cur_cue_track + 1].index - time) < 500) { // difference < 500ms
+            (cue_tracks[last_cue_track].index - time < 500 ||
+             time > cue_tracks[last_cue_track].index) ){ // may not happen. for safety.
             if(!real_ip->output->buffer_playing()) {
 #ifdef DEBUG
                 g_print("i: watchdog eof reached\n");
 #endif
                 if(cfg.repeat) {
                     guint pos = 0;
-#ifdef DEBUG
-                    g_print("i: watchdog repeat\n");
-#endif
                     exec_thread = g_thread_create(do_setpos, &pos, FALSE, NULL);
                 }
                 else {