diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-06-25 13:26:04 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-06-25 13:26:04 +0000 |
commit | bb9aaf50654bb32184d289b18f110cf9fd6687d1 (patch) | |
tree | 188943fa5d709086a89de94f1b3f98ed12979bea /firmware | |
parent | 3f9c7c2ab5edef46346fed58807307ea4499b39c (diff) | |
download | rockbox-bb9aaf50654bb32184d289b18f110cf9fd6687d1.tar.gz rockbox-bb9aaf50654bb32184d289b18f110cf9fd6687d1.zip |
A step towards WPS
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1184 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/mpeg.c | 42 | ||||
-rw-r--r-- | firmware/mpeg.h | 1 |
2 files changed, 42 insertions, 1 deletions
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 | ||
142 | static int mpeg_file; | 143 | static int mpeg_file; |
143 | 144 | ||
145 | /* list of tracks in memory */ | ||
146 | #define MAX_ID3_TAGS 4 | ||
147 | static struct { | ||
148 | struct mp3entry id3; | ||
149 | int mempos; | ||
150 | } id3tags[MAX_ID3_TAGS]; | ||
151 | static int last_tag = 0; | ||
152 | |||
144 | static void create_fliptable(void) | 153 | static 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 | ||
337 | struct mp3entry* mpeg_current_track(void) | ||
338 | { | ||
339 | return &(id3tags[0].id3); | ||
340 | } | ||
341 | |||
310 | static void mpeg_thread(void) | 342 | static 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); | |||
27 | void mpeg_volume(int percent); | 27 | void mpeg_volume(int percent); |
28 | void mpeg_bass(int percent); | 28 | void mpeg_bass(int percent); |
29 | void mpeg_treble(int percent); | 29 | void mpeg_treble(int percent); |
30 | struct mp3entry* mpeg_current_track(void); | ||
30 | 31 | ||
31 | #endif | 32 | #endif |