diff options
Diffstat (limited to 'src/cache')
| -rw-r--r-- | src/cache/entry.c | 1 | ||||
| -rw-r--r-- | src/cache/handle.c | 15 | ||||
| -rw-r--r-- | src/cache/handle.h | 2 | ||||
| -rw-r--r-- | src/cache/threaded_waits.c | 2 |
4 files changed, 4 insertions, 16 deletions
diff --git a/src/cache/entry.c b/src/cache/entry.c index c7fb8d2..8930ea0 100644 --- a/src/cache/entry.c +++ b/src/cache/entry.c @@ -6,7 +6,6 @@ bool cch_entry_get_handle(struct cch_entry *entry, struct cch_handle *handle) { handle->entry = entry; handle->pointer = 0; - handle->prev_pointer = 0; nn_cond_init(&handle->wait.cond); nn_mutex_init(&handle->wait.mutex); handle->wait.disabled = false; diff --git a/src/cache/handle.c b/src/cache/handle.c index 98bc2fa..10d1992 100644 --- a/src/cache/handle.c +++ b/src/cache/handle.c @@ -1,6 +1,5 @@ #include <al/lib.h> #include <al/log.h> -#include <al/random.h> #include "../codec/codec.h" @@ -23,9 +22,7 @@ s32 cch_handle_read(struct cch_handle *handle, u8 *buf, s32 size) // filesize < 0: Size is yet to be evaluated and we can wait on it. // filesize = 0: Size is explicitly unknown. off_t filesize = cch_entry_get_size(handle->entry); - if (size < 0) { - filesize = wait_for_size(handle, handler); - } + if (size < 0) filesize = wait_for_size(handle, handler); if (filesize > 0) { if (handle->pointer >= filesize) return CAMU_ERR_EOF; if (handle->pointer + size >= filesize) { @@ -58,13 +55,9 @@ off_t cch_handle_seek(struct cch_handle *handle, off_t offset, s32 whence) { struct cch_handler *handler = handle->entry->handler; off_t filesize = cch_entry_get_size(handle->entry); - if (filesize < 0) { - filesize = wait_for_size(handle, handler); - } + if (filesize < 0) filesize = wait_for_size(handle, handler); if (filesize <= 0) return -1; - if (whence == CAMU_SEEK_SIZE) { - return filesize; - } + if (whence == CAMU_SEEK_SIZE) return filesize; switch (whence) { case SEEK_SET: if (offset >= filesize || offset < 0) { @@ -79,13 +72,11 @@ off_t cch_handle_seek(struct cch_handle *handle, off_t offset, s32 whence) handle->pointer += offset; break; case SEEK_END: - handle->prev_pointer = handle->pointer; handle->pointer = filesize + offset; break; default: return -1; } - handle->prev_pointer = -1; return handle->pointer; } diff --git a/src/cache/handle.h b/src/cache/handle.h index 007e04d..0052c02 100644 --- a/src/cache/handle.h +++ b/src/cache/handle.h @@ -9,8 +9,6 @@ struct cch_entry; struct cch_handle { struct cch_entry *entry; off_t pointer; - // Set after a seek_end and reset after any seek_cur or seek_set. - off_t prev_pointer; struct cch_handler_wait wait; }; diff --git a/src/cache/threaded_waits.c b/src/cache/threaded_waits.c index 5990783..ae43ae9 100644 --- a/src/cache/threaded_waits.c +++ b/src/cache/threaded_waits.c @@ -39,12 +39,12 @@ bool cch_threaded_wait_for_range(struct cch_handler *handler, struct cch_backing nn_mutex_unlock(&handler->mutex); return false; } - nn_mutex_unlock(&wait->mutex); nn_mutex_lock(&handler->mutex); if (wait->disabled) { al_array_remove(handler->waits, wait); canceled = true; } + nn_mutex_unlock(&wait->mutex); } nn_mutex_unlock(&handler->mutex); return !canceled; |