From 02d20ebc25e90914528c6af712f27c5424b863a4 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 15 Dec 2017 21:46:30 -0500 Subject: Fix big WTF when closing the current track. It must be set to something else valid (unless it's the only one left) when closing it, IN ALL CASES, not just if it's first or last. Don't know what was in my head. Hopefully takes care of a reported issue. Even if it's not causing any issues, it was still incorrect. Change-Id: I594af8b35d774ec222dadce80dfa8b95138f037e --- apps/playback.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'apps/playback.c') diff --git a/apps/playback.c b/apps/playback.c index 25aa1948d6..8b607f30f0 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -611,38 +611,22 @@ static void track_list_free_buf_info(struct track_buf_info *tbip) return; } + /* If this one is the current track; new current track is next one, + if any, else, the previous */ + if (hid == track_list.current_hid) + track_list.current_hid = next_hid > 0 ? next_hid : prev_hid; + + /* Fixup list links */ if (prev_tbip) - { prev_tbip->link[1] = next_hid; - } else - { - /* Was the first track; new first track is next one */ track_list.first_hid = next_hid; - if (hid == track_list.current_hid) - { - /* Was the current track; new current track is next one */ - track_list.current_hid = next_hid; - } - } - if (next_tbip) - { next_tbip->link[0] = prev_hid; - } else - { - /* Was the last track; new last track is previous one */ track_list.last_hid = prev_hid; - if (hid == track_list.current_hid) - { - /* Was the current track; new current track is previous one */ - track_list.current_hid = prev_hid; - } - } - track_list.count--; } -- cgit v1.2.3