mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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
This commit is contained in:
parent
e86a7fb77d
commit
7cac18f94b
1 changed files with 6 additions and 7 deletions
|
@ -950,8 +950,8 @@ int bufopen(const char *file, size_t offset, enum data_type type,
|
||||||
h->type = type;
|
h->type = type;
|
||||||
strlcpy(h->path, file, MAX_PATH);
|
strlcpy(h->path, file, MAX_PATH);
|
||||||
|
|
||||||
buf_widx += sizeof(struct mp3entry); /* safe because the handle
|
buf_widx = ringbuf_add(buf_widx, sizeof(struct mp3entry));
|
||||||
can't wrap */
|
|
||||||
h->filerem = sizeof(struct mp3entry);
|
h->filerem = sizeof(struct mp3entry);
|
||||||
|
|
||||||
/* Inform the buffering thread that we added a handle */
|
/* 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,
|
||||||
} else {
|
} else {
|
||||||
h->filesize = rc;
|
h->filesize = rc;
|
||||||
h->available = rc;
|
h->available = rc;
|
||||||
h->widx = buf_widx + rc; /* safe because the data doesn't wrap */
|
buf_widx = ringbuf_add(buf_widx, rc);
|
||||||
buf_widx += rc; /* safe too */
|
h->widx = buf_widx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1107,12 +1107,11 @@ int bufalloc(const void *src, size_t size, enum data_type type)
|
||||||
h->filesize = size;
|
h->filesize = size;
|
||||||
h->offset = 0;
|
h->offset = 0;
|
||||||
h->ridx = buf_widx;
|
h->ridx = buf_widx;
|
||||||
h->widx = buf_widx + size; /* safe because the data doesn't wrap */
|
|
||||||
h->data = buf_widx;
|
h->data = buf_widx;
|
||||||
|
buf_widx = ringbuf_add(buf_widx, size);
|
||||||
|
h->widx = buf_widx;
|
||||||
h->available = size;
|
h->available = size;
|
||||||
h->type = type;
|
h->type = type;
|
||||||
|
|
||||||
buf_widx += size; /* safe too */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&llist_mutex);
|
mutex_unlock(&llist_mutex);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue