From 0f5cb94aa4a334366a746fcbb22f3335ca413265 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 6 Nov 2006 18:07:30 +0000 Subject: 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 --- apps/talk.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'apps/talk.c') diff --git a/apps/talk.c b/apps/talk.c index d81aa08..018f6ed 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -46,13 +46,17 @@ MASCODEC | MASCODEC | SWCODEC (playing) | (stopped) | - audiobuf-----------+-----------+----------- + audiobuf-----------+-----------+------------ audio | voice | thumbnail - |-----------|----------- filebuf + |-----------|------------ | thumbnail | voice - | |----------- + | |------------ + | | filebuf + | |------------ | | audio - audiobufend----------+-----------+----------- + | |------------ + | | codec swap + audiobufend----------+-----------+------------ SWCODEC allocates dedicated buffers, MASCODEC reuses audiobuf. */ @@ -102,7 +106,7 @@ struct queue_entry /* one entry of the internal queue */ /***************** Globals *****************/ -static unsigned char* p_thumbnail; /* buffer for thumbnail */ +static unsigned char* p_thumbnail = NULL; /* buffer for thumbnail */ static long size_for_thumbnail; /* leftover buffer size for it */ static struct voicefile* p_voicefile; /* loaded voicefile */ static bool has_voicefile; /* a voicefile file is present */ @@ -479,11 +483,14 @@ static void reset_state(void) queue_write = queue_read = 0; /* reset the queue */ p_voicefile = NULL; /* indicate no voicefile (trashed) */ #if CONFIG_CODEC == SWCODEC - /* Allocate a dedicated thumbnail buffer */ - size_for_thumbnail = audiobufend - audiobuf; - if (size_for_thumbnail > MAX_THUMBNAIL_BUFSIZE) - size_for_thumbnail = MAX_THUMBNAIL_BUFSIZE; - p_thumbnail = buffer_alloc(size_for_thumbnail); + /* Allocate a dedicated thumbnail buffer - once */ + if (p_thumbnail == NULL) + { + size_for_thumbnail = audiobufend - audiobuf; + if (size_for_thumbnail > MAX_THUMBNAIL_BUFSIZE) + size_for_thumbnail = MAX_THUMBNAIL_BUFSIZE; + p_thumbnail = buffer_alloc(size_for_thumbnail); + } #else /* Just use the audiobuf, without allocating anything */ p_thumbnail = audiobuf; -- cgit v1.1