From 7ad2cad173ffa094bb285112582afee1c9aea4e5 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 28 Aug 2011 07:45:35 +0000 Subject: Commit work started in FS#12153 to put timing/position information in PCM buffer chunks. * Samples and position indication is closely associated with audio data instead of compensating by a latency constant. Alleviates problems with using the elapsed as a track indicator where it could be off by several steps. * Timing is accurate throughout track even if resampling for pitch shift, whereas before it updated during transition latency at the normal 1:1 rate. * Simpler PCM buffer with a constant chunk size, no linked lists. In converting crossfade, a minor change was made to not change the WPS until the fade-in of the incoming track, whereas before it would change upon the start of the fade-out of the outgoing track possibly having the WPS change with far too much lead time. Codec changes are to set elapsed times *before* writing next PCM frame because time and position data last set are saved in the next committed PCM chunk. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30366 a1c6a512-1295-4272-9138-f99709370657 --- apps/pcmbuf.h | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'apps/pcmbuf.h') diff --git a/apps/pcmbuf.h b/apps/pcmbuf.h index a5cd3163e1..3261b20b35 100644 --- a/apps/pcmbuf.h +++ b/apps/pcmbuf.h @@ -21,9 +21,11 @@ #ifndef PCMBUF_H #define PCMBUF_H +#include + /* Commit PCM data */ void *pcmbuf_request_buffer(int *count); -void pcmbuf_write_complete(int count); +void pcmbuf_write_complete(int count, unsigned long elapsed, off_t offset); /* Init */ size_t pcmbuf_init(unsigned char *bufend); @@ -33,20 +35,30 @@ void pcmbuf_play_start(void); void pcmbuf_play_stop(void); void pcmbuf_pause(bool pause); void pcmbuf_monitor_track_change(bool monitor); -bool pcmbuf_start_track_change(bool manual_skip); +void pcmbuf_sync_position_update(void); + +/* Track change origin type */ +enum pcm_track_change_type +{ + TRACK_CHANGE_NONE = 0, /* No track change pending */ + TRACK_CHANGE_MANUAL, /* Manual change (from user) */ + TRACK_CHANGE_AUTO, /* Automatic change (from codec) */ + TRACK_CHANGE_END_OF_DATA, /* Expect no more data (from codec) */ +}; +void pcmbuf_start_track_change(enum pcm_track_change_type type); /* Crossfade */ #ifdef HAVE_CROSSFADE bool pcmbuf_is_crossfade_active(void); -void pcmbuf_request_crossfade_enable(bool on_off); +void pcmbuf_request_crossfade_enable(int setting); bool pcmbuf_is_same_size(void); #else /* Dummy functions with sensible returns */ -static inline bool pcmbuf_is_crossfade_active(void) +static FORCE_INLINE bool pcmbuf_is_crossfade_active(void) { return false; } -static inline void pcmbuf_request_crossfade_enable(bool on_off) +static FORCE_INLINE void pcmbuf_request_crossfade_enable(bool on_off) { return; (void)on_off; } -static inline bool pcmbuf_is_same_size(void) +static FORCE_INLINE bool pcmbuf_is_same_size(void) { return true; } #endif @@ -59,9 +71,7 @@ size_t pcmbuf_free(void); size_t pcmbuf_get_bufsize(void); int pcmbuf_descs(void); int pcmbuf_used_descs(void); -#ifdef ROCKBOX_HAS_LOGF -unsigned char *pcmbuf_get_meminfo(size_t *length); -#endif +unsigned int pcmbuf_get_position_key(void); /* Misc */ void pcmbuf_fade(bool fade, bool in); @@ -69,6 +79,5 @@ bool pcmbuf_fading(void); void pcmbuf_soft_mode(bool shhh); bool pcmbuf_is_lowdata(void); void pcmbuf_set_low_latency(bool state); -unsigned long pcmbuf_get_latency(void); #endif -- cgit v1.2.3