summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-07-01 20:11:46 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-07-01 20:11:46 +0000
commit958025bfd457d86b3e4f4531da25600740f3627d (patch)
treeb262fdd443c329db2e62a9a980b45695d19c8c7b
parentede382712635164a823c3a3ad1946f674e9e2189 (diff)
downloadrockbox-958025bfd457d86b3e4f4531da25600740f3627d.zip
rockbox-958025bfd457d86b3e4f4531da25600740f3627d.tar.gz
rockbox-958025bfd457d86b3e4f4531da25600740f3627d.tar.bz2
rockbox-958025bfd457d86b3e4f4531da25600740f3627d.tar.xz
Added mpeg_is_playing(), now stops counting time when the last song has stopped
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1288 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/mpeg.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index b61b5ee..69bc7d2 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -274,6 +274,7 @@ static int last_dma_chunk_size;
static bool dma_on; /* The DMA is active */
static bool playing; /* We are playing an MP3 stream */
+static bool play_pending; /* We are about to start playing */
static bool filling; /* We are filling the buffer with data from disk */
static int mpeg_file;
@@ -346,17 +347,17 @@ static void stop_dma(void)
static void dma_tick(void)
{
- /* Start DMA if it isn't running */
- if(playing && !dma_on)
+ if(playing)
{
- if(PBDR & 0x4000)
+ /* Start DMA if it is disabled and the DEMAND pin is high */
+ if(!dma_on && (PBDR & 0x4000))
{
if(!(SCR0 & 0x80))
start_dma();
}
+ id3tags[0].id3.elapsed += (current_tick - last_dma_tick) * 1000 / HZ;
+ last_dma_tick = current_tick;
}
- id3tags[0].id3.elapsed += (current_tick - last_dma_tick) * 1000 / HZ;
- last_dma_tick = current_tick;
}
static void bitswap(unsigned short *data, int length)
@@ -429,6 +430,7 @@ void DEI3(void)
{
DEBUGF("No more MP3 data. Stopping.\n");
CHCR3 = 0; /* Stop DMA interrupt */
+ playing = false;
}
}
@@ -486,7 +488,6 @@ static void mpeg_thread(void)
int len;
int free_space_left;
int amount_to_read;
- bool play_pending;
play_pending = false;
playing = false;
@@ -653,6 +654,7 @@ static void mpeg_thread(void)
play_pending = false;
playing = true;
+ last_dma_tick = current_tick;
init_dma();
start_dma();
}
@@ -794,6 +796,11 @@ void mpeg_prev(void)
#endif
}
+bool mpeg_is_playing(void)
+{
+ return playing || play_pending;
+}
+
#ifndef SIMULATOR
#ifndef ARCHOS_RECORDER
int current_volume=0; /* all values in tenth of dB */