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)
|
||||||
|
{
|
||||||
|
/* thumb clips are freed first */
|
||||||
|
age = now - cc[i].tick;
|
||||||
|
oldest = i;
|
||||||
|
}
|
||||||
|
else if (!thumb)
|
||||||
|
{
|
||||||
|
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 */
|
/* find the last-used clip but never consider silence */
|
||||||
age = now - cc[i].tick;
|
age = now - cc[i].tick;
|
||||||
oldest = i;
|
oldest = i;
|
||||||
}
|
}
|
||||||
else if (cc[i].voice_id == VOICEONLY_DELIMITER)
|
|
||||||
{
|
|
||||||
/* thumb clips are freed immediately */
|
|
||||||
oldest = i;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue