diff options
Diffstat (limited to 'apps/talk.c')
-rw-r--r-- | apps/talk.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/apps/talk.c b/apps/talk.c index 9e92a11b51..73191c22c3 100644 --- a/apps/talk.c +++ b/apps/talk.c | |||
@@ -377,7 +377,7 @@ static ssize_t read_clip_data(int fd, int index, int clip_handle) | |||
377 | { | 377 | { |
378 | struct clip_entry* clipbuf; | 378 | struct clip_entry* clipbuf; |
379 | size_t clipsize; | 379 | size_t clipsize; |
380 | ssize_t ret; | 380 | ssize_t ret = -1; |
381 | 381 | ||
382 | if (fd < 0) | 382 | if (fd < 0) |
383 | { | 383 | { |
@@ -388,8 +388,8 @@ static ssize_t read_clip_data(int fd, int index, int clip_handle) | |||
388 | clipbuf = core_get_data(index_handle); | 388 | clipbuf = core_get_data(index_handle); |
389 | /* this must not be called with LOADED_MASK set in clipsize */ | 389 | /* this must not be called with LOADED_MASK set in clipsize */ |
390 | clipsize = clipbuf[index].size; | 390 | clipsize = clipbuf[index].size; |
391 | lseek(fd, clipbuf[index].offset, SEEK_SET); | 391 | if (lseek(fd, clipbuf[index].offset, SEEK_SET) >= 0) |
392 | ret = read_to_handle_ex(fd, &clip_ctx, clip_handle, 0, clipsize); | 392 | ret = read_to_handle_ex(fd, &clip_ctx, clip_handle, 0, clipsize); |
393 | 393 | ||
394 | if (ret < 0 || clipsize != (size_t)ret) | 394 | if (ret < 0 || clipsize != (size_t)ret) |
395 | { | 395 | { |
@@ -978,7 +978,8 @@ static int _talk_file(const char* filename, | |||
978 | { | 978 | { |
979 | int fd; | 979 | int fd; |
980 | int size; | 980 | int size; |
981 | int handle, oldest = -1; | 981 | int handle = -1; |
982 | int oldest = -1; | ||
982 | 983 | ||
983 | /* reload needed? */ | 984 | /* reload needed? */ |
984 | if (talk_temp_disable_count > 0) | 985 | if (talk_temp_disable_count > 0) |
@@ -1005,11 +1006,15 @@ static int _talk_file(const char* filename, | |||
1005 | } | 1006 | } |
1006 | size = filesize(fd); | 1007 | size = filesize(fd); |
1007 | 1008 | ||
1008 | /* free clips from cache until this one succeeds to allocate */ | 1009 | if (size > 0) |
1009 | while ((handle = buflib_alloc(&clip_ctx, size)) < 0) | 1010 | { |
1010 | oldest = free_oldest_clip(); | 1011 | /* free clips from cache until this one succeeds to allocate */ |
1012 | while ((handle = buflib_alloc(&clip_ctx, size)) < 0) | ||
1013 | oldest = free_oldest_clip(); | ||
1014 | |||
1015 | size = read_to_handle_ex(fd, &clip_ctx, handle, 0, size); | ||
1016 | } | ||
1011 | 1017 | ||
1012 | size = read_to_handle_ex(fd, &clip_ctx, handle, 0, size); | ||
1013 | close(fd); | 1018 | close(fd); |
1014 | 1019 | ||
1015 | /* ToDo: find audio, skip ID headers and trailers */ | 1020 | /* ToDo: find audio, skip ID headers and trailers */ |