1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Index: apps/playlist.c
===================================================================
--- apps/playlist.c  (revision 29682)
+++ apps/playlist.c  (working copy)
@@ -819,6 +819,9 @@

     playlist->amount++;
     playlist->num_inserted_tracks++;
+    
+    /* Update index for resume. */
+    playback_set_playlist_index(playlist->index);

     return insert_position;
 }
@@ -919,6 +922,9 @@

         sync_control(playlist, false);
     }
+    
+    /* Update index for resume. */
+    playback_set_playlist_index(playlist->index);

     return 0;
 }
@@ -978,6 +984,9 @@
         update_control(playlist, PLAYLIST_COMMAND_SHUFFLE, seed,
             playlist->first_index, NULL, NULL, NULL);
     }
+    
+    /* Update index for resume. */
+    playback_set_playlist_index(playlist->index);

     return 0;
 }
@@ -1018,6 +1027,9 @@
         update_control(playlist, PLAYLIST_COMMAND_UNSHUFFLE,
             playlist->first_index, -1, NULL, NULL, NULL);
     }
+    
+    /* Update index for resume. */
+    playback_set_playlist_index(playlist->index);

     return 0;
 }
@@ -1191,6 +1203,9 @@
             break;
         }
     }
+    
+    /* Update index for resume. */
+    playback_set_playlist_index(playlist->index);
 }

 /*
@@ -3174,6 +3189,9 @@
     queue_post(&playlist_queue, PLAYLIST_LOAD_POINTERS, 0);
 #endif

+    /* Update index for resume. */
+    playback_set_playlist_index(playlist->index);
+
     return result;
 }

Index: apps/playback.c
===================================================================
--- apps/playback.c  (revision 29682)
+++ apps/playback.c  (working copy)
@@ -233,7 +233,15 @@

 /**************************************/

+/** Playlist callback */

+/* This callback is required to update the resume index in case of changing
+ * a playlist and pausing/resuming before the next track change. */
+void playback_set_playlist_index(int index)
+{
+    thistrack_id3->index = index;
+}
+
 /** Pcmbuf callbacks */

 /* Between the codec and PCM track change, we need to keep updating the
Index: apps/playback.h
===================================================================
--- apps/playback.h  (revision 29680)
+++ apps/playback.h  (working copy)
@@ -67,6 +67,7 @@
 void audio_pre_ff_rewind(void);
 void audio_skip(int direction);
 void audio_hard_stop(void); /* Stops audio from serving playback */
+void playback_set_playlist_index(int index);
 #ifdef HAVE_CROSSFADE
 void audio_set_crossfade(int enable);
 #endif