summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-07-27 14:10:48 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-07-27 14:10:48 +0000
commitf4f4111536951feed392a6869575ed80ffe87c4d (patch)
tree8fe0b78734d37939ea6a20e1e2f8a867bbb31ad4
parentde0100fafb1075286f0a7a7390eb6ce8a3fbe1a0 (diff)
downloadrockbox-f4f4111536951feed392a6869575ed80ffe87c4d.zip
rockbox-f4f4111536951feed392a6869575ed80ffe87c4d.tar.gz
rockbox-f4f4111536951feed392a6869575ed80ffe87c4d.tar.bz2
rockbox-f4f4111536951feed392a6869575ed80ffe87c4d.tar.xz
Added possibility to select the priority of the ID3 tags
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4962 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c105
-rw-r--r--apps/plugin.h113
-rw-r--r--apps/plugins/vbrfix.c2
-rw-r--r--apps/talk.c2
-rw-r--r--firmware/export/id3.h2
-rw-r--r--firmware/export/mpeg.h1
-rw-r--r--firmware/id3.c22
-rw-r--r--firmware/mpeg.c15
-rw-r--r--uisimulator/common/mpegplay.c2
9 files changed, 123 insertions, 141 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 413caf8..e5a496c 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -88,19 +88,25 @@ static const struct plugin_api rockbox_api = {
lcd_puts,
lcd_puts_scroll,
lcd_stop_scroll,
+ lcd_set_contrast,
#ifdef HAVE_LCD_CHARCELLS
lcd_define_pattern,
lcd_get_locked_pattern,
lcd_unlock_pattern,
lcd_putc,
+ lcd_put_cursor,
+ lcd_remove_cursor,
+ lcd_icon,
#else
lcd_putsxy,
+ lcd_puts_style,
lcd_bitmap,
lcd_drawline,
lcd_clearline,
lcd_drawpixel,
lcd_clearpixel,
lcd_setfont,
+ font_get,
lcd_clearrect,
lcd_fillrect,
lcd_drawrect,
@@ -109,14 +115,21 @@ static const struct plugin_api rockbox_api = {
lcd_update,
lcd_update_rect,
scrollbar,
+ checkbox,
+ &lcd_framebuffer[0][0],
+ lcd_blit,
#ifndef SIMULATOR
lcd_roll,
#endif
#endif
+ backlight_on,
+ backlight_off,
/* button */
button_get,
button_get_w_tmo,
+ button_status,
+ button_clear_queue,
/* file */
(open_func)PREFIX(open),
@@ -131,6 +144,7 @@ static const struct plugin_api rockbox_api = {
PREFIX(filesize),
fprintf,
read_line,
+ settings_parseline,
/* dir */
PREFIX(opendir),
@@ -139,14 +153,21 @@ static const struct plugin_api rockbox_api = {
/* kernel */
PREFIX(sleep),
+ yield,
usb_screen,
&current_tick,
+ default_event_handler,
+ create_thread,
+ remove_thread,
/* strings and memory */
snprintf,
strcpy,
+ strncpy,
strlen,
strrchr,
+ strcmp,
+ strcasecmp,
memset,
memcpy,
#ifndef SIMULATOR
@@ -154,12 +175,31 @@ static const struct plugin_api rockbox_api = {
#endif
/* sound */
+ mpeg_sound_set,
#ifndef SIMULATOR
+ mp3_play_data,
+ mp3_play_pause,
+ mp3_play_stop,
+ mp3_is_playing,
+ bitswap,
#ifdef HAVE_MAS3587F
mas_codec_readreg,
#endif
#endif
+ /* playback control */
+ mpeg_play,
+ mpeg_stop,
+ mpeg_pause,
+ mpeg_resume,
+ mpeg_next,
+ mpeg_prev,
+ mpeg_ff_rewind,
+ mpeg_next_track,
+ playlist_amount,
+ mpeg_status,
+ mpeg_has_changed_track,
+
/* misc */
srand,
rand,
@@ -170,54 +210,21 @@ static const struct plugin_api rockbox_api = {
atoi,
get_time,
plugin_get_buffer,
+ plugin_get_mp3_buffer,
+#ifndef SIMULATOR
+ plugin_register_timer,
+ plugin_unregister_timer,
+#endif
+ plugin_tsr,
/* new stuff at the end, sort into place next time the API gets incompatible */
-#ifndef HAVE_LCD_CHARCELLS
- &lcd_framebuffer[0][0],
- lcd_blit,
-#endif
- yield,
- plugin_get_mp3_buffer,
- mpeg_sound_set,
-#ifndef SIMULATOR
- mp3_play_data,
- mp3_play_pause,
- mp3_play_stop,
- mp3_is_playing,
- bitswap,
-#endif
&global_settings,
backlight_set_timeout,
#ifndef SIMULATOR
ata_sleep,
#endif
-#ifdef HAVE_LCD_BITMAP
- checkbox,
-#endif
-#ifndef SIMULATOR
- plugin_register_timer,
- plugin_unregister_timer,
-#endif
- plugin_tsr,
- create_thread,
- remove_thread,
- lcd_set_contrast,
- mpeg_play,
- mpeg_stop,
- mpeg_pause,
- mpeg_resume,
- mpeg_next,
- mpeg_prev,
- mpeg_ff_rewind,
- mpeg_next_track,
- playlist_amount,
- mpeg_status,
- mpeg_has_changed_track,
-#ifdef HAVE_LCD_BITMAP
- font_get,
-#endif
#if defined(DEBUG) || defined(SIMULATOR)
debugf,
#endif
@@ -238,26 +245,6 @@ static const struct plugin_api rockbox_api = {
set_time,
reset_poweroff_timer,
- backlight_on,
- backlight_off,
-
-#ifdef HAVE_LCD_CHARCELLS
- lcd_icon,
-#endif
-#ifdef HAVE_LCD_BITMAP
- lcd_puts_style,
-#endif
-#ifdef HAVE_LCD_CHARCELLS
- lcd_put_cursor,
- lcd_remove_cursor,
-#endif
- settings_parseline,
- strcmp,
- button_status,
- button_clear_queue,
- strncpy,
- strcasecmp,
- default_event_handler
};
int plugin_load(char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 7470087..51607a5 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -60,12 +60,12 @@
#endif
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 24
+#define PLUGIN_API_VERSION 25
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 19
+#define PLUGIN_MIN_API_VERSION 25
/* plugin return codes */
enum plugin_status {
@@ -114,13 +114,18 @@ struct plugin_api {
void (*lcd_puts)(int x, int y, unsigned char *string);
void (*lcd_puts_scroll)(int x, int y, unsigned char* string);
void (*lcd_stop_scroll)(void);
+ void (*lcd_set_contrast)(int x);
#ifdef HAVE_LCD_CHARCELLS
void (*lcd_define_pattern)(int which,char *pattern);
unsigned char (*lcd_get_locked_pattern)(void);
void (*lcd_unlock_pattern)(unsigned char pat);
void (*lcd_putc)(int x, int y, unsigned short ch);
+ void (*lcd_put_cursor)(int x, int y, char cursor_char);
+ void (*lcd_remove_cursor)(void);
+ void (*lcd_icon)(int icon, bool enable);
#else
void (*lcd_putsxy)(int x, int y, const unsigned char *string);
+ void (*lcd_puts_style)(int x, int y, unsigned char *str, int style);
void (*lcd_bitmap)(const unsigned char *src, int x, int y,
int nx, int ny, bool clear);
void (*lcd_drawline)(int x1, int y1, int x2, int y2);
@@ -128,6 +133,7 @@ struct plugin_api {
void (*lcd_drawpixel)(int x, int y);
void (*lcd_clearpixel)(int x, int y);
void (*lcd_setfont)(int font);
+ struct font* (*font_get)(int font);
void (*lcd_clearrect)(int x, int y, int nx, int ny);
void (*lcd_fillrect)(int x, int y, int nx, int ny);
void (*lcd_drawrect)(int x, int y, int nx, int ny);
@@ -137,14 +143,21 @@ struct plugin_api {
void (*lcd_update_rect)(int x, int y, int width, int height);
void (*scrollbar)(int x, int y, int width, int height, int items,
int min_shown, int max_shown, int orientation);
+ void (*checkbox)(int x, int y, int width, int height, bool checked);
+ unsigned char* lcd_framebuffer;
+ void (*lcd_blit) (unsigned char* p_data, int x, int y, int width, int height, int stride);
#ifndef SIMULATOR
void (*lcd_roll)(int pixels);
#endif
#endif
+ void (*backlight_on)(void);
+ void (*backlight_off)(void);
/* button */
int (*button_get)(bool block);
int (*button_get_w_tmo)(int ticks);
+ int (*button_status)(void);
+ void (*button_clear_queue)(void);
/* file */
int (*open)(const char* pathname, int flags);
@@ -159,6 +172,7 @@ struct plugin_api {
int (*filesize)(int fd);
int (*fprintf)(int fd, const char *fmt, ...);
int (*read_line)(int fd, char* buffer, int buffer_size);
+ bool (*settings_parseline)(char* line, char** name, char** value);
/* dir */
DIR* (*opendir)(const char* name);
@@ -167,14 +181,21 @@ struct plugin_api {
/* kernel */
void (*sleep)(int ticks);
+ void (*yield)(void);
void (*usb_screen)(void);
long* current_tick;
+ int (*default_event_handler)(int event);
+ int (*create_thread)(void* function, void* stack, int stack_size, char *name);
+ void (*remove_thread)(int threadnum);
/* strings and memory */
int (*snprintf)(char *buf, size_t size, const char *fmt, ...);
char* (*strcpy)(char *dst, const char *src);
+ char *(*strncpy)(char *dst, const char *src, size_t length);
size_t (*strlen)(const char *str);
char * (*strrchr)(const char *s, int c);
+ int (*strcmp)(const char *, const char *);
+ int (*strcasecmp)(const char *, const char *);
void* (*memset)(void *dst, int c, size_t length);
void* (*memcpy)(void *out, const void *in, size_t n);
#ifndef SIMULATOR
@@ -182,12 +203,31 @@ struct plugin_api {
#endif
/* sound */
+ void (*mpeg_sound_set)(int setting, int value);
#ifndef SIMULATOR
+ void (*mp3_play_data)(unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size));
+ void (*mp3_play_pause)(bool play);
+ void (*mp3_play_stop)(void);
+ bool (*mp3_is_playing)(void);
+ void (*bitswap)(unsigned char *data, int length);
#ifdef HAVE_MAS3587F
int (*mas_codec_readreg)(int reg);
#endif
#endif
+ /* playback control */
+ void (*mpeg_play)(int offset);
+ void (*mpeg_stop)(void);
+ void (*mpeg_pause)(void);
+ void (*mpeg_resume)(void);
+ void (*mpeg_next)(void);
+ void (*mpeg_prev)(void);
+ void (*mpeg_ff_rewind)(int newtime);
+ struct mp3entry* (*mpeg_next_track)(void);
+ int (*playlist_amount)(void);
+ int (*mpeg_status)(void);
+ bool (*mpeg_has_changed_track)(void);
+
/* misc */
void (*srand)(unsigned int seed);
int (*rand)(void);
@@ -199,61 +239,26 @@ struct plugin_api {
int (*atoi)(const char *str);
struct tm* (*get_time)(void);
void* (*plugin_get_buffer)(int* buffer_size);
-
- /* new stuff, sort in next time the API gets broken! */
-#ifndef HAVE_LCD_CHARCELLS
- unsigned char* lcd_framebuffer;
- void (*lcd_blit) (unsigned char* p_data, int x, int y, int width, int height, int stride);
-#endif
- void (*yield)(void);
-
void* (*plugin_get_mp3_buffer)(int* buffer_size);
- void (*mpeg_sound_set)(int setting, int value);
#ifndef SIMULATOR
- void (*mp3_play_data)(unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size));
- void (*mp3_play_pause)(bool play);
- void (*mp3_play_stop)(void);
- bool (*mp3_is_playing)(void);
- void (*bitswap)(unsigned char *data, int length);
+ int (*plugin_register_timer)(int cycles, int prio, void (*timer_callback)(void));
+ void (*plugin_unregister_timer)(void);
#endif
+ void (*plugin_tsr)(void (*exit_callback)(void));
+
+ /* new stuff, sort in next time the API gets broken! */
+
struct user_settings* global_settings;
void (*backlight_set_timeout)(int index);
#ifndef SIMULATOR
int (*ata_sleep)(void);
#endif
-#ifdef HAVE_LCD_BITMAP
- void (*checkbox)(int x, int y, int width, int height, bool checked);
-#endif
-#ifndef SIMULATOR
- int (*plugin_register_timer)(int cycles, int prio, void (*timer_callback)(void));
- void (*plugin_unregister_timer)(void);
-#endif
- void (*plugin_tsr)(void (*exit_callback)(void));
- int (*create_thread)(void* function, void* stack, int stack_size, char *name);
- void (*remove_thread)(int threadnum);
- void (*lcd_set_contrast)(int x);
- /* playback control */
- void (*mpeg_play)(int offset);
- void (*mpeg_stop)(void);
- void (*mpeg_pause)(void);
- void (*mpeg_resume)(void);
- void (*mpeg_next)(void);
- void (*mpeg_prev)(void);
- void (*mpeg_ff_rewind)(int newtime);
- struct mp3entry* (*mpeg_next_track)(void);
- int (*playlist_amount)(void);
- int (*mpeg_status)(void);
- bool (*mpeg_has_changed_track)(void);
-
-#ifdef HAVE_LCD_BITMAP
- struct font* (*font_get)(int font);
-#endif
#if defined(DEBUG) || defined(SIMULATOR)
void (*debugf)(char *fmt, ...);
#endif
- bool (*mp3info)(struct mp3entry *entry, char *filename) ;
+ bool (*mp3info)(struct mp3entry *entry, char *filename, bool v1first);
int (*count_mp3_frames)(int fd, int startpos, int filesize,
void (*progressfunc)(int));
int (*create_xing_header)(int fd, int startpos, int filesize,
@@ -274,26 +279,6 @@ struct plugin_api {
int (*set_time)(struct tm *tm);
void (*reset_poweroff_timer)(void);
- void (*backlight_on)(void);
- void (*backlight_off)(void);
-
-#ifdef HAVE_LCD_CHARCELLS
- void (*lcd_icon)(int icon, bool enable);
-#endif
-#ifdef HAVE_LCD_BITMAP
- void (*lcd_puts_style)(int x, int y, unsigned char *str, int style);
-#endif
-#ifdef HAVE_LCD_CHARCELLS
- void (*lcd_put_cursor)(int x, int y, char cursor_char);
- void (*lcd_remove_cursor)(void);
-#endif
- bool (*settings_parseline)(char* line, char** name, char** value);
- int (*strcmp)(const char *, const char *);
- int (*button_status)(void);
- void (*button_clear_queue)(void);
- char *(*strncpy)(char *dst, const char *src, size_t length);
- int (*strcasecmp)(const char *, const char *);
- int (*default_event_handler)(int event);
};
/* defined by the plugin loader (plugin.c) */
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index 1beca26..0077340 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -145,7 +145,7 @@ static bool vbr_fix(char *selected_file)
xingupdate(0);
- rc = rb->mp3info(&entry, selected_file);
+ rc = rb->mp3info(&entry, selected_file, false);
if(rc < 0) {
fileerror(rc);
return true;
diff --git a/apps/talk.c b/apps/talk.c
index 462ab85..51e8ae7 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -390,7 +390,7 @@ int talk_file(char* filename, bool enqueue)
if (p_thumbnail == NULL || size_for_thumbnail <= 0)
return -1;
- if(mp3info(&info, filename)) /* use this to find real start */
+ if(mp3info(&info, filename, false)) /* use this to find real start */
{
return 0; /* failed to open, or invalid */
}
diff --git a/firmware/export/id3.h b/firmware/export/id3.h
index 6e53e4c..10f8002 100644
--- a/firmware/export/id3.h
+++ b/firmware/export/id3.h
@@ -74,7 +74,7 @@ enum {
ID3_VER_2_4
};
-bool mp3info(struct mp3entry *entry, char *filename);
+bool mp3info(struct mp3entry *entry, char *filename, bool v1first);
char* id3_get_genre(struct mp3entry* id3);
#endif
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
index 252e509..51932c5 100644
--- a/firmware/export/mpeg.h
+++ b/firmware/export/mpeg.h
@@ -96,6 +96,7 @@ void mpeg_error_clear(void);
/* in order to keep the recording here, I have to expose this */
void rec_tick(void);
void playback_tick(void); /* FixMe: get rid of this, use mp3_get_playtime() */
+void mpeg_id3_options(bool _v1first);
#define MPEG_STATUS_PLAY 1
#define MPEG_STATUS_PAUSE 2
diff --git a/firmware/id3.c b/firmware/id3.c
index 70add41..03c37c0 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -798,13 +798,12 @@ static int getsonglength(int fd, struct mp3entry *entry)
* Checks all relevant information (such as ID3v1 tag, ID3v2 tag, length etc)
* about an MP3 file and updates it's entry accordingly.
*
- * Arguments: entry - the entry to check and update with the new information
- *
- * Returns: void
*/
-bool mp3info(struct mp3entry *entry, char *filename)
+bool mp3info(struct mp3entry *entry, char *filename, bool v1first)
{
int fd;
+ int v1found = false;
+
fd = open(filename, O_RDONLY);
if(-1 == fd)
return true;
@@ -819,7 +818,10 @@ bool mp3info(struct mp3entry *entry, char *filename)
entry->tracknum = 0;
entry->genre = 0xff;
- if (entry->id3v2len)
+ if(v1first)
+ v1found = setid3v1title(fd, entry);
+
+ if (!v1found && entry->id3v2len)
setid3v2title(fd, entry);
entry->length = getsonglength(fd, entry);
@@ -827,10 +829,10 @@ bool mp3info(struct mp3entry *entry, char *filename)
the true size of the MP3 stream */
entry->filesize -= entry->first_frame_offset;
- /* only seek to end of file if no id3v2 tags were found */
- if (!entry->id3v2len) {
- if(!entry->title)
- setid3v1title(fd, entry);
+ /* only seek to end of file if no id3v2 tags were found,
+ and we already haven't looked for a v1 tag */
+ if (!v1first && !entry->id3v2len) {
+ setid3v1title(fd, entry);
}
close(fd);
@@ -860,7 +862,7 @@ int main(int argc, char **argv)
for(i=1; i<argc; i++) {
struct mp3entry mp3;
mp3.album = "Bogus";
- if(mp3info(&mp3, argv[i])) {
+ if(mp3info(&mp3, argv[i], false)) {
printf("Failed to get %s\n", argv[i]);
return 0;
}
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 8f0612c..a54866e 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -107,6 +107,8 @@ struct id3tag
static struct id3tag *id3tags[MAX_ID3_TAGS];
static struct id3tag _id3tags[MAX_ID3_TAGS];
+static bool v1first = false;
+
static unsigned int current_track_counter = 0;
static unsigned int last_track_counter = 0;
@@ -736,7 +738,7 @@ static int add_track_to_tag_list(char *filename)
{
/* grab id3 tag of new file and
remember where in memory it starts */
- if(mp3info(&(t->id3), filename))
+ if(mp3info(&(t->id3), filename, v1first))
{
DEBUGF("Bad mp3\n");
return -1;
@@ -1985,6 +1987,11 @@ static void mpeg_thread(void)
static struct mp3entry taginfo;
#endif /* #ifdef SIMULATOR */
+void mpeg_id3_options(bool _v1first)
+{
+ v1first = _v1first;
+}
+
struct mp3entry* mpeg_current_track()
{
#ifdef SIMULATOR
@@ -2443,7 +2450,7 @@ void mpeg_play(int offset)
trackname = playlist_peek( steps );
if (!trackname)
break;
- if(mp3info(&taginfo, trackname)) {
+ if(mp3info(&taginfo, trackname, v1first)) {
/* bad mp3, move on */
if(++steps > playlist_amount())
break;
@@ -2518,7 +2525,7 @@ void mpeg_next(void)
file = playlist_peek(steps);
if(!file)
break;
- if(mp3info(&taginfo, file)) {
+ if(mp3info(&taginfo, file, v1first)) {
if(++steps > playlist_amount())
break;
continue;
@@ -2546,7 +2553,7 @@ void mpeg_prev(void)
file = playlist_peek(steps);
if(!file)
break;
- if(mp3info(&taginfo, file)) {
+ if(mp3info(&taginfo, file, v1first)) {
steps--;
continue;
}
diff --git a/uisimulator/common/mpegplay.c b/uisimulator/common/mpegplay.c
index c7e2552..fa1333b 100644
--- a/uisimulator/common/mpegplay.c
+++ b/uisimulator/common/mpegplay.c
@@ -133,7 +133,7 @@ void real_mpeg_play(char* fname)
static struct dither d0, d1;
int key=0;
- mp3info(&mp3, fname);
+ mp3info(&mp3, fname, false); /* FIXME: honor the v1first setting */
init_sound(&sound);