* \return The same value which was passed during creation time to
* btr_pool_new().
*/
-size_t btr_pool_size(struct btr_pool *btrp)
+size_t btr_pool_size(const struct btr_pool *btrp)
{
return btrp->area_end - btrp->area_start;
}
-static size_t btr_pool_filled(struct btr_pool *btrp)
+static size_t btr_pool_filled(const struct btr_pool *btrp)
{
if (!btrp->whead)
return btr_pool_size(btrp);
* the largest contiguous buffer that can currently be allocated from the
* buffer pool.
*/
-size_t btr_pool_unused(struct btr_pool *btrp)
+size_t btr_pool_unused(const struct btr_pool *btrp)
{
return btr_pool_size(btrp) - btr_pool_filled(btrp);
}
* Return maximal size available for one read. This is
* smaller than the value returned by btr_pool_unused().
*/
-static size_t btr_pool_available(struct btr_pool *btrp)
+static size_t btr_pool_available(const struct btr_pool *btrp)
{
if (!btrp->whead)
return 0;
* \return The maximal amount of bytes that may be written to the returned
* buffer.
*/
-size_t btr_pool_get_buffer(struct btr_pool *btrp, char **result)
+size_t btr_pool_get_buffer(const struct btr_pool *btrp, char **result)
{
if (result)
*result = btrp->whead;
* consists of two buffers. If this function returns the value n, then n
* elements of \a iov are initialized.
*/
-int btr_pool_get_buffers(struct btr_pool *btrp, struct iovec iov[2])
+int btr_pool_get_buffers(const struct btr_pool *btrp, struct iovec iov[2])
{
size_t sz, unused;
char *buf;
free(btrb->buf);
}
-static struct btr_buffer_reference *get_first_input_br(struct btr_node *btrn)
+static struct btr_buffer_reference *get_first_input_br(const struct btr_node *btrn)
{
if (list_empty(&btrn->input_queue))
return NULL;
struct btr_buffer_reference, node);
}
-static struct btr_buffer_reference *get_last_input_br(struct btr_node *btrn)
+static struct btr_buffer_reference *get_last_input_br(const struct btr_node *btrn)
{
if (list_empty(&btrn->input_queue))
return NULL;
*
* \return True if this node has no children. False otherwise.
*/
-static bool btr_no_children(struct btr_node *btrn)
+static bool btr_no_children(const struct btr_node *btrn)
{
return list_empty(&btrn->children);
}
* After a (non-leaf) node was removed removed from the tree, the function
* returns true for all child nodes.
*/
-bool btr_no_parent(struct btr_node *btrn)
+bool btr_no_parent(const struct btr_node *btrn)
{
return !btrn->parent;
}
*
* \return True if \a btrn has no siblings.
*/
-bool btr_inplace_ok(struct btr_node *btrn)
+bool btr_inplace_ok(const struct btr_node *btrn)
{
struct btr_buffer_reference *br;
FOR_EACH_BUFFER_REF(br, btrn) {
return true;
}
-static inline size_t br_available_bytes(struct btr_buffer_reference *br)
+static inline size_t br_available_bytes(const struct btr_buffer_reference *br)
{
return br->btrb->size - br->consumed;
}
-static size_t btr_get_buffer_by_reference(struct btr_buffer_reference *br, char **buf)
+static size_t btr_get_buffer_by_reference(const struct btr_buffer_reference *br,
+ char **buf)
{
if (buf)
*buf = br->btrb->buf + br->consumed;
* to by \a btrn, the function returns zero and the value of \a bufp is
* undefined.
*/
-size_t btr_next_buffer_omit(struct btr_node *btrn, size_t omit, char **bufp)
+size_t btr_next_buffer_omit(const struct btr_node *btrn, size_t omit,
+ char **bufp)
{
struct btr_buffer_reference *br;
size_t wrap_count, sz, rv = 0;
* The call of this function is is equivalent to calling \ref
* btr_next_buffer_omit() with an \a omit value of zero.
*/
-size_t btr_next_buffer(struct btr_node *btrn, char **bufp)
+size_t btr_next_buffer(const struct btr_node *btrn, char **bufp)
{
return btr_next_buffer_omit(btrn, 0, bufp);
}
* This simply iterates over all buffer references in the input queue and
* returns the sum of the sizes of all references.
*/
-size_t btr_get_input_queue_size(struct btr_node *btrn)
+size_t btr_get_input_queue_size(const struct btr_node *btrn)
{
struct btr_buffer_reference *br;
size_t size = 0, wrap_consumed = 0;
return size;
}
-static bool min_iqs_available(size_t min_iqs, struct btr_node *btrn)
+static bool min_iqs_available(size_t min_iqs, const struct btr_node *btrn)
{
struct btr_buffer_reference *br;
size_t have = 0, wrap_consumed = 0;
* \return This function iterates over all children of the given node and
* returns the size of the largest input queue.
*/
-size_t btr_get_output_queue_size(struct btr_node *btrn)
+size_t btr_get_output_queue_size(const struct btr_node *btrn)
{
size_t max_size = 0;
struct btr_node *ch;
*
* \sa \ref receiver::execute, \ref filter::execute, \ref writer::execute.
*/
-int btr_exec_up(struct btr_node *btrn, const char *command, char **value_result)
+int btr_exec_up(const struct btr_node *btrn, const char *command, char **value_result)
{
int ret;
*
* \sa \ref btr_new_node(), struct \ref btr_node_description.
*/
-void *btr_context(struct btr_node *btrn)
+void *btr_context(const struct btr_node *btrn)
{
return btrn->context;
}
-static bool need_buffer_pool_merge(struct btr_node *btrn)
+static bool need_buffer_pool_merge(const struct btr_node *btrn)
{
struct btr_buffer_reference *br = get_first_input_br(btrn);
}
}
-static bool btr_eof(struct btr_node *btrn)
+static bool btr_eof(const struct btr_node *btrn)
{
char *buf;
size_t len = btr_next_buffer(btrn, &buf);
return (len == 0 && btr_no_parent(btrn));
}
-static void log_tree_recursively(struct btr_node *btrn, int loglevel, int depth)
+static void log_tree_recursively(const struct btr_node *btrn, int loglevel, int depth)
{
struct btr_node *ch;
const char spaces[] = " ", *space = spaces + 16 - depth;
* \param btrn Start logging at this node.
* \param loglevel Set severity with which the tree should be logged.
*/
-void btr_log_tree(struct btr_node *btrn, int loglevel)
+void btr_log_tree(const struct btr_node *btrn, int loglevel)
{
return log_tree_recursively(btrn, loglevel, 0);
}
* btrn, the function also returns zero in order to bound the memory usage of
* the buffer tree.
*/
-int btr_node_status(struct btr_node *btrn, size_t min_iqs,
+int btr_node_status(const struct btr_node *btrn, size_t min_iqs,
enum btr_node_type type)
{
if (type != BTR_NT_LEAF && btr_no_children(btrn))
*
* Mainly useful for the time display of para_audiod.
*/
-void btr_get_node_start(struct btr_node *btrn, struct timeval *tv)
+void btr_get_node_start(const struct btr_node *btrn, struct timeval *tv)
{
*tv = btrn->start;
}
* \return The parent of \a btrn, or \p NULL if \a btrn is the
* root node of the buffer tree.
*/
-struct btr_node *btr_parent(struct btr_node *btrn)
+struct btr_node *btr_parent(const struct btr_node *btrn)
{
return btrn->parent;
}
* know the sample rate of its input known to e.g. the mp3dec node further up
* in the buffer tree.
*/
-typedef int (*btr_command_handler)(struct btr_node *btrn,
+typedef int (*btr_command_handler)(const struct btr_node *btrn,
const char *command, char **result);
/**
void *context;
};
-size_t btr_pool_size(struct btr_pool *btrp);
+size_t btr_pool_size(const struct btr_pool *btrp);
struct btr_pool *btr_pool_new(const char *name, size_t area_size);
void btr_pool_free(struct btr_pool *btrp);
-size_t btr_pool_get_buffer(struct btr_pool *btrp, char **result);
-int btr_pool_get_buffers(struct btr_pool *btrp, struct iovec iov[2]);
+size_t btr_pool_get_buffer(const struct btr_pool *btrp, char **result);
+int btr_pool_get_buffers(const struct btr_pool *btrp, struct iovec iov[2]);
void btr_add_output_pool(struct btr_pool *btrp, size_t size,
struct btr_node *btrn);
-size_t btr_pool_unused(struct btr_pool *btrp);
+size_t btr_pool_unused(const struct btr_pool *btrp);
void btr_copy(const void *src, size_t n, struct btr_pool *btrp,
struct btr_node *btrn);
-
struct btr_node *btr_new_node(struct btr_node_description *bnd);
void btr_remove_node(struct btr_node **btrnp);
void btr_add_output(char *buf, size_t size, struct btr_node *btrn);
void btr_add_output_dont_free(const char *buf, size_t size, struct btr_node *btrn);
-size_t btr_get_input_queue_size(struct btr_node *btrn);
-size_t btr_get_output_queue_size(struct btr_node *btrn);
-bool btr_no_parent(struct btr_node *btrn);
-size_t btr_next_buffer(struct btr_node *btrn, char **bufp);
-size_t btr_next_buffer_omit(struct btr_node *btrn, size_t omit, char **bufp);
+size_t btr_get_input_queue_size(const struct btr_node *btrn);
+size_t btr_get_output_queue_size(const struct btr_node *btrn);
+bool btr_no_parent(const struct btr_node *btrn);
+size_t btr_next_buffer(const struct btr_node *btrn, char **bufp);
+size_t btr_next_buffer_omit(const struct btr_node *btrn, size_t omit,
+ char **bufp);
void btr_consume(struct btr_node *btrn, size_t numbytes);
-int btr_exec_up(struct btr_node *btrn, const char *command, char **value_result);
+int btr_exec_up(const struct btr_node *btrn, const char *command, char **value_result);
void btr_splice_out_node(struct btr_node **btrnp);
void btr_pushdown(struct btr_node *btrn);
-void *btr_context(struct btr_node *btrn);
+void *btr_context(const struct btr_node *btrn);
void btr_merge(struct btr_node *btrn, size_t dest_size);
-void btr_log_tree(struct btr_node *btrn, int ll);
+void btr_log_tree(const struct btr_node *btrn, int ll);
void btr_pushdown_one(struct btr_node *btrn);
-bool btr_inplace_ok(struct btr_node *btrn);
-int btr_node_status(struct btr_node *btrn, size_t min_iqs,
+bool btr_inplace_ok(const struct btr_node *btrn);
+int btr_node_status(const struct btr_node *btrn, size_t min_iqs,
enum btr_node_type type);
-void btr_get_node_start(struct btr_node *btrn, struct timeval *tv);
+void btr_get_node_start(const struct btr_node *btrn, struct timeval *tv);
struct btr_node *btr_search_node(const char *name, struct btr_node *root);
void btr_drain(struct btr_node *btrn);
-struct btr_node *btr_parent(struct btr_node *btrn);
+struct btr_node *btr_parent(const struct btr_node *btrn);