diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2019-07-21 09:03:38 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2019-08-06 13:37:20 +0200 |
commit | e6b03ffa823aa2385c989fac9662bfd19679c5de (patch) | |
tree | 8880445b6be039a5dc558ce48a61b6bf582ad81c /apps/talk.c | |
parent | 2d70fdcd8c6f4fc30c06d07299d6b499389456b8 (diff) | |
download | rockbox-e6b03ffa823aa2385c989fac9662bfd19679c5de.tar.gz rockbox-e6b03ffa823aa2385c989fac9662bfd19679c5de.zip |
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/talk.c')
-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 | } |