summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/mpeg.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index a6c6783beb..85054d7cf0 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -845,14 +845,19 @@ static void swap_one_chunk(void)
845{ 845{
846 int free_space_left; 846 int free_space_left;
847 int amount_to_swap; 847 int amount_to_swap;
848 int t1, t2;
849 848
850 free_space_left = get_unswapped_space(); 849 free_space_left = get_unswapped_space();
851 850
852 if(free_space_left == 0 && !play_pending) 851 if(free_space_left == 0 && !play_pending)
853 return; 852 return;
854 853
855 amount_to_swap = MIN(MPEG_SWAP_CHUNKSIZE, free_space_left); 854 /* Swap in larger chunks when the user is waiting for the playback
855 to start */
856 if(play_pending)
857 amount_to_swap = MIN(MPEG_LOW_WATER_CHUNKSIZE, free_space_left);
858 else
859 amount_to_swap = MIN(MPEG_SWAP_CHUNKSIZE, free_space_left);
860
856 if(mp3buf_write < mp3buf_swapwrite) 861 if(mp3buf_write < mp3buf_swapwrite)
857 amount_to_swap = MIN(mp3buflen - mp3buf_swapwrite, 862 amount_to_swap = MIN(mp3buflen - mp3buf_swapwrite,
858 amount_to_swap); 863 amount_to_swap);
@@ -860,17 +865,12 @@ static void swap_one_chunk(void)
860 amount_to_swap = MIN(mp3buf_write - mp3buf_swapwrite, 865 amount_to_swap = MIN(mp3buf_write - mp3buf_swapwrite,
861 amount_to_swap); 866 amount_to_swap);
862 867
863 DEBUGF("B %x\n", amount_to_swap);
864 t1 = current_tick;
865 bitswap(mp3buf + mp3buf_swapwrite, amount_to_swap); 868 bitswap(mp3buf + mp3buf_swapwrite, amount_to_swap);
866 t2 = current_tick;
867 DEBUGF("time: %d\n", t2 - t1);
868 869
869 mp3buf_swapwrite += amount_to_swap; 870 mp3buf_swapwrite += amount_to_swap;
870 if(mp3buf_swapwrite >= mp3buflen) 871 if(mp3buf_swapwrite >= mp3buflen)
871 { 872 {
872 mp3buf_swapwrite = 0; 873 mp3buf_swapwrite = 0;
873 DEBUGF("BW\n");
874 } 874 }
875 875
876 /* And while we're at it, see if we have started 876 /* And while we're at it, see if we have started
@@ -919,8 +919,6 @@ static void mpeg_thread(void)
919 919
920 while(1) 920 while(1)
921 { 921 {
922 DEBUGF("S R:%x W:%x SW:%x\n",
923 mp3buf_read, mp3buf_write, mp3buf_swapwrite);
924 yield(); 922 yield();
925 923
926 /* Swap if necessary, and don't block on the queue_wait() */ 924 /* Swap if necessary, and don't block on the queue_wait() */
@@ -931,6 +929,8 @@ static void mpeg_thread(void)
931 } 929 }
932 else 930 else
933 { 931 {
932 DEBUGF("S R:%x W:%x SW:%x\n",
933 mp3buf_read, mp3buf_write, mp3buf_swapwrite);
934 queue_wait(&mpeg_queue, &ev); 934 queue_wait(&mpeg_queue, &ev);
935 } 935 }
936 936