forked from len0rd/rockbox
Don't unboost CPU in an ISR
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11224 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b89b5ba2ee
commit
10befc8e6e
3 changed files with 19 additions and 17 deletions
|
|
@ -94,6 +94,7 @@ static size_t pcmbuf_mix_sample IDATA_ATTR;
|
||||||
|
|
||||||
static bool low_latency_mode = false;
|
static bool low_latency_mode = false;
|
||||||
static bool pcmbuf_flush;
|
static bool pcmbuf_flush;
|
||||||
|
static volatile bool output_completed = false;
|
||||||
|
|
||||||
extern struct thread_entry *codec_thread_p;
|
extern struct thread_entry *codec_thread_p;
|
||||||
|
|
||||||
|
|
@ -115,7 +116,7 @@ void pcmbuf_boost(bool state)
|
||||||
#ifdef HAVE_PRIORITY_SCHEDULING
|
#ifdef HAVE_PRIORITY_SCHEDULING
|
||||||
static bool priority_modified = false;
|
static bool priority_modified = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (crossfade_init || crossfade_active)
|
if (crossfade_init || crossfade_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -203,14 +204,7 @@ process_new_buffer:
|
||||||
*realsize = 0;
|
*realsize = 0;
|
||||||
*realstart = NULL;
|
*realstart = NULL;
|
||||||
CALL_IF_EXISTS(pcmbuf_event_handler);
|
CALL_IF_EXISTS(pcmbuf_event_handler);
|
||||||
/* FIXME: We need to find another way to keep the CPU from
|
output_completed = true;
|
||||||
* being left boosted, because this is boosting in interrupt
|
|
||||||
* context. This is also not a good thing, because it will
|
|
||||||
* result in the CPU being deboosted if there is a legitimate
|
|
||||||
* buffer underrun (albeit only temporarily, because someone
|
|
||||||
* will reboost it soon, but it will make the skip longer
|
|
||||||
* than necessary. */
|
|
||||||
pcmbuf_boost(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1037,3 +1031,12 @@ bool pcmbuf_is_crossfade_enabled(void)
|
||||||
return crossfade_enabled;
|
return crossfade_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pcmbuf_output_completed(void)
|
||||||
|
{
|
||||||
|
if (output_completed)
|
||||||
|
{
|
||||||
|
output_completed = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ size_t get_pcmbuf_descsize(void);
|
||||||
void pcmbuf_pause(bool pause);
|
void pcmbuf_pause(bool pause);
|
||||||
void pcmbuf_play_stop(void);
|
void pcmbuf_play_stop(void);
|
||||||
bool pcmbuf_is_crossfade_active(void);
|
bool pcmbuf_is_crossfade_active(void);
|
||||||
|
bool pcmbuf_output_completed(void);
|
||||||
|
|
||||||
/* These functions are for playing chained buffers of PCM data */
|
/* These functions are for playing chained buffers of PCM data */
|
||||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR)
|
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && !defined(SIMULATOR)
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ static unsigned char *iram_buf[2];
|
||||||
static unsigned char *dram_buf[2];
|
static unsigned char *dram_buf[2];
|
||||||
|
|
||||||
/* Step count to the next unbuffered track. */
|
/* Step count to the next unbuffered track. */
|
||||||
static int last_peek_offset;
|
static int last_peek_offset; /* Audio thread */
|
||||||
|
|
||||||
/* Track information (count in file buffer, read/write indexes for
|
/* Track information (count in file buffer, read/write indexes for
|
||||||
track ring structure. */
|
track ring structure. */
|
||||||
|
|
@ -674,7 +674,7 @@ void audio_preinit(void)
|
||||||
track_buffer_callback = NULL;
|
track_buffer_callback = NULL;
|
||||||
track_unbuffer_callback = NULL;
|
track_unbuffer_callback = NULL;
|
||||||
track_changed_callback = NULL;
|
track_changed_callback = NULL;
|
||||||
/* Just to prevent CUR_TI never be anything random. */
|
/* Just to prevent CUR_TI from being anything random. */
|
||||||
track_ridx = 0;
|
track_ridx = 0;
|
||||||
|
|
||||||
mutex_init(&mutex_codecthread);
|
mutex_init(&mutex_codecthread);
|
||||||
|
|
@ -1249,7 +1249,6 @@ static void codec_set_offset_callback(size_t value)
|
||||||
static void codec_advance_buffer_counters(size_t amount)
|
static void codec_advance_buffer_counters(size_t amount)
|
||||||
{
|
{
|
||||||
buf_ridx = RINGBUF_ADD(buf_ridx, amount);
|
buf_ridx = RINGBUF_ADD(buf_ridx, amount);
|
||||||
|
|
||||||
ci.curpos += amount;
|
ci.curpos += amount;
|
||||||
CUR_TI->available -= amount;
|
CUR_TI->available -= amount;
|
||||||
|
|
||||||
|
|
@ -1963,12 +1962,11 @@ static bool audio_buffer_wind_forward(int new_track_ridx, int old_track_ridx)
|
||||||
amount = tracks[old_track_ridx].filesize - ci.curpos;
|
amount = tracks[old_track_ridx].filesize - ci.curpos;
|
||||||
/* Then collect all data from tracks in between them */
|
/* Then collect all data from tracks in between them */
|
||||||
amount += audio_buffer_count_tracks(old_track_ridx, new_track_ridx);
|
amount += audio_buffer_count_tracks(old_track_ridx, new_track_ridx);
|
||||||
|
logf("bwf:%ldB", (long) amount);
|
||||||
|
|
||||||
if (amount > FILEBUFUSED)
|
if (amount > FILEBUFUSED)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
logf("bwf:%ldB",amount);
|
|
||||||
|
|
||||||
/* Wind the buffer to the beginning of the target track or its codec */
|
/* Wind the buffer to the beginning of the target track or its codec */
|
||||||
buf_ridx = RINGBUF_ADD(buf_ridx, amount);
|
buf_ridx = RINGBUF_ADD(buf_ridx, amount);
|
||||||
|
|
||||||
|
|
@ -2535,7 +2533,6 @@ static bool audio_load_track(int offset, bool start_play, bool rebuffer)
|
||||||
tracks[track_widx].id3.offset = offset;
|
tracks[track_widx].id3.offset = offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logf("alt:%s", trackname);
|
logf("alt:%s", trackname);
|
||||||
|
|
@ -2891,9 +2888,8 @@ static void audio_rebuffer_and_seek(size_t newpos)
|
||||||
int fd;
|
int fd;
|
||||||
char *trackname;
|
char *trackname;
|
||||||
|
|
||||||
trackname = playlist_peek(0);
|
|
||||||
/* (Re-)open current track's file handle. */
|
/* (Re-)open current track's file handle. */
|
||||||
|
trackname = playlist_peek(0);
|
||||||
fd = open(trackname, O_RDONLY);
|
fd = open(trackname, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
|
|
@ -3342,6 +3338,8 @@ static void audio_thread(void)
|
||||||
|
|
||||||
case SYS_TIMEOUT:
|
case SYS_TIMEOUT:
|
||||||
LOGFQUEUE("audio < SYS_TIMEOUT");
|
LOGFQUEUE("audio < SYS_TIMEOUT");
|
||||||
|
if (pcmbuf_output_completed())
|
||||||
|
pcmbuf_play_stop(); /* Stop to ensure unboosted */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue