forked from len0rd/rockbox
Fixed track changing problems.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7201 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
30b8378b68
commit
d83b659fa7
2 changed files with 21 additions and 25 deletions
|
|
@ -85,7 +85,7 @@ volatile int pcmbuf_write_index;
|
||||||
int pcmbuf_unplayed_bytes;
|
int pcmbuf_unplayed_bytes;
|
||||||
int pcmbuf_watermark;
|
int pcmbuf_watermark;
|
||||||
void (*pcmbuf_watermark_event)(int bytes_left);
|
void (*pcmbuf_watermark_event)(int bytes_left);
|
||||||
static int last_chunksize;
|
//static int last_chunksize;
|
||||||
|
|
||||||
static void pcmbuf_boost(bool state)
|
static void pcmbuf_boost(bool state)
|
||||||
{
|
{
|
||||||
|
|
@ -110,11 +110,6 @@ int pcmbuf_num_used_buffers(void)
|
||||||
static void pcmbuf_callback(unsigned char** start, long* size)
|
static void pcmbuf_callback(unsigned char** start, long* size)
|
||||||
{
|
{
|
||||||
struct pcmbufdesc *desc = &pcmbuffers[pcmbuf_read_index];
|
struct pcmbufdesc *desc = &pcmbuffers[pcmbuf_read_index];
|
||||||
int sz;
|
|
||||||
|
|
||||||
pcmbuf_unplayed_bytes -= last_chunksize;
|
|
||||||
audiobuffer_free += last_chunksize;
|
|
||||||
|
|
||||||
|
|
||||||
if(desc->size == 0)
|
if(desc->size == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -129,17 +124,15 @@ static void pcmbuf_callback(unsigned char** start, long* size)
|
||||||
|
|
||||||
if(pcmbuf_num_used_buffers())
|
if(pcmbuf_num_used_buffers())
|
||||||
{
|
{
|
||||||
/* Play max 64K at a time */
|
pcmbuf_unplayed_bytes -= desc->size;
|
||||||
//sz = MIN(desc->size, 32768);
|
audiobuffer_free += desc->size;
|
||||||
sz = desc->size;
|
|
||||||
*start = desc->addr;
|
*start = desc->addr;
|
||||||
*size = sz;
|
*size = desc->size;
|
||||||
|
|
||||||
/* Update the buffer descriptor */
|
/* Update the buffer descriptor */
|
||||||
desc->size -= sz;
|
desc->addr += desc->size;
|
||||||
desc->addr += sz;
|
desc->size = 0;
|
||||||
|
|
||||||
last_chunksize = sz;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -243,7 +236,7 @@ bool pcmbuf_crossfade_init(void)
|
||||||
void pcmbuf_play_stop(void)
|
void pcmbuf_play_stop(void)
|
||||||
{
|
{
|
||||||
pcm_play_stop();
|
pcm_play_stop();
|
||||||
last_chunksize = 0;
|
//last_chunksize = 0;
|
||||||
pcmbuf_unplayed_bytes = 0;
|
pcmbuf_unplayed_bytes = 0;
|
||||||
pcmbuf_read_index = 0;
|
pcmbuf_read_index = 0;
|
||||||
pcmbuf_write_index = 0;
|
pcmbuf_write_index = 0;
|
||||||
|
|
@ -278,6 +271,7 @@ void pcmbuf_flush_audio(void)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pcmbuf_boost(true);
|
||||||
crossfade_mode = CFM_FLUSH;
|
crossfade_mode = CFM_FLUSH;
|
||||||
crossfade_init = true;
|
crossfade_init = true;
|
||||||
}
|
}
|
||||||
|
|
@ -296,7 +290,8 @@ void pcmbuf_flush_fillpos(void)
|
||||||
/* This is a fatal error situation that should never happen. */
|
/* This is a fatal error situation that should never happen. */
|
||||||
if (!pcm_is_playing()) {
|
if (!pcm_is_playing()) {
|
||||||
logf("pcm_flush_fillpos error");
|
logf("pcm_flush_fillpos error");
|
||||||
break ;
|
pcm_play_data(pcmbuf_callback);
|
||||||
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pcmbuf_event_handler = NULL;
|
pcmbuf_event_handler = NULL;
|
||||||
|
|
@ -320,7 +315,7 @@ static void crossfade_start(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
logf("crossfade_start");
|
logf("crossfade_start");
|
||||||
pcmbuf_flush_fillpos();
|
audiobuffer_fillpos = 0;
|
||||||
pcmbuf_boost(true);
|
pcmbuf_boost(true);
|
||||||
crossfade_active = true;
|
crossfade_active = true;
|
||||||
crossfade_pos = audiobuffer_pos;
|
crossfade_pos = audiobuffer_pos;
|
||||||
|
|
@ -384,7 +379,7 @@ static bool prepare_insert(long length)
|
||||||
pcmbuf_boost(false);
|
pcmbuf_boost(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pcm_is_playing()) {
|
if (!pcm_is_playing()) {
|
||||||
pcmbuf_boost(true);
|
pcmbuf_boost(true);
|
||||||
crossfade_active = false;
|
crossfade_active = false;
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ void codec_advance_buffer_callback(long amount)
|
||||||
if (amount > cur_ti->available + cur_ti->filerem)
|
if (amount > cur_ti->available + cur_ti->filerem)
|
||||||
amount = cur_ti->available + cur_ti->filerem;
|
amount = cur_ti->available + cur_ti->filerem;
|
||||||
|
|
||||||
if (amount > cur_ti->available) {
|
if (amount > cur_ti->available && !filling) {
|
||||||
if (!rebuffer_and_seek(ci.curpos + amount))
|
if (!rebuffer_and_seek(ci.curpos + amount))
|
||||||
ci.stop_codec = true;
|
ci.stop_codec = true;
|
||||||
return ;
|
return ;
|
||||||
|
|
@ -1346,16 +1346,16 @@ static void initiate_track_change(int peek_index)
|
||||||
if (!playlist_check(peek_index))
|
if (!playlist_check(peek_index))
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
new_track = peek_index;
|
|
||||||
ci.reload_codec = true;
|
|
||||||
|
|
||||||
/* Detect if disk is spinning.. */
|
/* Detect if disk is spinning.. */
|
||||||
if (filling) {
|
if (filling) {
|
||||||
ci.stop_codec = true;
|
ci.stop_codec = true;
|
||||||
playlist_next(peek_index);
|
playlist_next(peek_index);
|
||||||
queue_post(&audio_queue, AUDIO_PLAY, 0);
|
queue_post(&audio_queue, AUDIO_PLAY, 0);
|
||||||
} else {
|
} else {
|
||||||
pcmbuf_crossfade_init();
|
new_track = peek_index;
|
||||||
|
ci.reload_codec = true;
|
||||||
|
if (!pcmbuf_is_crossfade_enabled())
|
||||||
|
pcmbuf_flush_audio();
|
||||||
}
|
}
|
||||||
|
|
||||||
codec_track_changed();
|
codec_track_changed();
|
||||||
|
|
@ -1384,8 +1384,9 @@ void audio_thread(void)
|
||||||
ci.stop_codec = true;
|
ci.stop_codec = true;
|
||||||
ci.reload_codec = false;
|
ci.reload_codec = false;
|
||||||
ci.seek_time = 0;
|
ci.seek_time = 0;
|
||||||
if (!pcmbuf_is_crossfade_active())
|
pcmbuf_crossfade_init();
|
||||||
pcmbuf_crossfade_init();
|
while (codec_loaded)
|
||||||
|
yield();
|
||||||
audio_play_start((int)ev.data);
|
audio_play_start((int)ev.data);
|
||||||
playlist_update_resume_info(audio_current_track());
|
playlist_update_resume_info(audio_current_track());
|
||||||
break ;
|
break ;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue