summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorroman.artiukhin <bahusdrive@gmail.com>2023-03-26 12:12:52 +0300
committerAidan MacDonald <amachronic@protonmail.com>2023-10-22 08:21:22 -0400
commit4fb37ecbc692fdbb2e46aeaccf411caf631f9699 (patch)
treef08d9d8c842b4cfff395927cecdd4951f1316ab5 /apps
parent5c36643132a044dcc656dc0eae895e145bd932d0 (diff)
downloadrockbox-4fb37ecbc692fdbb2e46aeaccf411caf631f9699.tar.gz
rockbox-4fb37ecbc692fdbb2e46aeaccf411caf631f9699.zip
Skip Length across tracks
Allows to use Prev button to skip length from the end of previous track. Can be enabled with: Settings -> Playback Settings -> Skip Length set to some time interval and Settings -> Playback Settings -> Rewind Across Tracks set to Yes Change-Id: I99f234035a8a5acc9cbfe05ea83971ec5ddc59ea
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/wps.c14
-rw-r--r--apps/playback.c41
2 files changed, 43 insertions, 12 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 10c971fcc4..2a595f74e6 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -464,7 +464,21 @@ static void play_hop(int direction)
464 if (direction > 0) 464 if (direction > 0)
465 next_track(); 465 next_track();
466 else if (direction < 0) 466 else if (direction < 0)
467 {
468 if (step > 0 && global_settings.rewind_across_tracks && elapsed < DEFAULT_SKIP_THRESH && playlist_check(-1))
469 {
470 bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
471 if (!audio_paused)
472 audio_pause();
473 audio_prev();
474 audio_ff_rewind(-step);
475 if (!audio_paused)
476 audio_resume();
477 return;
478 }
479
467 prev_track(DEFAULT_SKIP_THRESH); 480 prev_track(DEFAULT_SKIP_THRESH);
481 }
468 return; 482 return;
469 } 483 }
470 else if (direction == 1 && step >= remaining) 484 else if (direction == 1 && step >= remaining)
diff --git a/apps/playback.c b/apps/playback.c
index 9d5a6569ae..18a3bad5b7 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -123,6 +123,9 @@ static enum audio_buffer_state
123/** Main state control **/ 123/** Main state control **/
124static bool ff_rw_mode SHAREDBSS_ATTR = false; /* Pre-ff-rewind mode (A,O-) */ 124static bool ff_rw_mode SHAREDBSS_ATTR = false; /* Pre-ff-rewind mode (A,O-) */
125 125
126static long seek_on_finish_load_time = 0;
127static int seek_on_finish_load_id3_hid = 0;
128
126static enum play_status 129static enum play_status
127{ 130{
128 PLAY_STOPPED = 0, 131 PLAY_STOPPED = 0,
@@ -1590,8 +1593,16 @@ static bool audio_start_codec(bool auto_skip)
1590 return false; 1593 return false;
1591 } 1594 }
1592 1595
1596 bool delayed_seek = false;
1597 if (info.id3_hid == seek_on_finish_load_id3_hid)
1598 {
1599 cur_id3->elapsed = seek_on_finish_load_time;
1600 cur_id3->offset = 0;
1601 delayed_seek = true;
1602 }
1603
1593#ifdef HAVE_TAGCACHE 1604#ifdef HAVE_TAGCACHE
1594 bool autoresume_enable = global_settings.autoresume_enable; 1605 bool autoresume_enable = !delayed_seek && global_settings.autoresume_enable;
1595 1606
1596 if (autoresume_enable && !(cur_id3->elapsed || cur_id3->offset)) 1607 if (autoresume_enable && !(cur_id3->elapsed || cur_id3->offset))
1597 { 1608 {
@@ -1641,8 +1652,8 @@ static bool audio_start_codec(bool auto_skip)
1641 and back again will cause accumulation of silent rewinds - that's not 1652 and back again will cause accumulation of silent rewinds - that's not
1642 our job to track directly nor could it be in any reasonable way 1653 our job to track directly nor could it be in any reasonable way
1643 */ 1654 */
1644 resume_rewind_adjust_progress(cur_id3, &cur_id3->elapsed, 1655 if (!delayed_seek)
1645 &cur_id3->offset); 1656 resume_rewind_adjust_progress(cur_id3, &cur_id3->elapsed, &cur_id3->offset);
1646 1657
1647 /* Update the codec API with the metadata and track info */ 1658 /* Update the codec API with the metadata and track info */
1648 id3_write(CODEC_ID3, cur_id3); 1659 id3_write(CODEC_ID3, cur_id3);
@@ -2429,6 +2440,9 @@ static void audio_on_finish_load_track(int id3_hid)
2429 { 2440 {
2430 audio_handle_track_load_status(LOAD_TRACK_ERR_START_CODEC); 2441 audio_handle_track_load_status(LOAD_TRACK_ERR_START_CODEC);
2431 } 2442 }
2443
2444 seek_on_finish_load_time = 0;
2445 seek_on_finish_load_id3_hid = 0;
2432} 2446}
2433 2447
2434/* Called when handles other than metadata handles have finished buffering 2448/* Called when handles other than metadata handles have finished buffering
@@ -3161,6 +3175,12 @@ static void audio_on_ff_rewind(long time)
3161 3175
3162 track_event_flags = TEF_NONE; 3176 track_event_flags = TEF_NONE;
3163 3177
3178 if (time < 0)
3179 {
3180 time = id3->length + time;
3181 if (time < 0)
3182 time = 0;
3183 }
3164 /* Send event before clobbering the time if rewinding. */ 3184 /* Send event before clobbering the time if rewinding. */
3165 if (time == 0) 3185 if (time == 0)
3166 { 3186 {
@@ -3201,18 +3221,15 @@ static void audio_on_ff_rewind(long time)
3201 /* Track must complete the loading _now_ since a codec and audio 3221 /* Track must complete the loading _now_ since a codec and audio
3202 handle are needed in order to do the seek */ 3222 handle are needed in order to do the seek */
3203 bool finish_load = cur_info.audio_hid < 0; 3223 bool finish_load = cur_info.audio_hid < 0;
3204 3224 if (finish_load)
3205 if (finish_load &&
3206 audio_finish_load_track(&cur_info) != LOAD_TRACK_READY)
3207 { 3225 {
3208 /* Call above should push any load sequence - no need for 3226 seek_on_finish_load_time = time;
3209 halt_decoding_track here if no skip was pending here because 3227 seek_on_finish_load_id3_hid = cur_info.id3_hid;
3210 there would not be a codec started if no audio handle was yet 3228 // Wait till playback thread receives finish load track event and seek then
3211 opened */ 3229 return;
3212 break;
3213 } 3230 }
3214 3231
3215 if (pending == TRACK_SKIP_AUTO || finish_load) 3232 if (pending == TRACK_SKIP_AUTO)
3216 { 3233 {
3217 if (!bufreadid3(cur_info.id3_hid, ci_id3) || 3234 if (!bufreadid3(cur_info.id3_hid, ci_id3) ||
3218 !audio_init_codec(&cur_info, ci_id3)) 3235 !audio_init_codec(&cur_info, ci_id3))