summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorSteve Bavin <pondlife@pondlife.me>2006-10-15 11:03:26 +0000
committerSteve Bavin <pondlife@pondlife.me>2006-10-15 11:03:26 +0000
commit10befc8e6ed2129143af79cfcfbc0fd5a4fe3d85 (patch)
treee291e383781082b758362cae10a7652b628213df /apps
parentb89b5ba2ee31bd351710670cf5ecc5aa8beb95f3 (diff)
downloadrockbox-10befc8e6ed2129143af79cfcfbc0fd5a4fe3d85.tar.gz
rockbox-10befc8e6ed2129143af79cfcfbc0fd5a4fe3d85.zip
Don't unboost CPU in an ISR
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11224 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/pcmbuf.c21
-rw-r--r--apps/pcmbuf.h1
-rw-r--r--apps/playback.c14
3 files changed, 19 insertions, 17 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index 964ebbc901..d8612a4fbc 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -94,6 +94,7 @@ static size_t pcmbuf_mix_sample IDATA_ATTR;
94 94
95static bool low_latency_mode = false; 95static bool low_latency_mode = false;
96static bool pcmbuf_flush; 96static bool pcmbuf_flush;
97static volatile bool output_completed = false;
97 98
98extern struct thread_entry *codec_thread_p; 99extern struct thread_entry *codec_thread_p;
99 100
@@ -115,7 +116,7 @@ void pcmbuf_boost(bool state)
115#ifdef HAVE_PRIORITY_SCHEDULING 116#ifdef HAVE_PRIORITY_SCHEDULING
116 static bool priority_modified = false; 117 static bool priority_modified = false;
117#endif 118#endif
118 119
119 if (crossfade_init || crossfade_active) 120 if (crossfade_init || crossfade_active)
120 return; 121 return;
121 122
@@ -203,14 +204,7 @@ process_new_buffer:
203 *realsize = 0; 204 *realsize = 0;
204 *realstart = NULL; 205 *realstart = NULL;
205 CALL_IF_EXISTS(pcmbuf_event_handler); 206 CALL_IF_EXISTS(pcmbuf_event_handler);
206 /* FIXME: We need to find another way to keep the CPU from 207 output_completed = true;
207 * being left boosted, because this is boosting in interrupt
208 * context. This is also not a good thing, because it will
209 * result in the CPU being deboosted if there is a legitimate
210 * buffer underrun (albeit only temporarily, because someone
211 * will reboost it soon, but it will make the skip longer
212 * than necessary. */
213 pcmbuf_boost(false);
214 } 208 }
215 } 209 }
216} 210}
@@ -1037,3 +1031,12 @@ bool pcmbuf_is_crossfade_enabled(void)
1037 return crossfade_enabled; 1031 return crossfade_enabled;
1038} 1032}
1039 1033
1034bool pcmbuf_output_completed(void)
1035{
1036 if (output_completed)
1037 {
1038 output_completed = false;
1039 return true;
1040 }
1041 return false;
1042}
diff --git a/apps/pcmbuf.h b/apps/pcmbuf.h
index b5035f4405..2106968368 100644
--- a/apps/pcmbuf.h
+++ b/apps/pcmbuf.h
@@ -46,6 +46,7 @@ size_t get_pcmbuf_descsize(void);
46void pcmbuf_pause(bool pause); 46void pcmbuf_pause(bool pause);
47void pcmbuf_play_stop(void); 47void pcmbuf_play_stop(void);
48bool pcmbuf_is_crossfade_active(void); 48bool pcmbuf_is_crossfade_active(void);
49bool pcmbuf_output_completed(void);
49 50
50/* These functions are for playing chained buffers of PCM data */ 51/* These functions are for playing chained buffers of PCM data */
51#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR) 52#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR)
diff --git a/apps/playback.c b/apps/playback.c
index 8c480c46c7..44aa8696fc 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -203,7 +203,7 @@ static unsigned char *iram_buf[2];
203static unsigned char *dram_buf[2]; 203static unsigned char *dram_buf[2];
204 204
205/* Step count to the next unbuffered track. */ 205/* Step count to the next unbuffered track. */
206static int last_peek_offset; 206static int last_peek_offset; /* Audio thread */
207 207
208/* Track information (count in file buffer, read/write indexes for 208/* Track information (count in file buffer, read/write indexes for
209 track ring structure. */ 209 track ring structure. */
@@ -674,7 +674,7 @@ void audio_preinit(void)
674 track_buffer_callback = NULL; 674 track_buffer_callback = NULL;
675 track_unbuffer_callback = NULL; 675 track_unbuffer_callback = NULL;
676 track_changed_callback = NULL; 676 track_changed_callback = NULL;
677 /* Just to prevent CUR_TI never be anything random. */ 677 /* Just to prevent CUR_TI from being anything random. */
678 track_ridx = 0; 678 track_ridx = 0;
679 679
680 mutex_init(&mutex_codecthread); 680 mutex_init(&mutex_codecthread);
@@ -1249,7 +1249,6 @@ static void codec_set_offset_callback(size_t value)
1249static void codec_advance_buffer_counters(size_t amount) 1249static void codec_advance_buffer_counters(size_t amount)
1250{ 1250{
1251 buf_ridx = RINGBUF_ADD(buf_ridx, amount); 1251 buf_ridx = RINGBUF_ADD(buf_ridx, amount);
1252
1253 ci.curpos += amount; 1252 ci.curpos += amount;
1254 CUR_TI->available -= amount; 1253 CUR_TI->available -= amount;
1255 1254
@@ -1963,12 +1962,11 @@ static bool audio_buffer_wind_forward(int new_track_ridx, int old_track_ridx)
1963 amount = tracks[old_track_ridx].filesize - ci.curpos; 1962 amount = tracks[old_track_ridx].filesize - ci.curpos;
1964 /* Then collect all data from tracks in between them */ 1963 /* Then collect all data from tracks in between them */
1965 amount += audio_buffer_count_tracks(old_track_ridx, new_track_ridx); 1964 amount += audio_buffer_count_tracks(old_track_ridx, new_track_ridx);
1965 logf("bwf:%ldB", (long) amount);
1966 1966
1967 if (amount > FILEBUFUSED) 1967 if (amount > FILEBUFUSED)
1968 return false; 1968 return false;
1969 1969
1970 logf("bwf:%ldB",amount);
1971
1972 /* Wind the buffer to the beginning of the target track or its codec */ 1970 /* Wind the buffer to the beginning of the target track or its codec */
1973 buf_ridx = RINGBUF_ADD(buf_ridx, amount); 1971 buf_ridx = RINGBUF_ADD(buf_ridx, amount);
1974 1972
@@ -2535,7 +2533,6 @@ static bool audio_load_track(int offset, bool start_play, bool rebuffer)
2535 tracks[track_widx].id3.offset = offset; 2533 tracks[track_widx].id3.offset = offset;
2536 break; 2534 break;
2537 } 2535 }
2538
2539 } 2536 }
2540 2537
2541 logf("alt:%s", trackname); 2538 logf("alt:%s", trackname);
@@ -2891,9 +2888,8 @@ static void audio_rebuffer_and_seek(size_t newpos)
2891 int fd; 2888 int fd;
2892 char *trackname; 2889 char *trackname;
2893 2890
2894 trackname = playlist_peek(0);
2895 /* (Re-)open current track's file handle. */ 2891 /* (Re-)open current track's file handle. */
2896 2892 trackname = playlist_peek(0);
2897 fd = open(trackname, O_RDONLY); 2893 fd = open(trackname, O_RDONLY);
2898 if (fd < 0) 2894 if (fd < 0)
2899 { 2895 {
@@ -3342,6 +3338,8 @@ static void audio_thread(void)
3342 3338
3343 case SYS_TIMEOUT: 3339 case SYS_TIMEOUT:
3344 LOGFQUEUE("audio < SYS_TIMEOUT"); 3340 LOGFQUEUE("audio < SYS_TIMEOUT");
3341 if (pcmbuf_output_completed())
3342 pcmbuf_play_stop(); /* Stop to ensure unboosted */
3345 break; 3343 break;
3346 3344
3347 default: 3345 default: