From 43907a729bee237e6f52523bd4407af99666c925 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Fri, 12 Oct 2007 23:28:19 +0200 Subject: [PATCH] Add buffered_data() for later use --- apps/buffering.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/buffering.c b/apps/buffering.c index e00758196..4fe082cb7 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -314,9 +314,10 @@ reset_handle : Reset writing position and data buffer of a handle to its rebuffer_handle : Seek to a nonbuffered part of a handle by rebuffering the data shrink_handle : Free buffer space by moving a handle fill_buffer : Call buffer_handle for all handles that have data to buffer -can_add_handle : Indicate whether it's safe to add a handle. +can_add_handle : Indicate whether it's safe to add a handle data_rem : Total amount of data needing to be buffered wasted_space : Total amount of space available for freeing +buffered_data : Total amount of data currently in the buffer These functions are used by the buffering thread to manage buffer space. */ @@ -590,6 +591,17 @@ static size_t wasted_space(void) return ret; } +static size_t buffered_data(void) +{ + size_t ret = 0; + struct memory_handle *m = first_handle; + while (m) { + ret += m->available; + m = m->next; + } + return ret; +} + /* BUFFERING API FUNCTIONS @@ -974,13 +986,5 @@ void buffering_get_debugdata(struct buffering_debug *dbgdata) dbgdata->num_handles = num_handles; dbgdata->data_rem = data_rem(); dbgdata->wasted_space = wasted_space(); - - size_t buffered_data = 0; - struct memory_handle *m = first_handle; - while (m) { - buffered_data += m->available; - m = m->next; - } - - dbgdata->buffered_data = buffered_data; + dbgdata->buffered_data = buffered_data(); } -- 2.11.4.GIT