diff options
-rw-r--r-- | apps/talk.c | 22 |
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) | |||
349 | { | 349 | { |
350 | unsigned i; | 350 | unsigned i; |
351 | int oldest = 0; | 351 | int oldest = 0; |
352 | bool thumb = false; | ||
352 | long age, now; | 353 | long age, now; |
353 | struct clip_entry* clipbuf; | 354 | struct clip_entry* clipbuf; |
354 | struct clip_cache_metadata *cc = buflib_get_data(&clip_ctx, metadata_table_handle); | 355 | struct clip_cache_metadata *cc = buflib_get_data(&clip_ctx, metadata_table_handle); |
@@ -356,17 +357,26 @@ static int free_oldest_clip(void) | |||
356 | { | 357 | { |
357 | if (cc[i].handle) | 358 | if (cc[i].handle) |
358 | { | 359 | { |
359 | if ((now - cc[i].tick) > age && cc[i].voice_id != VOICE_PAUSE) | 360 | if (thumb && cc[i].voice_id == VOICEONLY_DELIMITER && (now - cc[i].tick) > age) |
360 | { | 361 | { |
361 | /* find the last-used clip but never consider silence */ | 362 | /* thumb clips are freed first */ |
362 | age = now - cc[i].tick; | 363 | age = now - cc[i].tick; |
363 | oldest = i; | 364 | oldest = i; |
364 | } | 365 | } |
365 | else if (cc[i].voice_id == VOICEONLY_DELIMITER) | 366 | else if (!thumb) |
366 | { | 367 | { |
367 | /* thumb clips are freed immediately */ | 368 | if (cc[i].voice_id == VOICEONLY_DELIMITER) |
368 | oldest = i; | 369 | { |
369 | break; | 370 | age = now - cc[i].tick; |
371 | oldest = i; | ||
372 | thumb = true; | ||
373 | } | ||
374 | else if ((now - cc[i].tick) > age && cc[i].voice_id != VOICE_PAUSE) | ||
375 | { | ||
376 | /* find the last-used clip but never consider silence */ | ||
377 | age = now - cc[i].tick; | ||
378 | oldest = i; | ||
379 | } | ||
370 | } | 380 | } |
371 | } | 381 | } |
372 | } | 382 | } |