|
Rockbox mail archiveSubject: [PATCH] WPS modification[PATCH] WPS modification
From: Brian King <brking_at_charter.net>
Date: Wed, 31 Jul 2002 21:21:54 -0500 I made a small modification to the WPS code. I usually have WPS set to display id3 info, but I have a few songs that do not have valid id3 info in them. So I made a patch that will use directory/filename to display on the screen if there are no valid id3 tags. I also modified the directory parsing code so that both Genre/Artist/Album/Mp3_file and Artist/Album/Mp3_file directory formats should work and display the proper artist/title. This patch will only affect the Jukebox, but I'm sure it would be easy enough to add to it to give the recorder the same behavior. -bk Index: wps.c =================================================================== RCS file: /cvsroot/rockbox/apps/wps.c,v retrieving revision 1.44 diff -u -r1.44 wps.c --- wps.c 29 Jul 2002 09:08:38 -0000 1.44 +++ wps.c 1 Aug 2002 01:50:54 -0000 _at__at_ -47,6 +47,49 _at__at_ #define RELEASE_MASK (BUTTON_MENU | BUTTON_STOP) #endif +static void display_track_title(struct mp3entry* id3, char *artist, char *title) +{ + char ch = '/'; + char* end; + char* szTok; + char* szDelimit; + char* szPeriod; + char szArtist[26]; + char szBuff[257]; + int i; + szBuff[sizeof(szBuff)-1] = 0; + + strncpy(szBuff, id3->path, sizeof(szBuff)); + + for (i=0, szTok = strchr(szBuff, '/'); szTok; i++) + szTok = strchr(szTok+1, '/'); + + szTok = strtok_r(szBuff, "/", &end); + + if (i > 3) + szTok = strtok_r(NULL, "/", &end); + + // Assume path format of: Genre/Artist/Album/Mp3_file + strncpy(szArtist,szTok,sizeof(szArtist)); + szArtist[sizeof(szArtist)-1] = 0; + szDelimit = strrchr(id3->path, ch); + + if (artist) + lcd_puts(0, 0, artist); + else + lcd_puts(0,0, szArtist?szArtist:"<nothing>"); + + // removes the .mp3 from the end of the display buffer + szPeriod = strrchr(szDelimit, '.'); + if (szPeriod != NULL) + *szPeriod = 0; + + if (title) + lcd_puts_scroll(0, LINE_Y, id3->title); + else + lcd_puts_scroll(0,LINE_Y,(++szDelimit)); +} + static void draw_screen(struct mp3entry* id3) { lcd_clear_display(); _at__at_ -65,32 +108,7 _at__at_ switch ( global_settings.wps_display ) { case PLAY_DISPLAY_TRACK_TITLE: { - char ch = '/'; - char* end; - char* szTok; - char* szDelimit; - char* szPeriod; - char szArtist[26]; - char szBuff[257]; - szBuff[sizeof(szBuff)-1] = 0; - - strncpy(szBuff, id3->path, sizeof(szBuff)); - - szTok = strtok_r(szBuff, "/", &end); - szTok = strtok_r(NULL, "/", &end); - - // Assume path format of: Genre/Artist/Album/Mp3_file - strncpy(szArtist,szTok,sizeof(szArtist)); - szArtist[sizeof(szArtist)-1] = 0; - szDelimit = strrchr(id3->path, ch); - lcd_puts(0,0, szArtist?szArtist:"<nothing>"); - - // removes the .mp3 from the end of the display buffer - szPeriod = strrchr(szDelimit, '.'); - if (szPeriod != NULL) - *szPeriod = 0; - - lcd_puts_scroll(0,LINE_Y,(++szDelimit)); + display_track_title(id3, NULL, NULL); break; } case PLAY_DISPLAY_FILENAME_SCROLL: _at__at_ -126,9 +144,12 _at__at_ snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency); lcd_puts(0, l++, buffer); #else - - lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>"); - lcd_puts_scroll(0, l++, id3->title?id3->title:"<no title>"); + if (!id3->artist || !id3->title) + display_track_title(id3, id3->artist, id3->title); + else { + lcd_puts(0, l++, id3->artist); + lcd_puts_scroll(0, l++, id3->title); + } #endif break; } Received on 2002-08-01 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |