mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
Fundamentally rewrite much of the audio DSP.
Creates a standard buffer passing, local data passing and messaging system for processing stages. Stages can be moved to their own source files to reduce clutter and ease assimilation of new ones. dsp.c becomes dsp_core.c which supports an engine and framework for effects. Formats and change notifications are passed along with the buffer so that they arrive at the correct time at each stage in the chain regardless of the internal delays of a particular one. Removes restrictions on the number of samples that can be processed at a time and it pays attention to destination buffer size restrictions without having to limit input count, which also allows pcmbuf to remain fuller and safely set its own buffer limits as it sees fit. There is no longer a need to query input/output counts given a certain number of input samples; just give it the sizes of the source and destination buffers. Works in harmony with stages that are not deterministic in terms of sample input/output ratio (like both resamplers but most notably the timestretch). As a result it fixes quirks with timestretch hanging up with certain settings and it now operates properly throughout its full settings range. Change-Id: Ib206ec78f6f6c79259c5af9009fe021d68be9734 Reviewed-on: http://gerrit.rockbox.org/200 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
This commit is contained in:
parent
c9c1349773
commit
c9bcbe202d
56 changed files with 4823 additions and 2998 deletions
|
|
@ -47,16 +47,23 @@
|
|||
smaller math - must be < 65536 bytes */
|
||||
#define PCMBUF_CHUNK_SIZE 8192u
|
||||
|
||||
/* Massive size is a nasty temp fix */
|
||||
#define PCMBUF_GUARD_SIZE (1024u*12*((NATIVE_FREQUENCY+7999)/8000))
|
||||
/* Small guard buf to give decent space near end */
|
||||
#define PCMBUF_GUARD_SIZE (PCMBUF_CHUNK_SIZE / 8)
|
||||
|
||||
/* Mnemonics for common data commit thresholds */
|
||||
#define COMMIT_CHUNKS PCMBUF_CHUNK_SIZE
|
||||
#define COMMIT_ALL_DATA 1u
|
||||
|
||||
/* Size of the crossfade buffer where codec data is written to be faded
|
||||
on commit */
|
||||
#define CROSSFADE_BUFSIZE 8192u
|
||||
/* Size of the crossfade buffer where codec data is written to be faded
|
||||
on commit */
|
||||
#define CROSSFADE_BUFSIZE PCMBUF_CHUNK_SIZE
|
||||
|
||||
/* Maximum contiguous space that PCM buffer will allow (to avoid excessive
|
||||
draining between inserts and observe low-latency mode) */
|
||||
#define PCMBUF_MAX_BUFFER (PCMBUF_CHUNK_SIZE * 4)
|
||||
|
||||
/* Forced buffer insert constraint can thus be from 1KB to 32KB using 8KB
|
||||
chunks */
|
||||
|
||||
/* Return data level in 1/4-second increments */
|
||||
#define DATA_LEVEL(quarter_secs) (NATIVE_FREQUENCY * (quarter_secs))
|
||||
|
|
@ -383,7 +390,11 @@ void * pcmbuf_request_buffer(int *count)
|
|||
/* If crossfade has begun, put the new track samples in crossfade_buffer */
|
||||
if (crossfade_status != CROSSFADE_INACTIVE && size > CROSSFADE_BUFSIZE)
|
||||
size = CROSSFADE_BUFSIZE;
|
||||
#endif
|
||||
else
|
||||
#endif /* HAVE_CROSSFADE */
|
||||
|
||||
if (size > PCMBUF_MAX_BUFFER)
|
||||
size = PCMBUF_MAX_BUFFER; /* constrain */
|
||||
|
||||
enum channel_status status = mixer_channel_status(PCM_MIXER_CHAN_PLAYBACK);
|
||||
size_t remaining = pcmbuf_unplayed_bytes();
|
||||
|
|
@ -432,11 +443,22 @@ void * pcmbuf_request_buffer(int *count)
|
|||
pcmbuf_play_start();
|
||||
}
|
||||
|
||||
void *buf =
|
||||
void *buf;
|
||||
|
||||
#ifdef HAVE_CROSSFADE
|
||||
crossfade_status != CROSSFADE_INACTIVE ? crossfade_buffer :
|
||||
if (crossfade_status != CROSSFADE_INACTIVE)
|
||||
{
|
||||
buf = crossfade_buffer; /* always CROSSFADE_BUFSIZE */
|
||||
}
|
||||
else
|
||||
#endif
|
||||
get_write_buffer(&size);
|
||||
{
|
||||
/* Give the maximum amount available if there's more */
|
||||
if (size + PCMBUF_CHUNK_SIZE < freespace)
|
||||
size = freespace - PCMBUF_CHUNK_SIZE;
|
||||
|
||||
buf = get_write_buffer(&size);
|
||||
}
|
||||
|
||||
*count = size / 4;
|
||||
return buf;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue