forked from len0rd/rockbox
Fixed the "last song bug".
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6725 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e941289c2f
commit
c3fed62fc7
3 changed files with 24 additions and 5 deletions
|
@ -171,6 +171,10 @@ bool audiobuffer_insert(char *buf, size_t length)
|
|||
return true;
|
||||
}
|
||||
|
||||
void audiobuffer_add_event(void (*event_handler)(void))
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int audiobuffer_get_latency()
|
||||
{
|
||||
return 0;
|
||||
|
@ -416,6 +420,11 @@ void codec_configure_callback(int setting, void *value)
|
|||
}
|
||||
}
|
||||
|
||||
void codec_track_changed(void)
|
||||
{
|
||||
track_changed = true;
|
||||
}
|
||||
|
||||
void yield_codecs(void)
|
||||
{
|
||||
yield();
|
||||
|
@ -603,6 +612,8 @@ bool audio_load_track(int offset, bool start_play, int peek_offset)
|
|||
|
||||
trackname = playlist_peek(peek_offset);
|
||||
if (!trackname) {
|
||||
logf("End-of-playlist");
|
||||
conf_watermark = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -668,7 +679,7 @@ bool audio_load_track(int offset, bool start_play, int peek_offset)
|
|||
|
||||
if (start_play) {
|
||||
track_count++;
|
||||
track_changed = true;
|
||||
audiobuffer_add_event(codec_track_changed);
|
||||
}
|
||||
|
||||
i = tracks[track_widx].start_pos;
|
||||
|
@ -872,13 +883,15 @@ void audio_update_trackinfo(void)
|
|||
ci.mp3data = (struct mp3info *)&cur_ti->mp3data;
|
||||
ci.curpos = 0;
|
||||
ci.taginfo_ready = (bool *)&cur_ti->taginfo_ready;
|
||||
track_changed = true;
|
||||
audiobuffer_add_event(codec_track_changed);
|
||||
}
|
||||
|
||||
void audio_change_track(void)
|
||||
{
|
||||
if (track_ridx == track_widx) {
|
||||
logf("No more tracks");
|
||||
while (pcm_is_playing())
|
||||
yield();
|
||||
playing = false;
|
||||
return ;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ void pcm_play_set_watermark(int numbytes, void (*callback)(int bytes_left));
|
|||
void pcm_set_boost_mode(bool state);
|
||||
bool pcm_is_lowdata(void);
|
||||
bool pcm_crossfade_start(void);
|
||||
void audiobuffer_add_event(void (*event_handler)(void));
|
||||
unsigned int audiobuffer_get_latency(void);
|
||||
bool audiobuffer_insert(char *buf, size_t length);
|
||||
bool pcm_is_crossfade_enabled(void);
|
||||
|
|
|
@ -62,6 +62,8 @@ static int crossfade_pos;
|
|||
static int crossfade_amount;
|
||||
static int crossfade_rem;
|
||||
|
||||
static void (*pcm_event_handler)(void);
|
||||
|
||||
static unsigned char *next_start;
|
||||
static long next_size;
|
||||
|
||||
|
@ -202,6 +204,8 @@ static void pcm_play_callback(unsigned char** start, long* size)
|
|||
{
|
||||
/* No more buffers */
|
||||
*size = 0;
|
||||
if (pcm_event_handler)
|
||||
pcm_event_handler();
|
||||
}
|
||||
#if 1
|
||||
if(pcmbuf_unplayed_bytes <= pcmbuf_watermark)
|
||||
|
@ -363,8 +367,7 @@ void pcm_set_boost_mode(bool state)
|
|||
|
||||
void audiobuffer_add_event(void (*event_handler)(void))
|
||||
{
|
||||
while (!pcm_play_add_chunk(NULL, 0, event_handler))
|
||||
yield();
|
||||
pcm_event_handler = event_handler;
|
||||
}
|
||||
|
||||
unsigned int audiobuffer_get_latency(void)
|
||||
|
@ -474,10 +477,11 @@ bool audiobuffer_insert(char *buf, size_t length)
|
|||
copy_n += audiobuffer_fillpos;
|
||||
|
||||
while (!pcm_play_add_chunk(&audiobuffer[audiobuffer_pos],
|
||||
copy_n, NULL)) {
|
||||
copy_n, pcm_event_handler)) {
|
||||
pcm_boost(false);
|
||||
yield();
|
||||
}
|
||||
pcm_event_handler = NULL;
|
||||
|
||||
audiobuffer_pos += copy_n;
|
||||
audiobuffer_fillpos = 0;
|
||||
|
@ -502,6 +506,7 @@ void pcm_play_init(void)
|
|||
pcmbuf_write_index = 0;
|
||||
pcmbuf_unplayed_bytes = 0;
|
||||
crossfade_enabled = false;
|
||||
pcm_event_handler = NULL;
|
||||
pcm_play_set_watermark(PCM_WATERMARK, pcm_watermark_callback);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue