diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2006-11-06 18:07:30 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2006-11-06 18:07:30 +0000 |
commit | 0f5cb94aa4a334366a746fcbb22f3335ca413265 (patch) | |
tree | 8f89a96628c1810d51ee9816daf78edb8c76fcd4 /apps/pcmbuf.c | |
parent | 0b22795e26ee09de14f6ac23219adeda12f2fd5b (diff) |
Big Patch adds primarily: Samplerate and format selection to recording for SWCODEC. Supprort for samplerates changing in playback (just goes with the recording part inseparably). Samplerates to all encoders. Encoders can be configured individually on a menu specific to the encoder in the recording menu. File creation is delayed until flush time to reduce spinups when splitting. Misc: statusbar icons for numbers are individual digits to display any number. Audio buffer was rearranged to maximize memory available to recording and properly reinitialized when trashed. ColdFire PCM stuff moved to target tree to avoid a complicated mess when adding samplerate switching. Some needed API changes and to neaten up growing gap between hardware and software codecs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11452 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/pcmbuf.c')
-rw-r--r-- | apps/pcmbuf.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 44f175c67d..5119d20ebd 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -51,9 +51,11 @@ struct pcmbufdesc void (*callback)(void); }; +#define PCMBUF_DESCS(bufsize) ((bufsize) / PCMBUF_MINAVG_CHUNK) + /* Size of the PCM buffer. */ static size_t pcmbuf_size IDATA_ATTR = 0; - +static char *pcmbuf_bufend IDATA_ATTR; static char *audiobuffer IDATA_ATTR; /* Current audio buffer write index. */ static size_t audiobuffer_pos IDATA_ATTR; @@ -360,7 +362,7 @@ int pcmbuf_used_descs(void) { } int pcmbuf_descs(void) { - return pcmbuf_size / PCMBUF_MINAVG_CHUNK; + return PCMBUF_DESCS(pcmbuf_size); } size_t get_pcmbuf_descsize(void) { @@ -371,28 +373,37 @@ static void pcmbuf_init_pcmbuffers(void) { struct pcmbufdesc *next = pcmbuf_write; next++; pcmbuf_write_end = pcmbuf_write; - while ((void *)next < (void *)audiobufend) { + while ((void *)next < (void *)pcmbuf_bufend) { pcmbuf_write_end->link=next; pcmbuf_write_end=next; next++; } } +bool pcmbuf_is_same_size(size_t bufsize) +{ + /* keep calculations synced with pcmbuf_init */ + bufsize += PCMBUF_MIX_CHUNK * 2 + PCMBUF_DESCS(bufsize); + return bufsize == (size_t)(pcmbuf_bufend - audiobuffer); +} + /* Initialize the pcmbuffer the structure looks like this: - * ...CODECBUFFER|---------PCMBUF---------|GUARDBUF|DESCS| */ -void pcmbuf_init(size_t bufsize) + * ...|---------PCMBUF---------|FADEBUF|VOICEBUF|DESCS|... */ +size_t pcmbuf_init(size_t bufsize, char *bufend) { pcmbuf_size = bufsize; + pcmbuf_bufend = bufend; pcmbuf_descsize = pcmbuf_descs()*sizeof(struct pcmbufdesc); - audiobuffer = (char *)&audiobuf[(audiobufend - audiobuf) - - (pcmbuf_size + PCMBUF_MIX_CHUNK * 2 + pcmbuf_descsize)]; + audiobuffer = pcmbuf_bufend - (pcmbuf_size + PCMBUF_MIX_CHUNK * 2 + + pcmbuf_descsize); fadebuf = &audiobuffer[pcmbuf_size]; voicebuf = &fadebuf[PCMBUF_MIX_CHUNK]; - pcmbuf_write = (struct pcmbufdesc *)(&voicebuf[PCMBUF_MIX_CHUNK]); + pcmbuf_write = (struct pcmbufdesc *)&voicebuf[PCMBUF_MIX_CHUNK]; pcmbuf_init_pcmbuffers(); position_callback = NULL; pcmbuf_event_handler = NULL; pcmbuf_play_stop(); + return pcmbuf_bufend - audiobuffer; } size_t pcmbuf_get_bufsize(void) |