forked from len0rd/rockbox
Resume now starts playback at the point it was stopped, not 2-7 seconds later.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7125 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
40a8401cd3
commit
d191756286
4 changed files with 26 additions and 4 deletions
|
@ -244,6 +244,7 @@ struct codec_api ci = {
|
|||
#endif
|
||||
|
||||
memchr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap)
|
||||
|
@ -292,7 +293,7 @@ int codec_load_file(const char *plugin)
|
|||
|
||||
/* zero out codec buffer to ensure a properly zeroed bss area */
|
||||
memset(codecbuf, 0, CODEC_SIZE);
|
||||
|
||||
|
||||
fd = open(plugin, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
snprintf(msgbuf, sizeof(msgbuf)-1, "Couldn't load codec: %s", plugin);
|
||||
|
|
|
@ -327,6 +327,7 @@ struct codec_api {
|
|||
#endif
|
||||
|
||||
void *(*memchr)(const void *s1, int c, size_t n);
|
||||
void (*set_offset)(unsigned int value);
|
||||
};
|
||||
|
||||
/* defined by the codec loader (codec.c) */
|
||||
|
|
|
@ -227,8 +227,8 @@ enum codec_status codec_start(struct codec_api* api)
|
|||
if ( rb->id3->offset ) {
|
||||
rb->advance_buffer(rb->id3->offset);
|
||||
ov_raw_seek(&vf,rb->id3->offset);
|
||||
rb->id3->offset = ov_raw_tell(&vf);
|
||||
rb->set_elapsed(ov_time_tell(&vf));
|
||||
rb->set_offset(ov_raw_tell(&vf));
|
||||
}
|
||||
|
||||
eof=0;
|
||||
|
@ -272,7 +272,7 @@ enum codec_status codec_start(struct codec_api* api)
|
|||
}
|
||||
}
|
||||
if ( !rb->seek_time ) {
|
||||
rb->id3->offset = ov_raw_tell(&vf);
|
||||
rb->set_offset(ov_raw_tell(&vf));
|
||||
rb->set_elapsed(ov_time_tell(&vf));
|
||||
rb->yield();
|
||||
}
|
||||
|
|
|
@ -370,6 +370,25 @@ void codec_set_elapsed_callback(unsigned int value)
|
|||
}
|
||||
}
|
||||
|
||||
void codec_set_offset_callback(unsigned int value)
|
||||
{
|
||||
unsigned int latency;
|
||||
|
||||
if (ci.stop_codec)
|
||||
return ;
|
||||
|
||||
/* The 1000 here is a hack. audiobuffer_get_latency() should
|
||||
* be more accurate
|
||||
*/
|
||||
latency = (audiobuffer_get_latency() + 1000) * cur_ti->id3.bitrate / 8;
|
||||
|
||||
if (value < latency) {
|
||||
cur_ti->id3.offset = 0;
|
||||
} else if (value - latency > (unsigned int)cur_ti->id3.offset ) {
|
||||
cur_ti->id3.offset = value - latency;
|
||||
}
|
||||
}
|
||||
|
||||
long codec_filebuf_callback(void *ptr, long size)
|
||||
{
|
||||
char *buf = (char *)ptr;
|
||||
|
@ -498,7 +517,7 @@ void codec_advance_buffer_callback(long amount)
|
|||
cur_ti->available -= amount;
|
||||
codecbufused -= amount;
|
||||
ci.curpos += amount;
|
||||
cur_ti->id3.offset = ci.curpos;
|
||||
codec_set_offset_callback(ci.curpos);
|
||||
}
|
||||
|
||||
void codec_advance_buffer_loc_callback(void *ptr)
|
||||
|
@ -1896,6 +1915,7 @@ void audio_init(void)
|
|||
ci.mp3_get_filepos = codec_mp3_get_filepos_callback;
|
||||
ci.seek_buffer = codec_seek_buffer_callback;
|
||||
ci.set_elapsed = codec_set_elapsed_callback;
|
||||
ci.set_offset = codec_set_offset_callback;
|
||||
ci.configure = codec_configure_callback;
|
||||
|
||||
mutex_init(&mutex_bufferfill);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue