Now codecs will do the buffer flushing after seeking as they find it
necessary. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7369 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6e291fdcdf
commit
8a7d104a35
4 changed files with 15 additions and 8 deletions
|
@ -247,6 +247,7 @@ struct codec_api ci = {
|
|||
|
||||
memchr,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap,
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
#endif
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define CODEC_API_VERSION 40
|
||||
#define CODEC_API_VERSION 41
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
|
@ -327,6 +327,8 @@ struct codec_api {
|
|||
|
||||
void *(*memchr)(const void *s1, int c, size_t n);
|
||||
void (*set_offset)(unsigned int value);
|
||||
/* Codec should call this function when it has done the seeking. */
|
||||
void (*seek_complete)(void);
|
||||
};
|
||||
|
||||
/* defined by the codec loader (codec.c) */
|
||||
|
|
|
@ -177,7 +177,10 @@ enum codec_status codec_start(struct codec_api* api)
|
|||
goto next_track;
|
||||
}
|
||||
ci->seek_time = 0;
|
||||
if (newpos == 0) frame_skip = start_skip;
|
||||
if (newpos == 0)
|
||||
frame_skip = start_skip;
|
||||
/* Optional but good thing to do. */
|
||||
ci->seek_complete();
|
||||
}
|
||||
|
||||
/* Lock buffers */
|
||||
|
|
|
@ -539,7 +539,6 @@ static bool rebuffer_and_seek(int newpos)
|
|||
ci.curpos = newpos;
|
||||
cur_ti->available = 0;
|
||||
lseek(current_fd, newpos, SEEK_SET);
|
||||
pcmbuf_flush_audio();
|
||||
|
||||
mutex_unlock(&mutex_bufferfill);
|
||||
|
||||
|
@ -602,6 +601,11 @@ off_t codec_mp3_get_filepos_callback(int newtime)
|
|||
return newpos;
|
||||
}
|
||||
|
||||
void codec_seek_complete_callback(void)
|
||||
{
|
||||
pcmbuf_flush_audio();
|
||||
}
|
||||
|
||||
bool codec_seek_buffer_callback(off_t newpos)
|
||||
{
|
||||
int difference;
|
||||
|
@ -620,8 +624,6 @@ bool codec_seek_buffer_callback(off_t newpos)
|
|||
if (difference >= 0) {
|
||||
logf("seek: +%d", difference);
|
||||
codec_advance_buffer_callback(difference);
|
||||
if (!pcmbuf_is_crossfade_active())
|
||||
pcmbuf_play_stop();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -642,8 +644,6 @@ bool codec_seek_buffer_callback(off_t newpos)
|
|||
if (buf_ridx < 0)
|
||||
buf_ridx = filebuflen + buf_ridx;
|
||||
ci.curpos -= difference;
|
||||
if (!pcmbuf_is_crossfade_active())
|
||||
pcmbuf_play_stop();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1939,8 +1939,8 @@ void audio_ff_rewind(int newpos)
|
|||
{
|
||||
logf("rewind: %d", newpos);
|
||||
if (playing) {
|
||||
ci.seek_time = newpos+1;
|
||||
pcmbuf_play_stop();
|
||||
ci.seek_time = newpos+1;
|
||||
paused = false;
|
||||
}
|
||||
}
|
||||
|
@ -2215,6 +2215,7 @@ void audio_init(void)
|
|||
ci.request_next_track = codec_request_next_track_callback;
|
||||
ci.mp3_get_filepos = codec_mp3_get_filepos_callback;
|
||||
ci.seek_buffer = codec_seek_buffer_callback;
|
||||
ci.seek_complete = codec_seek_complete_callback;
|
||||
ci.set_elapsed = codec_set_elapsed_callback;
|
||||
ci.set_offset = codec_set_offset_callback;
|
||||
ci.configure = codec_configure_callback;
|
||||
|
|
Loading…
Reference in a new issue