Respect age when freeing thumbnails from clip cache.
Otherwise they could get freed while queued. Patch by Igor Poretsky Change-Id: I436b074d81a85cfeb68a07a17320a3c9c0a43e1e
This commit is contained in:
parent
2d70fdcd8c
commit
e6b03ffa82
1 changed files with 16 additions and 6 deletions
22
apps/talk.c
22
apps/talk.c
|
@ -349,6 +349,7 @@ static int free_oldest_clip(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int oldest = 0;
|
int oldest = 0;
|
||||||
|
bool thumb = false;
|
||||||
long age, now;
|
long age, now;
|
||||||
struct clip_entry* clipbuf;
|
struct clip_entry* clipbuf;
|
||||||
struct clip_cache_metadata *cc = buflib_get_data(&clip_ctx, metadata_table_handle);
|
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 (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;
|
age = now - cc[i].tick;
|
||||||
oldest = i;
|
oldest = i;
|
||||||
}
|
}
|
||||||
else if (cc[i].voice_id == VOICEONLY_DELIMITER)
|
else if (!thumb)
|
||||||
{
|
{
|
||||||
/* thumb clips are freed immediately */
|
if (cc[i].voice_id == VOICEONLY_DELIMITER)
|
||||||
oldest = i;
|
{
|
||||||
break;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue