From a2a5f8407d0af71946044f4ca1059b75e92abc54 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Fri, 3 Aug 2007 20:41:27 +0200 Subject: [PATCH] A bit of cleaning up. Trimmed long lines and removed useless commented debug output. --- testplugin.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/testplugin.c b/testplugin.c index 1274779..aa51111 100644 --- a/testplugin.c +++ b/testplugin.c @@ -124,7 +124,8 @@ static struct memory_handle *add_handle(size_t *data_size) return NULL; } - struct memory_handle *new_handle = (struct memory_handle *)(&buffer[buf_widx]); + struct memory_handle *new_handle = + (struct memory_handle *)(&buffer[buf_widx]); /* only advance the buffer write index of the size of the struct */ buf_widx = RINGBUF_ADD(buf_widx, sizeof(struct memory_handle)); @@ -191,7 +192,8 @@ static struct memory_handle *find_handle(int handle_id) will either be the same as the last, or the one after the last */ if (cached_handle) { - if (cached_handle_id == handle_id && cached_handle_id == cached_handle->id) + if (cached_handle_id == handle_id && + cached_handle_id == cached_handle->id) return cached_handle; else if (cached_handle->next && (cached_handle->next->id == handle_id)) { @@ -290,8 +292,6 @@ static ssize_t buffer_handle(int handle_id) ssize_t ret = 0; while (h->filerem > 0) { - //DEBUGF("h: %d\n", (void *)h - (void *)buffer); - //DEBUGF("buf_widx: %ld\n", (long)buf_widx); /* max amount to copy */ size_t copy_n = MIN(conf_filechunk, buffer_len - h->widx); @@ -307,7 +307,6 @@ static ssize_t buffer_handle(int handle_id) if (rc < 0) { - //DEBUGF("failed on fd %d at buf_widx = %ld for handle %d\n", h->fd, (long)buf_widx, h->id); DEBUGF("File ended %ld bytes early\n", (long)h->filerem); h->filesize -= h->filerem; h->filerem = 0; @@ -395,10 +394,10 @@ static size_t wasted_space(void) } /* Request a file be buffered - filename: name of the file t open - offset: starting offset to buffer from the file - RETURNS: <0 if the file cannot be opened, or one file already - queued to be opened, otherwise the handle for the file in the buffer + filename: name of the file to open + offset:starting offset to buffer from the file + return value: <0 if the file cannot be opened, or one file already + queued to be opened, otherwise the handle for the file in the buffer */ int bufopen(char *file, size_t offset) { @@ -450,7 +449,7 @@ int bufclose(int handle_id) return 0; } -/* Set the reading index in a handle (relatively to the start of the handle data). +/* Set reading index in handle (relatively to the start of the handle data). Return 0 for success and < 0 for failure */ int bufseek(int handle_id, size_t offset) { @@ -556,7 +555,8 @@ ssize_t bufgetdata(int handle_id, size_t size, unsigned char **data) *data = (unsigned char *)&buffer[h->ridx]; - //DEBUGF("bufgetdata(%d): h->ridx=%ld, ret=%ld\n", handle_id, (long)h->ridx, ret); + /* DEBUGF("bufgetdata(%d): h->ridx=%ld, ret=%ld\n", handle_id, + (long)h->ridx, ret); */ return ret; } @@ -779,7 +779,8 @@ void codec_thread(void) } while (read > 0); if (read >= 0 && total >= 0) { - DEBUGF("read %ld bytes from handle %d\n", total, handles[idx]); + DEBUGF("read %ld bytes from handle %d\n", total, + handles[idx]); } if (read == -2) { @@ -879,8 +880,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) } } - if (data_rem() > 0 && BUF_USED < buffer_len/4 && disk_is_spinning()) { - DEBUGF("%ld bytes left to buffer and the buffer is running low\n", data_rem()); + if (data_rem() > 0 && BUF_USED < buffer_len/4 && + disk_is_spinning()) + { + DEBUGF("%ld bytes left to buffer and the buffer is low\n", + data_rem()); fill_buffer(); } else { rb->sleep(HZ/2); -- 2.11.4.GIT