Index: apps/playback.c
===================================================================
--- apps/playback.c (revision 29533)
+++ apps/playback.c (working copy)
@@ -1585,8 +1585,6 @@
track_count = audio_track_count();
old_track_ridx = track_ridx;

- /* Now it's good time to send track finish events. */
- send_event(PLAYBACK_EVENT_TRACK_FINISH, thistrack_id3);
/* swap the mp3entry pointers */
temp = thistrack_id3;
thistrack_id3 = othertrack_id3;
@@ -1776,22 +1774,20 @@

static void audio_stop_playback(void)
{
+ automatic_skip = false;
+
if (playing)
{
/* If we were playing, save resume information */
- struct mp3entry *id3 = NULL;
+ struct mp3entry *id3 = audio_current_track();

- if (!ci.stop_codec)
- id3 = audio_current_track();
-
/* Save the current playing spot, or NULL if the playlist has ended */
- playlist_update_resume_info(id3);
+ playlist_update_resume_info(filling == STATE_ENDING ? NULL : id3);

/* Now it's good time to send track finish events. Do this
only if this hasn't been done already as part of a track
switch. */
- if (id3 == thistrack_id3)
- send_event(PLAYBACK_EVENT_TRACK_FINISH, thistrack_id3);
+ send_event(PLAYBACK_EVENT_TRACK_FINISH, id3);

/* TODO: Create auto bookmark too? */

@@ -1928,6 +1924,9 @@
{
logf("audio_finalise_track_change");

+ /* Now it's good time to send track finish events. */
+ send_event(PLAYBACK_EVENT_TRACK_FINISH, othertrack_id3);
+
if (automatic_skip)
{
wps_offset = 0;
@@ -2169,14 +2168,6 @@
break;
}

- if ((long)ev.data == 0)
- {
- /* About to restart the track - send track finish
- events if not already done. */
- if (thistrack_id3 == audio_current_track())
- send_event(PLAYBACK_EVENT_TRACK_FINISH, thistrack_id3);
- }
-
if (automatic_skip)
{
/* An automatic track skip is in progress. Finalize it,