playback: fix single mode handling with auto frequency switch enabled

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 3373ed674421e6c917bcece4f2c524e28f0a56e1
Author: Roman Artiukhin <[email protected]>
Date:   Thu Feb 19 12:28:19 2026 +0200

    playback: fix single mode handling with auto frequency switch enabled
    
    Fix single mode fails to pause between tracks with different sample rates with auto frequency switch enabled.
    
    Fixup for c199d9a3
    
    Change-Id: I51bbd33a15be16b711b3a8e46c0cab1b15a93705

diff --git a/apps/playback.c b/apps/playback.c
index bdd2cfe14f..0e8871c96c 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -2734,6 +2734,16 @@ static void audio_finalise_track_change(void)
     {
         buf_read_cuesheet(info.cuesheet_hid);
         track_id3 = bufgetid3(info.id3_hid);
+
+        /* When pause_on_track_change is calculated, next track_info may be missing
+         * (due to a low buffer or an automatic directory change),
+         * so we need to recalculate it. */
+        if (pause_on_track_change || single_mode_do_pause(info.id3_hid))
+        {
+            play_status = PLAY_PAUSED;
+            pcmbuf_pause(true);
+            pause_on_track_change = false;
+        }
     }
     /* Sync the next track information */
     have_info = track_list_current(1, &info);
@@ -2810,11 +2820,16 @@ static void audio_monitor_end_of_playlist(void)
 }
 
 /* Does this track have an entry allocated? */
-static bool audio_can_change_track(int *trackstat, int *id3_hid)
+static bool audio_can_change_track(int *trackstat, enum pcm_track_change_type *type)
 {
     struct track_info info;
     bool have_track = track_list_advance_current(1, &info);
-    *id3_hid = info.id3_hid;
+
+    pause_on_track_change = have_track && single_mode_do_pause(info.id3_hid);
+    *type = pause_on_track_change
+                ? TRACK_CHANGE_END_OF_DATA
+                : TRACK_CHANGE_AUTO;
+
     if (!have_track || info.audio_hid < 0)
     {
         bool end_of_playlist = false;
@@ -2823,8 +2838,8 @@ static bool audio_can_change_track(int *trackstat, int *id3_hid)
         {
             if (filling == STATE_STOPPED)
             {
-                audio_begin_track_change(TRACK_CHANGE_END_OF_DATA, *trackstat);
-                return false;
+                *type = TRACK_CHANGE_END_OF_DATA;
+                return true;
             }
 
             /* Track load is not complete - it might have stopped on a
@@ -2926,14 +2941,10 @@ static void audio_on_codec_complete(int status)
     track_event_flags = TEF_AUTO_SKIP;
     skip_pending = TRACK_SKIP_AUTO;
 
-    int id3_hid = 0;
-    if (audio_can_change_track(&trackstat, &id3_hid))
+    enum pcm_track_change_type type;
+    if (audio_can_change_track(&trackstat, &type))
     {
-        pause_on_track_change = single_mode_do_pause(id3_hid);
-        audio_begin_track_change(
-                pause_on_track_change
-                ? TRACK_CHANGE_END_OF_DATA
-                : TRACK_CHANGE_AUTO, trackstat);
+        audio_begin_track_change(type, trackstat);
     }
 }
 
@@ -2950,12 +2961,6 @@ static void audio_on_codec_seek_complete(void)
    (Q_AUDIO_TRACK_CHANGED) */
 static void audio_on_track_changed(void)
 {
-    if (pause_on_track_change)
-    {
-        play_status = PLAY_PAUSED;
-        pause_on_track_change = false;
-    }
-
     /* Finish whatever is pending so that the WPS is in sync */
     audio_finalise_track_change();
 
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.