summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/tree.c82
-rw-r--r--apps/wps.c51
-rw-r--r--apps/wps.h2
-rw-r--r--firmware/mpeg.c42
-rw-r--r--firmware/mpeg.h1
-rw-r--r--uisimulator/x11/Makefile5
-rw-r--r--uisimulator/x11/mpeg.c18
7 files changed, 145 insertions, 56 deletions
diff --git a/apps/tree.c b/apps/tree.c
index a1af9bc203..b43c1d725d 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -34,6 +34,7 @@
34#include "mpeg.h" 34#include "mpeg.h"
35#include "playlist.h" 35#include "playlist.h"
36#include "menu.h" 36#include "menu.h"
37#include "wps.h"
37 38
38#ifdef HAVE_LCD_BITMAP 39#ifdef HAVE_LCD_BITMAP
39#include "icons.h" 40#include "icons.h"
@@ -198,31 +199,31 @@ char* peek_next_track(int type)
198 return NULL; 199 return NULL;
199 200
200 switch(playing) { 201 switch(playing) {
201 default: 202 default:
202 case 1: 203 case 1:
203 /* play-full-dir mode */ 204 /* play-full-dir mode */
204 205
205 /* get next track in dir */ 206 /* get next track in dir */
206 while (dircursor + start + 1 < numentries ) { 207 while (dircursor + start + 1 < numentries ) {
207 if(dircursor+1 < TREE_MAX_ON_SCREEN) 208 if(dircursor+1 < TREE_MAX_ON_SCREEN)
208 dircursor++; 209 dircursor++;
209 else 210 else
210 start++; 211 start++;
211 if ( dircacheptr[dircursor+start]->file && 212 if ( dircacheptr[dircursor+start]->file &&
212 dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') { 213 dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
213 snprintf(buf,sizeof buf,"%s/%s", 214 snprintf(buf,sizeof buf,"%s/%s",
214 currdir, dircacheptr[dircursor+start]->name ); 215 currdir, dircacheptr[dircursor+start]->name );
215 lcd_clear_display(); 216 lcd_clear_display();
216 lcd_puts(0,0,"<Playing>"); 217 lcd_puts(0,0,"<Playing>");
217 lcd_puts(0,1,"<all files>"); 218 lcd_puts(0,1,"<all files>");
218 return buf; 219 return buf;
219 } 220 }
220 } 221 }
221 break; 222 break;
222 223
223 case 2: 224 case 2:
224 /* playlist mode */ 225 /* playlist mode */
225 return playlist_next(type); 226 return playlist_next(type);
226 } 227 }
227 228
228 return NULL; 229 return NULL;
@@ -246,6 +247,7 @@ bool dirbrowse(char *root)
246 lcd_update(); 247 lcd_update();
247 248
248 while(1) { 249 while(1) {
250 bool restore = false;
249 button = button_get(true); 251 button = button_get(true);
250 252
251 switch(button) { 253 switch(button) {
@@ -267,8 +269,7 @@ bool dirbrowse(char *root)
267 } 269 }
268 else 270 else
269 start = dircursor = 0; 271 start = dircursor = 0;
270 numentries = showdir(currdir, start); 272 restore = true;
271 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
272 } 273 }
273 else 274 else
274 mpeg_stop(); 275 mpeg_stop();
@@ -316,8 +317,7 @@ bool dirbrowse(char *root)
316 playing = 0; 317 playing = 0;
317 } 318 }
318 } 319 }
319 numentries = showdir(currdir, start); 320 restore = true;
320 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
321 break; 321 break;
322 322
323 case TREE_PREV: 323 case TREE_PREV:
@@ -354,20 +354,28 @@ bool dirbrowse(char *root)
354 case TREE_MENU: 354 case TREE_MENU:
355 lcd_stop_scroll(); 355 lcd_stop_scroll();
356 main_menu(); 356 main_menu();
357 restore = true;
358 break;
357 359
358 /* restore display */ 360 case BUTTON_ON:
359 /* TODO: this is just a copy from BUTTON_STOP, fix it */ 361 wps_show();
360 lcd_clear_display(); 362 restore = true;
361 numentries = showdir(currdir, start);
362 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
363
364 break; 363 break;
364
365 } 365 }
366 366
367 lcd_stop_scroll(); 367 if ( restore ) {
368 if ( numentries ) 368 /* restore display */
369 lcd_puts_scroll(LINE_X, LINE_Y+dircursor, 369 /* TODO: this is just a copy from BUTTON_STOP, fix it */
370 dircacheptr[start+dircursor]->name); 370 numentries = showdir(currdir, start);
371 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
372 }
373 else {
374 lcd_stop_scroll();
375 if ( numentries )
376 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
377 dircacheptr[start+dircursor]->name);
378 }
371 379
372 lcd_update(); 380 lcd_update();
373 } 381 }
diff --git a/apps/wps.c b/apps/wps.c
index fb878d6aaf..bd23a28557 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -29,6 +29,7 @@
29#include "sprintf.h" 29#include "sprintf.h"
30#include "settings.h" 30#include "settings.h"
31#include "wps.h" 31#include "wps.h"
32#include "mpeg.h"
32 33
33 34
34#define LINE_Y 1 /* initial line */ 35#define LINE_Y 1 /* initial line */
@@ -38,11 +39,12 @@
38#define PLAY_DISPLAY_TRACK_TITLE 2 39#define PLAY_DISPLAY_TRACK_TITLE 2
39 40
40/* demonstrates showing different formats from playtune */ 41/* demonstrates showing different formats from playtune */
41void wps_show_play(char* filename) 42void wps_show(void)
42{ 43{
43 struct mp3entry mp3; 44 struct mp3entry* id3 = mpeg_current_track();
44 mp3info(&mp3,filename); 45 static bool playing = true;
45 46
47 lcd_clear_display();
46 switch ( global_settings.wps_display ) { 48 switch ( global_settings.wps_display ) {
47 case PLAY_DISPLAY_TRACK_TITLE: 49 case PLAY_DISPLAY_TRACK_TITLE:
48 { 50 {
@@ -54,7 +56,7 @@ void wps_show_play(char* filename)
54 char szBuff[257]; 56 char szBuff[257];
55 szBuff[sizeof(szBuff)-1] = 0; 57 szBuff[sizeof(szBuff)-1] = 0;
56 58
57 strncpy(szBuff, filename, sizeof(szBuff)); 59 strncpy(szBuff, id3->path, sizeof(szBuff));
58 60
59 szTok = strtok_r(szBuff, "/", &end); 61 szTok = strtok_r(szBuff, "/", &end);
60 szTok = strtok_r(NULL, "/", &end); 62 szTok = strtok_r(NULL, "/", &end);
@@ -62,7 +64,7 @@ void wps_show_play(char* filename)
62 // Assume path format of: Genre/Artist/Album/Mp3_file 64 // Assume path format of: Genre/Artist/Album/Mp3_file
63 strncpy(szArtist,szTok,sizeof(szArtist)); 65 strncpy(szArtist,szTok,sizeof(szArtist));
64 szArtist[sizeof(szArtist)-1] = 0; 66 szArtist[sizeof(szArtist)-1] = 0;
65 szDelimit = strrchr(filename, ch); 67 szDelimit = strrchr(id3->path, ch);
66 lcd_puts(0,0, szArtist?szArtist:"<nothing>"); 68 lcd_puts(0,0, szArtist?szArtist:"<nothing>");
67 lcd_puts_scroll(0,LINE_Y,(++szDelimit)); 69 lcd_puts_scroll(0,LINE_Y,(++szDelimit));
68 break; 70 break;
@@ -70,12 +72,12 @@ void wps_show_play(char* filename)
70 case PLAY_DISPLAY_FILENAME_SCROLL: 72 case PLAY_DISPLAY_FILENAME_SCROLL:
71 { 73 {
72 char ch = '/'; 74 char ch = '/';
73 char* szLast = strrchr(filename, ch); 75 char* szLast = strrchr(id3->path, ch);
74 76
75 if (szLast) 77 if (szLast)
76 lcd_puts_scroll(0,0, (++szLast)); 78 lcd_puts_scroll(0,0, (++szLast));
77 else 79 else
78 lcd_puts_scroll(0,0, mp3.path); 80 lcd_puts_scroll(0,0, id3->path);
79 81
80 break; 82 break;
81 } 83 }
@@ -85,27 +87,46 @@ void wps_show_play(char* filename)
85 char buffer[256]; 87 char buffer[256];
86 88
87 lcd_puts(0, 0, "[id3 info]"); 89 lcd_puts(0, 0, "[id3 info]");
88 lcd_puts(0, LINE_Y, mp3.title?mp3.title:""); 90 lcd_puts(0, LINE_Y, id3->title?id3->title:"");
89 lcd_puts(0, LINE_Y+1, mp3.album?mp3.album:""); 91 lcd_puts(0, LINE_Y+1, id3->album?id3->album:"");
90 lcd_puts(0, LINE_Y+2, mp3.artist?mp3.artist:""); 92 lcd_puts(0, LINE_Y+2, id3->artist?id3->artist:"");
91 93
92 snprintf(buffer,sizeof(buffer), "%d ms", mp3.length); 94 snprintf(buffer,sizeof(buffer), "%d ms", id3->length);
93 lcd_puts(0, LINE_Y+3, buffer); 95 lcd_puts(0, LINE_Y+3, buffer);
94 96
95 snprintf(buffer,sizeof(buffer), "%d kbits", mp3.bitrate); 97 snprintf(buffer,sizeof(buffer), "%d kbits", id3->bitrate);
96 98
97 lcd_puts(0, LINE_Y+4, buffer); 99 lcd_puts(0, LINE_Y+4, buffer);
98 100
99 snprintf(buffer,sizeof(buffer), "%d Hz", mp3.frequency); 101 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency);
100 lcd_puts(0, LINE_Y+5, buffer); 102 lcd_puts(0, LINE_Y+5, buffer);
101#else 103#else
102 104
103 lcd_puts(0, 0, mp3.artist?mp3.artist:"<no artist>"); 105 lcd_puts(0, 0, id3->artist?id3->artist:"<no artist>");
104 lcd_puts(0, 1, mp3.title?mp3.title:"<no title>"); 106 lcd_puts(0, 1, id3->title?id3->title:"<no title>");
105#endif 107#endif
106 break; 108 break;
107 } 109 }
110 }
111 lcd_update();
112 while ( 1 ) {
113 switch ( button_get(true) ) {
114 case BUTTON_ON:
115 return;
108 116
117#ifdef HAVE_RECORDER_KEYPAD
118 case BUTTON_PLAY:
119#else
120 case BUTTON_UP:
121#endif
122 if ( playing )
123 mpeg_pause();
124 else
125 mpeg_resume();
126
127 playing = !playing;
128 break;
129 }
109 } 130 }
110} 131}
111 132
diff --git a/apps/wps.h b/apps/wps.h
index 2bc6fbf8dc..4963ffee4f 100644
--- a/apps/wps.h
+++ b/apps/wps.h
@@ -21,7 +21,7 @@
21#include "id3.h" 21#include "id3.h"
22#include "playlist.h" 22#include "playlist.h"
23 23
24void wps_show_play(char* filename); 24void wps_show(void);
25//void wps_show_playlist(char* current, playlist_info_t *list); 25//void wps_show_playlist(char* current, playlist_info_t *list);
26 26
27#endif 27#endif
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index cce67dbdee..41be070a6e 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -29,6 +29,7 @@
29#include "panic.h" 29#include "panic.h"
30#include "file.h" 30#include "file.h"
31#include "settings.h" 31#include "settings.h"
32#include "id3.h"
32 33
33#define MPEG_STACK_SIZE 0x2000 34#define MPEG_STACK_SIZE 0x2000
34#define MPEG_CHUNKSIZE 0x20000 35#define MPEG_CHUNKSIZE 0x20000
@@ -141,6 +142,14 @@ static bool filling; /* We are filling the buffer with data from disk */
141 142
142static int mpeg_file; 143static int mpeg_file;
143 144
145/* list of tracks in memory */
146#define MAX_ID3_TAGS 4
147static struct {
148 struct mp3entry id3;
149 int mempos;
150} id3tags[MAX_ID3_TAGS];
151static int last_tag = 0;
152
144static void create_fliptable(void) 153static void create_fliptable(void)
145{ 154{
146 int i; 155 int i;
@@ -271,6 +280,16 @@ void DEI3(void)
271 last_dma_chunk_size = MIN(last_dma_chunk_size, space_until_end_of_buffer); 280 last_dma_chunk_size = MIN(last_dma_chunk_size, space_until_end_of_buffer);
272 DTCR3 = last_dma_chunk_size & 0xffff; 281 DTCR3 = last_dma_chunk_size & 0xffff;
273 SAR3 = (unsigned int)mp3buf + mp3buf_read; 282 SAR3 = (unsigned int)mp3buf + mp3buf_read;
283
284 /* will we move across the track boundary? */
285 if (( mp3buf_read <= id3tags[0].mempos ) &&
286 ( mp3buf_read + last_dma_chunk_size > id3tags[0].mempos )) {
287 /* shift array so index 0 is current track */
288 int i;
289 for (i=0; i<MAX_ID3_TAGS-1; i++)
290 id3tags[i] = id3tags[i+1];
291 last_tag--;
292 }
274 } 293 }
275 else 294 else
276 { 295 {
@@ -297,7 +316,15 @@ static int new_file(void)
297 if ( !trackname ) 316 if ( !trackname )
298 return -1; 317 return -1;
299 318
300 debugf("playing %s\n", trackname); 319 DEBUGF("playing %s\n", trackname);
320
321 /* grab id3 tag of new file and remember where in memory it starts */
322 if ( last_tag < MAX_ID3_TAGS ) {
323 mp3info(&(id3tags[last_tag].id3), trackname);
324 id3tags[last_tag].mempos = mp3buf_write;
325 last_tag++;
326 }
327
301 mpeg_file = open(trackname, O_RDONLY); 328 mpeg_file = open(trackname, O_RDONLY);
302 if(mpeg_file < 0) 329 if(mpeg_file < 0)
303 { 330 {
@@ -307,6 +334,11 @@ static int new_file(void)
307 return 0; 334 return 0;
308} 335}
309 336
337struct mp3entry* mpeg_current_track(void)
338{
339 return &(id3tags[0].id3);
340}
341
310static void mpeg_thread(void) 342static void mpeg_thread(void)
311{ 343{
312 struct event ev; 344 struct event ev;
@@ -344,6 +376,14 @@ static void mpeg_thread(void)
344 break; 376 break;
345 } 377 }
346 378
379 /* grab id3 tag of new file and
380 remember where in memory it starts */
381 if ( last_tag < MAX_ID3_TAGS ) {
382 mp3info(&(id3tags[last_tag].id3), ev.data);
383 id3tags[last_tag].mempos = mp3buf_write;
384 last_tag++;
385 }
386
347 /* Make it read more data */ 387 /* Make it read more data */
348 filling = true; 388 filling = true;
349 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0); 389 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
diff --git a/firmware/mpeg.h b/firmware/mpeg.h
index 493e5f55a2..54b760c151 100644
--- a/firmware/mpeg.h
+++ b/firmware/mpeg.h
@@ -27,5 +27,6 @@ void mpeg_resume(void);
27void mpeg_volume(int percent); 27void mpeg_volume(int percent);
28void mpeg_bass(int percent); 28void mpeg_bass(int percent);
29void mpeg_treble(int percent); 29void mpeg_treble(int percent);
30struct mp3entry* mpeg_current_track(void);
30 31
31#endif 32#endif
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
index 9681ad521e..d3b446f5c9 100644
--- a/uisimulator/x11/Makefile
+++ b/uisimulator/x11/Makefile
@@ -76,7 +76,7 @@ APPCFLAGS = $(DEBUG) $(DEFINES) $(APPINCLUDES) -W -Wall
76FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c settings.c 76FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c settings.c
77 77
78APPS = main.c tree.c play.c menu.c credits.c main_menu.c\ 78APPS = main.c tree.c play.c menu.c credits.c main_menu.c\
79 playlist.c showtext.c 79 playlist.c showtext.c wps.c
80 80
81MENUS = games_menu.c screensavers_menu.c settings_menu.c sound_menu.c 81MENUS = games_menu.c screensavers_menu.c settings_menu.c sound_menu.c
82 82
@@ -182,6 +182,9 @@ $(OBJDIR)/boxes.o: $(RECDIR)/boxes.c
182$(OBJDIR)/main.o: $(APPDIR)/main.c 182$(OBJDIR)/main.o: $(APPDIR)/main.c
183 $(CC) $(APPCFLAGS) -c $< -o $@ 183 $(CC) $(APPCFLAGS) -c $< -o $@
184 184
185$(OBJDIR)/wps.o: $(APPDIR)/wps.c
186 $(CC) $(APPCFLAGS) -c $< -o $@
187
185$(OBJDIR)/bmp.o: $(RECDIR)/bmp.c 188$(OBJDIR)/bmp.o: $(RECDIR)/bmp.c
186 $(CC) $(APPCFLAGS) -c $< -o $@ 189 $(CC) $(APPCFLAGS) -c $< -o $@
187 190
diff --git a/uisimulator/x11/mpeg.c b/uisimulator/x11/mpeg.c
index 0f3680d737..e1bce1e22c 100644
--- a/uisimulator/x11/mpeg.c
+++ b/uisimulator/x11/mpeg.c
@@ -16,11 +16,13 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19#include <stdbool.h>
20#include "debug.h" 20#include "debug.h"
21#include "id3.h"
21 22
22/* This file is for emulating some of the mpeg controlling functions of 23/* This file is for emulating some of the mpeg controlling functions of
23 the target */ 24 the target */
25static struct mp3entry dummy;
24 26
25void mpeg_volume(void) 27void mpeg_volume(void)
26{ 28{
@@ -43,6 +45,20 @@ void mpeg_play(char *tune)
43{ 45{
44 DEBUGF("We instruct the MPEG thread to play %s for us\n", 46 DEBUGF("We instruct the MPEG thread to play %s for us\n",
45 tune); 47 tune);
48 mp3info(&dummy, tune);
49}
50
51void mpeg_pause(void)
52{
53}
54
55void mpeg_resume(void)
56{
46} 57}
47 58
48#endif 59#endif
60
61struct mp3entry* mpeg_current_track(void)
62{
63 return &dummy;
64}