summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-03-13 11:56:51 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-03-13 11:56:51 +0000
commit7cac18f94b512d8541456c2a68f7bfb05a5bd6e8 (patch)
tree1bf4092efef05374c5bbe2376f2d7f835435463b /apps
parente86a7fb77d22cdd593162e91d57012f4ae61cc81 (diff)
downloadrockbox-7cac18f94b512d8541456c2a68f7bfb05a5bd6e8.tar.gz
rockbox-7cac18f94b512d8541456c2a68f7bfb05a5bd6e8.zip
Use ringbuf_add in buffering when incrementing for initial allocation of non-wrapping data. The result of the shortcut would have been wrong if the handle used space exactly to the end of the buffer since buf_widx wouldn't have been properly wrapped to index 0.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29578 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/buffering.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 2949a81a87..0cd81df93a 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -950,8 +950,8 @@ int bufopen(const char *file, size_t offset, enum data_type type,
950 h->type = type; 950 h->type = type;
951 strlcpy(h->path, file, MAX_PATH); 951 strlcpy(h->path, file, MAX_PATH);
952 952
953 buf_widx += sizeof(struct mp3entry); /* safe because the handle 953 buf_widx = ringbuf_add(buf_widx, sizeof(struct mp3entry));
954 can't wrap */ 954
955 h->filerem = sizeof(struct mp3entry); 955 h->filerem = sizeof(struct mp3entry);
956 956
957 /* Inform the buffering thread that we added a handle */ 957 /* Inform the buffering thread that we added a handle */
@@ -1037,8 +1037,8 @@ int bufopen(const char *file, size_t offset, enum data_type type,
1037 } else { 1037 } else {
1038 h->filesize = rc; 1038 h->filesize = rc;
1039 h->available = rc; 1039 h->available = rc;
1040 h->widx = buf_widx + rc; /* safe because the data doesn't wrap */ 1040 buf_widx = ringbuf_add(buf_widx, rc);
1041 buf_widx += rc; /* safe too */ 1041 h->widx = buf_widx;
1042 } 1042 }
1043 } 1043 }
1044 else 1044 else
@@ -1107,12 +1107,11 @@ int bufalloc(const void *src, size_t size, enum data_type type)
1107 h->filesize = size; 1107 h->filesize = size;
1108 h->offset = 0; 1108 h->offset = 0;
1109 h->ridx = buf_widx; 1109 h->ridx = buf_widx;
1110 h->widx = buf_widx + size; /* safe because the data doesn't wrap */
1111 h->data = buf_widx; 1110 h->data = buf_widx;
1111 buf_widx = ringbuf_add(buf_widx, size);
1112 h->widx = buf_widx;
1112 h->available = size; 1113 h->available = size;
1113 h->type = type; 1114 h->type = type;
1114
1115 buf_widx += size; /* safe too */
1116 } 1115 }
1117 1116
1118 mutex_unlock(&llist_mutex); 1117 mutex_unlock(&llist_mutex);