summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-10-28 00:00:07 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-10-28 00:00:07 +0000
commitc5e29938c4c7dfcb1b888bbb3440f8688eb1d165 (patch)
tree52b242a5266797e2d0632de36ace0517553a91bf /firmware
parenta12eb3d89239c2933bd3679cffd7d82be305dd42 (diff)
downloadrockbox-c5e29938c4c7dfcb1b888bbb3440f8688eb1d165.tar.gz
rockbox-c5e29938c4c7dfcb1b888bbb3440f8688eb1d165.zip
Fast forward near the end of the last song in a playlist didn't activate the DMA if the remaining amount to play was below the watermark
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2754 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/mpeg.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index e8fd1acbc7..206e67d3d3 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -841,7 +841,35 @@ void hexdump(unsigned char *buf, int len)
841} 841}
842#endif 842#endif
843 843
844static void swap_one_chunk(void) 844static void start_playback_if_ready(void)
845{
846 /* See if we have started playing yet. If not, do it. */
847 if(play_pending || dma_underrun)
848 {
849 /* If the filling has stopped, and we still haven't reached
850 the watermark, the file must be smaller than the
851 watermark. We must still play it. */
852 if(((mp3buf_swapwrite - mp3buf_read) >= MPEG_LOW_WATER) ||
853 !filling)
854 {
855 DEBUGF("P\n");
856 play_pending = false;
857 playing = true;
858
859 init_dma();
860 if (!paused)
861 {
862 last_dma_tick = current_tick;
863 start_dma();
864 }
865
866 /* Tell ourselves that we need more data */
867 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
868 }
869 }
870}
871
872static bool swap_one_chunk(void)
845{ 873{
846 int free_space_left; 874 int free_space_left;
847 int amount_to_swap; 875 int amount_to_swap;
@@ -849,7 +877,7 @@ static void swap_one_chunk(void)
849 free_space_left = get_unswapped_space(); 877 free_space_left = get_unswapped_space();
850 878
851 if(free_space_left == 0 && !play_pending) 879 if(free_space_left == 0 && !play_pending)
852 return; 880 return false;
853 881
854 /* Swap in larger chunks when the user is waiting for the playback 882 /* Swap in larger chunks when the user is waiting for the playback
855 to start */ 883 to start */
@@ -873,31 +901,7 @@ static void swap_one_chunk(void)
873 mp3buf_swapwrite = 0; 901 mp3buf_swapwrite = 0;
874 } 902 }
875 903
876 /* And while we're at it, see if we have started 904 return true;
877 playing yet. If not, do it. */
878 if(play_pending || dma_underrun)
879 {
880 /* If the filling has stopped, and we still haven't reached
881 the watermark, the file must be smaller than the
882 watermark. We must still play it. */
883 if(((mp3buf_swapwrite - mp3buf_read) >= MPEG_LOW_WATER) ||
884 !filling)
885 {
886 DEBUGF("P\n");
887 play_pending = false;
888 playing = true;
889
890 init_dma();
891 if (!paused)
892 {
893 last_dma_tick = current_tick;
894 start_dma();
895 }
896
897 /* Tell ourselves that we need more data */
898 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
899 }
900 }
901} 905}
902 906
903static void mpeg_thread(void) 907static void mpeg_thread(void)
@@ -922,9 +926,8 @@ static void mpeg_thread(void)
922 yield(); 926 yield();
923 927
924 /* Swap if necessary, and don't block on the queue_wait() */ 928 /* Swap if necessary, and don't block on the queue_wait() */
925 if(get_unswapped_space()) 929 if(swap_one_chunk())
926 { 930 {
927 swap_one_chunk();
928 queue_wait_w_tmo(&mpeg_queue, &ev, 0); 931 queue_wait_w_tmo(&mpeg_queue, &ev, 0);
929 } 932 }
930 else 933 else
@@ -933,6 +936,8 @@ static void mpeg_thread(void)
933 mp3buf_read, mp3buf_write, mp3buf_swapwrite); 936 mp3buf_read, mp3buf_write, mp3buf_swapwrite);
934 queue_wait(&mpeg_queue, &ev); 937 queue_wait(&mpeg_queue, &ev);
935 } 938 }
939
940 start_playback_if_ready();
936 941
937 switch(ev.id) 942 switch(ev.id)
938 { 943 {