summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-06-25 13:26:04 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-06-25 13:26:04 +0000
commitbb9aaf50654bb32184d289b18f110cf9fd6687d1 (patch)
tree188943fa5d709086a89de94f1b3f98ed12979bea /firmware
parent3f9c7c2ab5edef46346fed58807307ea4499b39c (diff)
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.c42
-rw-r--r--firmware/mpeg.h1
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 @@
#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);
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);
void mpeg_volume(int percent);
void mpeg_bass(int percent);
void mpeg_treble(int percent);
+struct mp3entry* mpeg_current_track(void);
#endif