paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros | Functions
filter_common.c File Reference

Common helper functions for filter input/output. More...

#include <regex.h>
#include <sys/types.h>
#include <lopsub.h>
#include "filter_cmd.lsg.h"
#include "para.h"
#include "list.h"
#include "sched.h"
#include "fd.h"
#include "buffer_tree.h"
#include "filter.h"
#include "error.h"
#include "string.h"

Macros

#define FOR_EACH_FILTER(j)   for (j = 1; FILTER_CMD(j); j++)
 Iterate over all filters. More...
 
#define DECODER_SAMPLE_FORMAT   SF_S16_LE
 

Functions

const struct filterfilter_get (int filter_num)
 Obtain a reference to a filter structure. More...
 
const char * filter_name (int filter_num)
 Return the name of a filter, given its number. More...
 
int filter_setup (const char *fa, void **conf, struct lls_parse_result **lprp)
 Parse a filter command line and call the corresponding ->setup method. More...
 
void print_filter_helps (bool detailed)
 Print help text of each filter to stdout. More...
 
void print_filter_list (void)
 Print a short summary of all available filters to stdout. More...
 
void generic_filter_pre_monitor (struct sched *s, void *context)
 Request a minimal timeout if not idle. More...
 
int decoder_execute (const char *cmd, unsigned sample_rate, unsigned channels, char **result)
 Execute a btr command for a decoder. More...
 

Detailed Description

Common helper functions for filter input/output.

Macro Definition Documentation

◆ FOR_EACH_FILTER

#define FOR_EACH_FILTER (   j)    for (j = 1; FILTER_CMD(j); j++)

Iterate over all filters.

◆ DECODER_SAMPLE_FORMAT

#define DECODER_SAMPLE_FORMAT   SF_S16_LE

Function Documentation

◆ filter_get()

const struct filter* filter_get ( int  filter_num)

Obtain a reference to a filter structure.

Parameters
filter_numBetween zero and NUM_SUPPORTED_FILTERS, inclusively.
Returns
Pointer to the filter identified by the given filter number, or NULL if the filter number is out of range.
See also
filter_name().

References FILTER_CMD.

◆ filter_name()

const char* filter_name ( int  filter_num)

Return the name of a filter, given its number.

Parameters
filter_numSee filter_get().
Returns
A pointer to a string literal, or NULL if filter_num is out of range. The caller must not attempt to call free(3) on the returned pointer.

References FILTER_CMD.

◆ filter_setup()

int filter_setup ( const char *  fa,
void **  conf,
struct lls_parse_result **  lprp 
)

Parse a filter command line and call the corresponding ->setup method.

Parameters
faThe filter argument.
confPoints to filter-specific setup upon successful return.
lprpParsed command line options are returned here.

Check if the given filter argument starts with the name of a supported filter, optionally followed by options for this filter. If yes, call the command line parser of that filter and its ->setup method.

Returns
On success, the number of the filter is returned and conf is initialized to point to the filter configuration as returned by the filter's ->setup() method, if any. Moreover, *lprp is initialized to contain the parsed command line options. On errors a negative paraslash error code is returned.

References create_argv(), FILTER_CMD, free_argv(), and lls().

◆ print_filter_helps()

void print_filter_helps ( bool  detailed)

Print help text of each filter to stdout.

Parameters
detailedWhether to print short or long help.

References FOR_EACH_FILTER.

◆ print_filter_list()

void print_filter_list ( void  )

Print a short summary of all available filters to stdout.

For each supported filter, the filter name and the purpose text is printed in a single line. Since no options are shown, the filter list is more concise than the text obtained from print_filter_helps().

References FILTER_CMD, and FOR_EACH_FILTER.

◆ generic_filter_pre_monitor()

void generic_filter_pre_monitor ( struct sched s,
void *  context 
)

Request a minimal timeout if not idle.

Parameters
sThe scheduler instance.
contextPointer to the filter node.

If the buffer tree node of the given filter node has data available (or is in error state) a minimal I/O timeout is requested from the scheduler. Otherwise the function does nothing.

References btr_node_status(), BTR_NT_INTERNAL, filter_node::btrn, filter_node::min_iqs, and sched_min_delay().

◆ decoder_execute()

int decoder_execute ( const char *  cmd,
unsigned  sample_rate,
unsigned  channels,
char **  result 
)

Execute a btr command for a decoder.

The buffer tree nodes of the writers ask the parent nodes about sample_rate, channels count and sample format. This function is called by all decoders to answer these queries.

Parameters
cmdThe command to be executed by the child node.
sample_rateKnown to the decoder.
channelsKnown to the decoder.
resultAscii representation on the answer is stored here.
Returns
Standard.