summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-02-14 14:40:24 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-02-14 14:40:24 +0000
commit9f4bd8712fc122f61ec162c544d613a95c3ca66e (patch)
tree4e652a1e7c19ac8a6bb789ee79304744c133d029 /apps/gui
parent0403c2a572154667f3f2bd671d7d5a7cc08c64af (diff)
downloadrockbox-9f4bd8712fc122f61ec162c544d613a95c3ca66e.zip
rockbox-9f4bd8712fc122f61ec162c544d613a95c3ca66e.tar.gz
rockbox-9f4bd8712fc122f61ec162c544d613a95c3ca66e.tar.bz2
rockbox-9f4bd8712fc122f61ec162c544d613a95c3ca66e.tar.xz
Cuesheet support by Jonathan Gordon and me (FS #6460).
Everytime an audio file is loaded, a cue file with the same name is searched for. A setting allows to disable this (default is off). Cuesheet files can also be viewed in the file browser. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12304 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps-common.c64
-rw-r--r--apps/gui/gwps.c48
2 files changed, 108 insertions, 4 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 53b1223..b6e64d2 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -53,6 +53,7 @@
#endif
#include "dsp.h"
#include "action.h"
+#include "cuesheet.h"
#ifdef HAVE_LCD_CHARCELLS
static bool draw_player_progress(struct gui_wps *gwps);
@@ -1850,6 +1851,14 @@ bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset,
data->progress_start, data->progress_end, sb_y,
data->progress_height);
#endif
+
+ if (cuesheet_is_enabled() && state->id3->cuesheet_type)
+ {
+ cue_draw_markers(display, state->id3->length,
+ data->progress_start, data->progress_end,
+ sb_y+1, data->progress_height-2);
+ }
+
update_line = true;
}
if (flags & refresh_mode & WPS_REFRESH_PEAK_METER) {
@@ -2561,6 +2570,35 @@ bool update(struct gui_wps *gwps)
{
gwps->display->stop_scroll();
gwps->state->id3 = audio_current_track();
+
+ if (cuesheet_is_enabled() && gwps->state->id3->cuesheet_type
+ && strcmp(gwps->state->id3->path, curr_cue->audio_filename))
+ {
+ /* the current cuesheet isn't the right one any more */
+
+ if (!strcmp(gwps->state->id3->path, temp_cue->audio_filename)) {
+ /* We have the new cuesheet in memory (temp_cue),
+ let's make it the current one ! */
+ memcpy(curr_cue, temp_cue, sizeof(struct cuesheet));
+ }
+ else {
+ /* We need to parse the new cuesheet */
+
+ char cuepath[MAX_PATH];
+ strncpy(cuepath, gwps->state->id3->path, MAX_PATH);
+ char *dot = strrchr(cuepath, '.');
+ strcpy(dot, ".cue");
+
+ if (parse_cuesheet(cuepath, curr_cue))
+ {
+ gwps->state->id3->cuesheet_type = 1;
+ strcpy(curr_cue->audio_filename, gwps->state->id3->path);
+ }
+ }
+
+ cue_spoof_id3(curr_cue, gwps->state->id3);
+ }
+
if (gui_wps_display())
retcode = true;
else{
@@ -2572,12 +2610,34 @@ bool update(struct gui_wps *gwps)
sizeof(gwps->state->current_track_path));
}
+ if (cuesheet_is_enabled() && gwps->state->id3->cuesheet_type
+ && (gwps->state->id3->elapsed < curr_cue->curr_track->offset
+ || (curr_cue->curr_track_idx < curr_cue->track_count - 1
+ && gwps->state->id3->elapsed >= (curr_cue->curr_track+1)->offset)))
+ {
+ /* We've changed tracks within the cuesheet :
+ we need to update the ID3 info and refresh the WPS */
+
+ cue_find_current_track(curr_cue, gwps->state->id3->elapsed);
+ cue_spoof_id3(curr_cue, gwps->state->id3);
+
+ gwps->display->stop_scroll();
+ if (gui_wps_display())
+ retcode = true;
+ else{
+ gui_wps_refresh(gwps, 0, WPS_REFRESH_ALL);
+ }
+ gui_wps_statusbar_draw(gwps, false);
+
+ return retcode;
+ }
+
if (gwps->state->id3)
gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC);
gui_wps_statusbar_draw(gwps, false);
-
- return retcode;
+
+ return retcode;
}
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 7128a95..00290a8 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -54,6 +54,7 @@
#include "abrepeat.h"
#include "playback.h"
#include "splash.h"
+#include "cuesheet.h"
#if LCD_DEPTH > 1
#include "backdrop.h"
#endif
@@ -333,7 +334,16 @@ long gui_wps_show(void)
if (global_settings.party_mode)
break;
if (current_tick -last_right < HZ)
- audio_next_dir();
+ {
+ if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
+ {
+ audio_next();
+ }
+ else
+ {
+ audio_next_dir();
+ }
+ }
else ffwd_rew(ACTION_WPS_SEEKFWD);
last_right = 0;
break;
@@ -343,7 +353,22 @@ long gui_wps_show(void)
if (global_settings.party_mode)
break;
if (current_tick -last_left < HZ)
- audio_prev_dir();
+ {
+ if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
+ {
+ if (!wps_state.paused)
+#if (CONFIG_CODEC == SWCODEC)
+ audio_pre_ff_rewind();
+#else
+ audio_pause();
+#endif
+ audio_ff_rewind(0);
+ }
+ else
+ {
+ audio_prev_dir();
+ }
+ }
else ffwd_rew(ACTION_WPS_SEEKBACK);
last_left = 0;
break;
@@ -377,6 +402,13 @@ long gui_wps_show(void)
audio_prev();
}
else {
+
+ if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
+ {
+ curr_cuesheet_skip(-1, wps_state.id3->elapsed);
+ break;
+ }
+
if (!wps_state.paused)
#if (CONFIG_CODEC == SWCODEC)
audio_pre_ff_rewind();
@@ -417,6 +449,18 @@ long gui_wps_show(void)
}
/* ...otherwise, do it normally */
#endif
+
+ /* take care of if we're playing a cuesheet */
+ if (cuesheet_is_enabled() && wps_state.id3->cuesheet_type)
+ {
+ if (curr_cuesheet_skip(1, wps_state.id3->elapsed))
+ {
+ /* if the result was false, then we really want
+ to skip to the next track */
+ break;
+ }
+ }
+
audio_next();
break;
/* next / prev directories */