A step towards WPS
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1184 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3f9c7c2ab5
commit
bb9aaf5065
84
apps/tree.c
84
apps/tree.c
|
@ -34,6 +34,7 @@
|
|||
#include "mpeg.h"
|
||||
#include "playlist.h"
|
||||
#include "menu.h"
|
||||
#include "wps.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
|
@ -198,31 +199,31 @@ char* peek_next_track(int type)
|
|||
return NULL;
|
||||
|
||||
switch(playing) {
|
||||
default:
|
||||
case 1:
|
||||
/* play-full-dir mode */
|
||||
default:
|
||||
case 1:
|
||||
/* play-full-dir mode */
|
||||
|
||||
/* get next track in dir */
|
||||
while (dircursor + start + 1 < numentries ) {
|
||||
if(dircursor+1 < TREE_MAX_ON_SCREEN)
|
||||
dircursor++;
|
||||
else
|
||||
start++;
|
||||
if ( dircacheptr[dircursor+start]->file &&
|
||||
dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
|
||||
snprintf(buf,sizeof buf,"%s/%s",
|
||||
currdir, dircacheptr[dircursor+start]->name );
|
||||
lcd_clear_display();
|
||||
lcd_puts(0,0,"<Playing>");
|
||||
lcd_puts(0,1,"<all files>");
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* get next track in dir */
|
||||
while (dircursor + start + 1 < numentries ) {
|
||||
if(dircursor+1 < TREE_MAX_ON_SCREEN)
|
||||
dircursor++;
|
||||
else
|
||||
start++;
|
||||
if ( dircacheptr[dircursor+start]->file &&
|
||||
dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
|
||||
snprintf(buf,sizeof buf,"%s/%s",
|
||||
currdir, dircacheptr[dircursor+start]->name );
|
||||
lcd_clear_display();
|
||||
lcd_puts(0,0,"<Playing>");
|
||||
lcd_puts(0,1,"<all files>");
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* playlist mode */
|
||||
return playlist_next(type);
|
||||
case 2:
|
||||
/* playlist mode */
|
||||
return playlist_next(type);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -246,6 +247,7 @@ bool dirbrowse(char *root)
|
|||
lcd_update();
|
||||
|
||||
while(1) {
|
||||
bool restore = false;
|
||||
button = button_get(true);
|
||||
|
||||
switch(button) {
|
||||
|
@ -267,8 +269,7 @@ bool dirbrowse(char *root)
|
|||
}
|
||||
else
|
||||
start = dircursor = 0;
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
|
||||
restore = true;
|
||||
}
|
||||
else
|
||||
mpeg_stop();
|
||||
|
@ -316,8 +317,7 @@ bool dirbrowse(char *root)
|
|||
playing = 0;
|
||||
}
|
||||
}
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
|
||||
restore = true;
|
||||
break;
|
||||
|
||||
case TREE_PREV:
|
||||
|
@ -354,20 +354,28 @@ bool dirbrowse(char *root)
|
|||
case TREE_MENU:
|
||||
lcd_stop_scroll();
|
||||
main_menu();
|
||||
|
||||
/* restore display */
|
||||
/* TODO: this is just a copy from BUTTON_STOP, fix it */
|
||||
lcd_clear_display();
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
|
||||
|
||||
restore = true;
|
||||
break;
|
||||
|
||||
case BUTTON_ON:
|
||||
wps_show();
|
||||
restore = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
lcd_stop_scroll();
|
||||
if ( numentries )
|
||||
lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
|
||||
dircacheptr[start+dircursor]->name);
|
||||
if ( restore ) {
|
||||
/* restore display */
|
||||
/* TODO: this is just a copy from BUTTON_STOP, fix it */
|
||||
numentries = showdir(currdir, start);
|
||||
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
|
||||
}
|
||||
else {
|
||||
lcd_stop_scroll();
|
||||
if ( numentries )
|
||||
lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
|
||||
dircacheptr[start+dircursor]->name);
|
||||
}
|
||||
|
||||
lcd_update();
|
||||
}
|
||||
|
|
51
apps/wps.c
51
apps/wps.c
|
@ -29,6 +29,7 @@
|
|||
#include "sprintf.h"
|
||||
#include "settings.h"
|
||||
#include "wps.h"
|
||||
#include "mpeg.h"
|
||||
|
||||
|
||||
#define LINE_Y 1 /* initial line */
|
||||
|
@ -38,11 +39,12 @@
|
|||
#define PLAY_DISPLAY_TRACK_TITLE 2
|
||||
|
||||
/* demonstrates showing different formats from playtune */
|
||||
void wps_show_play(char* filename)
|
||||
void wps_show(void)
|
||||
{
|
||||
struct mp3entry mp3;
|
||||
mp3info(&mp3,filename);
|
||||
struct mp3entry* id3 = mpeg_current_track();
|
||||
static bool playing = true;
|
||||
|
||||
lcd_clear_display();
|
||||
switch ( global_settings.wps_display ) {
|
||||
case PLAY_DISPLAY_TRACK_TITLE:
|
||||
{
|
||||
|
@ -54,7 +56,7 @@ void wps_show_play(char* filename)
|
|||
char szBuff[257];
|
||||
szBuff[sizeof(szBuff)-1] = 0;
|
||||
|
||||
strncpy(szBuff, filename, sizeof(szBuff));
|
||||
strncpy(szBuff, id3->path, sizeof(szBuff));
|
||||
|
||||
szTok = strtok_r(szBuff, "/", &end);
|
||||
szTok = strtok_r(NULL, "/", &end);
|
||||
|
@ -62,7 +64,7 @@ void wps_show_play(char* filename)
|
|||
// Assume path format of: Genre/Artist/Album/Mp3_file
|
||||
strncpy(szArtist,szTok,sizeof(szArtist));
|
||||
szArtist[sizeof(szArtist)-1] = 0;
|
||||
szDelimit = strrchr(filename, ch);
|
||||
szDelimit = strrchr(id3->path, ch);
|
||||
lcd_puts(0,0, szArtist?szArtist:"<nothing>");
|
||||
lcd_puts_scroll(0,LINE_Y,(++szDelimit));
|
||||
break;
|
||||
|
@ -70,12 +72,12 @@ void wps_show_play(char* filename)
|
|||
case PLAY_DISPLAY_FILENAME_SCROLL:
|
||||
{
|
||||
char ch = '/';
|
||||
char* szLast = strrchr(filename, ch);
|
||||
char* szLast = strrchr(id3->path, ch);
|
||||
|
||||
if (szLast)
|
||||
lcd_puts_scroll(0,0, (++szLast));
|
||||
else
|
||||
lcd_puts_scroll(0,0, mp3.path);
|
||||
lcd_puts_scroll(0,0, id3->path);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -85,27 +87,46 @@ void wps_show_play(char* filename)
|
|||
char buffer[256];
|
||||
|
||||
lcd_puts(0, 0, "[id3 info]");
|
||||
lcd_puts(0, LINE_Y, mp3.title?mp3.title:"");
|
||||
lcd_puts(0, LINE_Y+1, mp3.album?mp3.album:"");
|
||||
lcd_puts(0, LINE_Y+2, mp3.artist?mp3.artist:"");
|
||||
lcd_puts(0, LINE_Y, id3->title?id3->title:"");
|
||||
lcd_puts(0, LINE_Y+1, id3->album?id3->album:"");
|
||||
lcd_puts(0, LINE_Y+2, id3->artist?id3->artist:"");
|
||||
|
||||
snprintf(buffer,sizeof(buffer), "%d ms", mp3.length);
|
||||
snprintf(buffer,sizeof(buffer), "%d ms", id3->length);
|
||||
lcd_puts(0, LINE_Y+3, buffer);
|
||||
|
||||
snprintf(buffer,sizeof(buffer), "%d kbits", mp3.bitrate);
|
||||
snprintf(buffer,sizeof(buffer), "%d kbits", id3->bitrate);
|
||||
|
||||
lcd_puts(0, LINE_Y+4, buffer);
|
||||
|
||||
snprintf(buffer,sizeof(buffer), "%d Hz", mp3.frequency);
|
||||
snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency);
|
||||
lcd_puts(0, LINE_Y+5, buffer);
|
||||
#else
|
||||
|
||||
lcd_puts(0, 0, mp3.artist?mp3.artist:"<no artist>");
|
||||
lcd_puts(0, 1, mp3.title?mp3.title:"<no title>");
|
||||
lcd_puts(0, 0, id3->artist?id3->artist:"<no artist>");
|
||||
lcd_puts(0, 1, id3->title?id3->title:"<no title>");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
lcd_update();
|
||||
while ( 1 ) {
|
||||
switch ( button_get(true) ) {
|
||||
case BUTTON_ON:
|
||||
return;
|
||||
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
case BUTTON_PLAY:
|
||||
#else
|
||||
case BUTTON_UP:
|
||||
#endif
|
||||
if ( playing )
|
||||
mpeg_pause();
|
||||
else
|
||||
mpeg_resume();
|
||||
|
||||
playing = !playing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "id3.h"
|
||||
#include "playlist.h"
|
||||
|
||||
void wps_show_play(char* filename);
|
||||
void wps_show(void);
|
||||
//void wps_show_playlist(char* current, playlist_info_t *list);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "panic.h"
|
||||
#include "file.h"
|
||||
#include "settings.h"
|
||||
#include "id3.h"
|
||||
|
||||
#define MPEG_STACK_SIZE 0x2000
|
||||
#define MPEG_CHUNKSIZE 0x20000
|
||||
|
@ -141,6 +142,14 @@ static bool filling; /* We are filling the buffer with data from disk */
|
|||
|
||||
static int mpeg_file;
|
||||
|
||||
/* list of tracks in memory */
|
||||
#define MAX_ID3_TAGS 4
|
||||
static struct {
|
||||
struct mp3entry id3;
|
||||
int mempos;
|
||||
} id3tags[MAX_ID3_TAGS];
|
||||
static int last_tag = 0;
|
||||
|
||||
static void create_fliptable(void)
|
||||
{
|
||||
int i;
|
||||
|
@ -271,6 +280,16 @@ void DEI3(void)
|
|||
last_dma_chunk_size = MIN(last_dma_chunk_size, space_until_end_of_buffer);
|
||||
DTCR3 = last_dma_chunk_size & 0xffff;
|
||||
SAR3 = (unsigned int)mp3buf + mp3buf_read;
|
||||
|
||||
/* will we move across the track boundary? */
|
||||
if (( mp3buf_read <= id3tags[0].mempos ) &&
|
||||
( mp3buf_read + last_dma_chunk_size > id3tags[0].mempos )) {
|
||||
/* shift array so index 0 is current track */
|
||||
int i;
|
||||
for (i=0; i<MAX_ID3_TAGS-1; i++)
|
||||
id3tags[i] = id3tags[i+1];
|
||||
last_tag--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -297,7 +316,15 @@ static int new_file(void)
|
|||
if ( !trackname )
|
||||
return -1;
|
||||
|
||||
debugf("playing %s\n", trackname);
|
||||
DEBUGF("playing %s\n", trackname);
|
||||
|
||||
/* grab id3 tag of new file and remember where in memory it starts */
|
||||
if ( last_tag < MAX_ID3_TAGS ) {
|
||||
mp3info(&(id3tags[last_tag].id3), trackname);
|
||||
id3tags[last_tag].mempos = mp3buf_write;
|
||||
last_tag++;
|
||||
}
|
||||
|
||||
mpeg_file = open(trackname, O_RDONLY);
|
||||
if(mpeg_file < 0)
|
||||
{
|
||||
|
@ -307,6 +334,11 @@ static int new_file(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct mp3entry* mpeg_current_track(void)
|
||||
{
|
||||
return &(id3tags[0].id3);
|
||||
}
|
||||
|
||||
static void mpeg_thread(void)
|
||||
{
|
||||
struct event ev;
|
||||
|
@ -344,6 +376,14 @@ static void mpeg_thread(void)
|
|||
break;
|
||||
}
|
||||
|
||||
/* grab id3 tag of new file and
|
||||
remember where in memory it starts */
|
||||
if ( last_tag < MAX_ID3_TAGS ) {
|
||||
mp3info(&(id3tags[last_tag].id3), ev.data);
|
||||
id3tags[last_tag].mempos = mp3buf_write;
|
||||
last_tag++;
|
||||
}
|
||||
|
||||
/* Make it read more data */
|
||||
filling = true;
|
||||
queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
|
||||
|
|
|
@ -27,5 +27,6 @@ void mpeg_resume(void);
|
|||
void mpeg_volume(int percent);
|
||||
void mpeg_bass(int percent);
|
||||
void mpeg_treble(int percent);
|
||||
struct mp3entry* mpeg_current_track(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -76,7 +76,7 @@ APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall
|
|||
FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c settings.c
|
||||
|
||||
APPS = main.c tree.c play.c menu.c credits.c main_menu.c\
|
||||
playlist.c showtext.c
|
||||
playlist.c showtext.c wps.c
|
||||
|
||||
MENUS = games_menu.c screensavers_menu.c settings_menu.c sound_menu.c
|
||||
|
||||
|
@ -182,6 +182,9 @@ $(OBJDIR)/boxes.o: $(RECDIR)/boxes.c
|
|||
$(OBJDIR)/main.o: $(APPDIR)/main.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/wps.o: $(APPDIR)/wps.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/bmp.o: $(RECDIR)/bmp.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
|
|
|
@ -16,11 +16,13 @@
|
|||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "debug.h"
|
||||
#include "id3.h"
|
||||
|
||||
/* This file is for emulating some of the mpeg controlling functions of
|
||||
the target */
|
||||
static struct mp3entry dummy;
|
||||
|
||||
void mpeg_volume(void)
|
||||
{
|
||||
|
@ -43,6 +45,20 @@ void mpeg_play(char *tune)
|
|||
{
|
||||
DEBUGF("We instruct the MPEG thread to play %s for us\n",
|
||||
tune);
|
||||
mp3info(&dummy, tune);
|
||||
}
|
||||
|
||||
void mpeg_pause(void)
|
||||
{
|
||||
}
|
||||
|
||||
void mpeg_resume(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
struct mp3entry* mpeg_current_track(void)
|
||||
{
|
||||
return &dummy;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user