summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-07-21 09:03:38 -0400
committerSolomon Peachy <pizza@shaftnet.org>2019-08-06 13:37:20 +0200
commite6b03ffa823aa2385c989fac9662bfd19679c5de (patch)
tree8880445b6be039a5dc558ce48a61b6bf582ad81c /apps
parent2d70fdcd8c6f4fc30c06d07299d6b499389456b8 (diff)
Respect age when freeing thumbnails from clip cache.
Otherwise they could get freed while queued. Patch by Igor Poretsky Change-Id: I436b074d81a85cfeb68a07a17320a3c9c0a43e1e
Diffstat (limited to 'apps')
-rw-r--r--apps/talk.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 03da4897c8..fb16e80417 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -349,6 +349,7 @@ static int free_oldest_clip(void)
{
unsigned i;
int oldest = 0;
+ bool thumb = false;
long age, now;
struct clip_entry* clipbuf;
struct clip_cache_metadata *cc = buflib_get_data(&clip_ctx, metadata_table_handle);
@@ -356,17 +357,26 @@ static int free_oldest_clip(void)
{
if (cc[i].handle)
{
- if ((now - cc[i].tick) > age && cc[i].voice_id != VOICE_PAUSE)
+ if (thumb && cc[i].voice_id == VOICEONLY_DELIMITER && (now - cc[i].tick) > age)
{
- /* find the last-used clip but never consider silence */
+ /* thumb clips are freed first */
age = now - cc[i].tick;
oldest = i;
}
- else if (cc[i].voice_id == VOICEONLY_DELIMITER)
+ else if (!thumb)
{
- /* thumb clips are freed immediately */
- oldest = i;
- break;
+ if (cc[i].voice_id == VOICEONLY_DELIMITER)
+ {
+ age = now - cc[i].tick;
+ oldest = i;
+ thumb = true;
+ }
+ else if ((now - cc[i].tick) > age && cc[i].voice_id != VOICE_PAUSE)
+ {
+ /* find the last-used clip but never consider silence */
+ age = now - cc[i].tick;
+ oldest = i;
+ }
}
}
}