diff options
Diffstat (limited to 'apps/buffering.c')
-rw-r--r-- | apps/buffering.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index d891382d81..938cc95620 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -190,7 +190,7 @@ static struct event_queue buffering_queue; | |||
190 | static struct queue_sender_list buffering_queue_sender_list; | 190 | static struct queue_sender_list buffering_queue_sender_list; |
191 | 191 | ||
192 | 192 | ||
193 | static void call_buffering_callbacks(const enum callback_event ev, const int value); | 193 | static void call_buffering_callbacks(enum callback_event ev, int value); |
194 | 194 | ||
195 | 195 | ||
196 | /* | 196 | /* |
@@ -225,8 +225,8 @@ buf_ridx == buf_widx means the buffer is empty. | |||
225 | only potential side effect is to allocate space for the cur_handle | 225 | only potential side effect is to allocate space for the cur_handle |
226 | if it returns NULL. | 226 | if it returns NULL. |
227 | */ | 227 | */ |
228 | static struct memory_handle *add_handle(const size_t data_size, const bool can_wrap, | 228 | static struct memory_handle *add_handle(size_t data_size, bool can_wrap, |
229 | const bool alloc_all) | 229 | bool alloc_all) |
230 | { | 230 | { |
231 | /* gives each handle a unique id */ | 231 | /* gives each handle a unique id */ |
232 | static int cur_handle_id = 0; | 232 | static int cur_handle_id = 0; |
@@ -363,7 +363,7 @@ static bool rm_handle(const struct memory_handle *h) | |||
363 | 363 | ||
364 | /* Return a pointer to the memory handle of given ID. | 364 | /* Return a pointer to the memory handle of given ID. |
365 | NULL if the handle wasn't found */ | 365 | NULL if the handle wasn't found */ |
366 | static struct memory_handle *find_handle(const int handle_id) | 366 | static struct memory_handle *find_handle(int handle_id) |
367 | { | 367 | { |
368 | if (handle_id < 0) | 368 | if (handle_id < 0) |
369 | return NULL; | 369 | return NULL; |
@@ -407,7 +407,7 @@ static struct memory_handle *find_handle(const int handle_id) | |||
407 | found in the linked list for adjustment. This function has no side | 407 | found in the linked list for adjustment. This function has no side |
408 | effects if NULL is returned. */ | 408 | effects if NULL is returned. */ |
409 | static bool move_handle(struct memory_handle **h, size_t *delta, | 409 | static bool move_handle(struct memory_handle **h, size_t *delta, |
410 | const size_t data_size, const bool can_wrap) | 410 | size_t data_size, bool can_wrap) |
411 | { | 411 | { |
412 | struct memory_handle *dest; | 412 | struct memory_handle *dest; |
413 | const struct memory_handle *src; | 413 | const struct memory_handle *src; |
@@ -559,7 +559,7 @@ static inline bool buffer_is_low(void) | |||
559 | 559 | ||
560 | /* Buffer data for the given handle. | 560 | /* Buffer data for the given handle. |
561 | Return whether or not the buffering should continue explicitly. */ | 561 | Return whether or not the buffering should continue explicitly. */ |
562 | static bool buffer_handle(const int handle_id) | 562 | static bool buffer_handle(int handle_id) |
563 | { | 563 | { |
564 | logf("buffer_handle(%d)", handle_id); | 564 | logf("buffer_handle(%d)", handle_id); |
565 | struct memory_handle *h = find_handle(handle_id); | 565 | struct memory_handle *h = find_handle(handle_id); |
@@ -667,7 +667,7 @@ static bool buffer_handle(const int handle_id) | |||
667 | 667 | ||
668 | /* Reset writing position and data buffer of a handle to its current offset. | 668 | /* Reset writing position and data buffer of a handle to its current offset. |
669 | Use this after having set the new offset to use. */ | 669 | Use this after having set the new offset to use. */ |
670 | static void reset_handle(const int handle_id) | 670 | static void reset_handle(int handle_id) |
671 | { | 671 | { |
672 | logf("reset_handle(%d)", handle_id); | 672 | logf("reset_handle(%d)", handle_id); |
673 | 673 | ||
@@ -687,7 +687,7 @@ static void reset_handle(const int handle_id) | |||
687 | } | 687 | } |
688 | 688 | ||
689 | /* Seek to a nonbuffered part of a handle by rebuffering the data. */ | 689 | /* Seek to a nonbuffered part of a handle by rebuffering the data. */ |
690 | static void rebuffer_handle(const int handle_id, const size_t newpos) | 690 | static void rebuffer_handle(int handle_id, size_t newpos) |
691 | { | 691 | { |
692 | struct memory_handle *h = find_handle(handle_id); | 692 | struct memory_handle *h = find_handle(handle_id); |
693 | if (!h) | 693 | if (!h) |
@@ -725,7 +725,7 @@ static void rebuffer_handle(const int handle_id, const size_t newpos) | |||
725 | h->ridx = h->data; | 725 | h->ridx = h->data; |
726 | } | 726 | } |
727 | 727 | ||
728 | static bool close_handle(const int handle_id) | 728 | static bool close_handle(int handle_id) |
729 | { | 729 | { |
730 | struct memory_handle *h = find_handle(handle_id); | 730 | struct memory_handle *h = find_handle(handle_id); |
731 | 731 | ||
@@ -830,7 +830,7 @@ static bool fill_buffer(void) | |||
830 | /* Given a file descriptor to a bitmap file, write the bitmap data to the | 830 | /* Given a file descriptor to a bitmap file, write the bitmap data to the |
831 | buffer, with a struct bitmap and the actual data immediately following. | 831 | buffer, with a struct bitmap and the actual data immediately following. |
832 | Return value is the total size (struct + data). */ | 832 | Return value is the total size (struct + data). */ |
833 | static int load_bitmap(const int fd) | 833 | static int load_bitmap(int fd) |
834 | { | 834 | { |
835 | int rc; | 835 | int rc; |
836 | struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx]; | 836 | struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx]; |
@@ -873,7 +873,7 @@ management functions for all the actual handle management work. | |||
873 | return value: <0 if the file cannot be opened, or one file already | 873 | return value: <0 if the file cannot be opened, or one file already |
874 | queued to be opened, otherwise the handle for the file in the buffer | 874 | queued to be opened, otherwise the handle for the file in the buffer |
875 | */ | 875 | */ |
876 | int bufopen(const char *file, const size_t offset, const enum data_type type) | 876 | int bufopen(const char *file, size_t offset, enum data_type type) |
877 | { | 877 | { |
878 | size_t adjusted_offset = offset; | 878 | size_t adjusted_offset = offset; |
879 | 879 | ||
@@ -957,7 +957,7 @@ int bufopen(const char *file, const size_t offset, const enum data_type type) | |||
957 | requested amount of data can entirely fit in the buffer without wrapping. | 957 | requested amount of data can entirely fit in the buffer without wrapping. |
958 | Return value is the handle id for success or <0 for failure. | 958 | Return value is the handle id for success or <0 for failure. |
959 | */ | 959 | */ |
960 | int bufalloc(const void *src, const size_t size, const enum data_type type) | 960 | int bufalloc(const void *src, size_t size, enum data_type type) |
961 | { | 961 | { |
962 | struct memory_handle *h = add_handle(size, false, true); | 962 | struct memory_handle *h = add_handle(size, false, true); |
963 | 963 | ||
@@ -992,7 +992,7 @@ int bufalloc(const void *src, const size_t size, const enum data_type type) | |||
992 | } | 992 | } |
993 | 993 | ||
994 | /* Close the handle. Return true for success and false for failure */ | 994 | /* Close the handle. Return true for success and false for failure */ |
995 | bool bufclose(const int handle_id) | 995 | bool bufclose(int handle_id) |
996 | { | 996 | { |
997 | logf("bufclose(%d)", handle_id); | 997 | logf("bufclose(%d)", handle_id); |
998 | 998 | ||
@@ -1006,7 +1006,7 @@ bool bufclose(const int handle_id) | |||
1006 | -1 if the handle wasn't found | 1006 | -1 if the handle wasn't found |
1007 | -2 if the new requested position was beyond the end of the file | 1007 | -2 if the new requested position was beyond the end of the file |
1008 | */ | 1008 | */ |
1009 | int bufseek(const int handle_id, const size_t newpos) | 1009 | int bufseek(int handle_id, size_t newpos) |
1010 | { | 1010 | { |
1011 | struct memory_handle *h = find_handle(handle_id); | 1011 | struct memory_handle *h = find_handle(handle_id); |
1012 | if (!h) | 1012 | if (!h) |
@@ -1028,7 +1028,7 @@ int bufseek(const int handle_id, const size_t newpos) | |||
1028 | 1028 | ||
1029 | /* Advance the reading index in a handle (relatively to its current position). | 1029 | /* Advance the reading index in a handle (relatively to its current position). |
1030 | Return 0 for success and < 0 for failure */ | 1030 | Return 0 for success and < 0 for failure */ |
1031 | int bufadvance(const int handle_id, const off_t offset) | 1031 | int bufadvance(int handle_id, off_t offset) |
1032 | { | 1032 | { |
1033 | const struct memory_handle *h = find_handle(handle_id); | 1033 | const struct memory_handle *h = find_handle(handle_id); |
1034 | if (!h) | 1034 | if (!h) |
@@ -1042,8 +1042,8 @@ int bufadvance(const int handle_id, const off_t offset) | |||
1042 | * actual amount of data available for reading. This function explicitly | 1042 | * actual amount of data available for reading. This function explicitly |
1043 | * does not check the validity of the input handle. It does do range checks | 1043 | * does not check the validity of the input handle. It does do range checks |
1044 | * on size and returns a valid (and explicit) amount of data for reading */ | 1044 | * on size and returns a valid (and explicit) amount of data for reading */ |
1045 | static struct memory_handle *prep_bufdata(const int handle_id, size_t *size, | 1045 | static struct memory_handle *prep_bufdata(int handle_id, size_t *size, |
1046 | const bool guardbuf_limit) | 1046 | bool guardbuf_limit) |
1047 | { | 1047 | { |
1048 | struct memory_handle *h = find_handle(handle_id); | 1048 | struct memory_handle *h = find_handle(handle_id); |
1049 | if (!h) | 1049 | if (!h) |
@@ -1096,7 +1096,7 @@ static struct memory_handle *prep_bufdata(const int handle_id, size_t *size, | |||
1096 | Return the number of bytes copied or < 0 for failure (handle not found). | 1096 | Return the number of bytes copied or < 0 for failure (handle not found). |
1097 | The caller is blocked until the requested amount of data is available. | 1097 | The caller is blocked until the requested amount of data is available. |
1098 | */ | 1098 | */ |
1099 | ssize_t bufread(const int handle_id, const size_t size, void *dest) | 1099 | ssize_t bufread(int handle_id, size_t size, void *dest) |
1100 | { | 1100 | { |
1101 | const struct memory_handle *h; | 1101 | const struct memory_handle *h; |
1102 | size_t adjusted_size = size; | 1102 | size_t adjusted_size = size; |
@@ -1129,7 +1129,7 @@ ssize_t bufread(const int handle_id, const size_t size, void *dest) | |||
1129 | The guard buffer may be used to provide the requested size. This means it's | 1129 | The guard buffer may be used to provide the requested size. This means it's |
1130 | unsafe to request more than the size of the guard buffer. | 1130 | unsafe to request more than the size of the guard buffer. |
1131 | */ | 1131 | */ |
1132 | ssize_t bufgetdata(const int handle_id, const size_t size, void **data) | 1132 | ssize_t bufgetdata(int handle_id, size_t size, void **data) |
1133 | { | 1133 | { |
1134 | const struct memory_handle *h; | 1134 | const struct memory_handle *h; |
1135 | size_t adjusted_size = size; | 1135 | size_t adjusted_size = size; |
@@ -1154,7 +1154,7 @@ ssize_t bufgetdata(const int handle_id, const size_t size, void **data) | |||
1154 | return adjusted_size; | 1154 | return adjusted_size; |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | ssize_t bufgettail(const int handle_id, const size_t size, void **data) | 1157 | ssize_t bufgettail(int handle_id, size_t size, void **data) |
1158 | { | 1158 | { |
1159 | size_t tidx; | 1159 | size_t tidx; |
1160 | 1160 | ||
@@ -1184,7 +1184,7 @@ ssize_t bufgettail(const int handle_id, const size_t size, void **data) | |||
1184 | return size; | 1184 | return size; |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | ssize_t bufcuttail(const int handle_id, const size_t size) | 1187 | ssize_t bufcuttail(int handle_id, size_t size) |
1188 | { | 1188 | { |
1189 | struct memory_handle *h; | 1189 | struct memory_handle *h; |
1190 | size_t adjusted_size = size; | 1190 | size_t adjusted_size = size; |
@@ -1228,7 +1228,7 @@ management functions for all the actual handle management work. | |||
1228 | */ | 1228 | */ |
1229 | 1229 | ||
1230 | /* Get a handle offset from a pointer */ | 1230 | /* Get a handle offset from a pointer */ |
1231 | ssize_t buf_get_offset(const int handle_id, void *ptr) | 1231 | ssize_t buf_get_offset(int handle_id, void *ptr) |
1232 | { | 1232 | { |
1233 | const struct memory_handle *h = find_handle(handle_id); | 1233 | const struct memory_handle *h = find_handle(handle_id); |
1234 | if (!h) | 1234 | if (!h) |
@@ -1237,7 +1237,7 @@ ssize_t buf_get_offset(const int handle_id, void *ptr) | |||
1237 | return (size_t)ptr - (size_t)&buffer[h->ridx]; | 1237 | return (size_t)ptr - (size_t)&buffer[h->ridx]; |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | ssize_t buf_handle_offset(const int handle_id) | 1240 | ssize_t buf_handle_offset(int handle_id) |
1241 | { | 1241 | { |
1242 | const struct memory_handle *h = find_handle(handle_id); | 1242 | const struct memory_handle *h = find_handle(handle_id); |
1243 | if (!h) | 1243 | if (!h) |
@@ -1245,13 +1245,13 @@ ssize_t buf_handle_offset(const int handle_id) | |||
1245 | return h->offset; | 1245 | return h->offset; |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | void buf_request_buffer_handle(const int handle_id) | 1248 | void buf_request_buffer_handle(int handle_id) |
1249 | { | 1249 | { |
1250 | LOGFQUEUE("buffering >| Q_START_FILL %d",handle_id); | 1250 | LOGFQUEUE("buffering >| Q_START_FILL %d",handle_id); |
1251 | queue_send(&buffering_queue, Q_START_FILL, handle_id); | 1251 | queue_send(&buffering_queue, Q_START_FILL, handle_id); |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | void buf_set_base_handle(const int handle_id) | 1254 | void buf_set_base_handle(int handle_id) |
1255 | { | 1255 | { |
1256 | LOGFQUEUE("buffering > Q_BASE_HANDLE %d", handle_id); | 1256 | LOGFQUEUE("buffering > Q_BASE_HANDLE %d", handle_id); |
1257 | queue_post(&buffering_queue, Q_BASE_HANDLE, handle_id); | 1257 | queue_post(&buffering_queue, Q_BASE_HANDLE, handle_id); |
@@ -1263,13 +1263,13 @@ size_t buf_used(void) | |||
1263 | return BUF_USED; | 1263 | return BUF_USED; |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | void buf_set_watermark(const size_t bytes) | 1266 | void buf_set_watermark(size_t bytes) |
1267 | { | 1267 | { |
1268 | LOGFQUEUE("buffering > Q_SET_WATERMARK %ld", (long)bytes); | 1268 | LOGFQUEUE("buffering > Q_SET_WATERMARK %ld", (long)bytes); |
1269 | queue_post(&buffering_queue, Q_SET_WATERMARK, bytes); | 1269 | queue_post(&buffering_queue, Q_SET_WATERMARK, bytes); |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | bool register_buffering_callback(const buffering_callback func) | 1272 | bool register_buffering_callback(buffering_callback func) |
1273 | { | 1273 | { |
1274 | int i; | 1274 | int i; |
1275 | if (buffer_callback_count >= MAX_BUF_CALLBACKS) | 1275 | if (buffer_callback_count >= MAX_BUF_CALLBACKS) |
@@ -1288,7 +1288,7 @@ bool register_buffering_callback(const buffering_callback func) | |||
1288 | return false; | 1288 | return false; |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | void unregister_buffering_callback(const buffering_callback func) | 1291 | void unregister_buffering_callback(buffering_callback func) |
1292 | { | 1292 | { |
1293 | int i; | 1293 | int i; |
1294 | for (i = 0; i < MAX_BUF_CALLBACKS; i++) | 1294 | for (i = 0; i < MAX_BUF_CALLBACKS; i++) |
@@ -1302,7 +1302,7 @@ void unregister_buffering_callback(const buffering_callback func) | |||
1302 | return; | 1302 | return; |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | static void call_buffering_callbacks(const enum callback_event ev, const int value) | 1305 | static void call_buffering_callbacks(enum callback_event ev, int value) |
1306 | { | 1306 | { |
1307 | logf("call_buffering_callbacks()"); | 1307 | logf("call_buffering_callbacks()"); |
1308 | int i; | 1308 | int i; |
@@ -1471,7 +1471,7 @@ void buffering_init(void) | |||
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | /* Initialise the buffering subsystem */ | 1473 | /* Initialise the buffering subsystem */ |
1474 | bool buffering_reset(char *buf, const size_t buflen) | 1474 | bool buffering_reset(char *buf, size_t buflen) |
1475 | { | 1475 | { |
1476 | if (!buf || !buflen) | 1476 | if (!buf || !buflen) |
1477 | return false; | 1477 | return false; |