paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros | Enumerations | Functions | Variables
audiod.c File Reference

Macros

#define CMD_PTR   (lls_cmd(0, audiod_suite))
 
#define OPT_RESULT(_name)   (lls_opt_result(LSG_AUDIOD_PARA_AUDIOD_OPT_ ## _name, lpr))
 
#define OPT_GIVEN(_name)   (lls_opt_given(OPT_RESULT(_name)))
 
#define OPT_STRING_VAL(_name)   (lls_string_val(0, OPT_RESULT(_name)))
 
#define OPT_UINT32_VAL(_name)   (lls_uint32_val(0, OPT_RESULT(_name)))
 
#define NUM_AUDIO_FORMATS   ARRAY_SIZE(audio_formats)
 
#define RECEIVER_CMD(_a)   lls_cmd((_a)->receiver_num, recv_cmd_suite)
 
#define RECEIVER(_a)   ((const struct receiver *)lls_user_data(RECEIVER_CMD(_a)))
 
#define MAX_STREAM_SLOTS   5
 
#define FOR_EACH_SLOT(_slot)   for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)
 
#define FOR_EACH_AUDIO_FORMAT(af)   for (af = 0; af < NUM_AUDIO_FORMATS; af++)
 

Enumerations

enum  vss_status_flags { VSS_STATUS_FLAG_NEXT = 1, VSS_STATUS_FLAG_PLAYING = 2 }
 

Functions

__malloc char * audiod_get_decoder_flags (void)
 
__malloc char * get_time_string (void)
 
struct btr_node * audiod_get_btr_root (void)
 
bool uid_is_whitelisted (uid_t uid)
 
int main (int argc, char *argv[])
 

Variables

 DEFINE_PARA_ERRLIST
 
__printf_2_3 void(* para_log )(int, const char *,...) = daemon_log
 
struct sched sched = {.timeout = 0}
 
char * stat_item_values [NUM_STAT_ITEMS] = {NULL}
 
int audiod_status = AUDIOD_ON
 

Macro Definition Documentation

◆ CMD_PTR

#define CMD_PTR   (lls_cmd(0, audiod_suite))

◆ OPT_RESULT

#define OPT_RESULT (   _name)    (lls_opt_result(LSG_AUDIOD_PARA_AUDIOD_OPT_ ## _name, lpr))

◆ OPT_GIVEN

#define OPT_GIVEN (   _name)    (lls_opt_given(OPT_RESULT(_name)))

◆ OPT_STRING_VAL

#define OPT_STRING_VAL (   _name)    (lls_string_val(0, OPT_RESULT(_name)))

◆ OPT_UINT32_VAL

#define OPT_UINT32_VAL (   _name)    (lls_uint32_val(0, OPT_RESULT(_name)))

◆ NUM_AUDIO_FORMATS

#define NUM_AUDIO_FORMATS   ARRAY_SIZE(audio_formats)

◆ RECEIVER_CMD

#define RECEIVER_CMD (   _a)    lls_cmd((_a)->receiver_num, recv_cmd_suite)

◆ RECEIVER

#define RECEIVER (   _a)    ((const struct receiver *)lls_user_data(RECEIVER_CMD(_a)))

◆ MAX_STREAM_SLOTS

#define MAX_STREAM_SLOTS   5

Maximal number of simultaneous instances.

◆ FOR_EACH_SLOT

#define FOR_EACH_SLOT (   _slot)    for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)

Iterate over all slots.

◆ FOR_EACH_AUDIO_FORMAT

#define FOR_EACH_AUDIO_FORMAT (   af)    for (af = 0; af < NUM_AUDIO_FORMATS; af++)

Iterate over all supported audio formats.

Enumeration Type Documentation

◆ vss_status_flags

The vss status flags audiod is interested in.

Enumerator
VSS_STATUS_FLAG_NEXT 

Whether the 'N' flag is set.

VSS_STATUS_FLAG_PLAYING 

The 'P' flag is set.

Function Documentation

◆ audiod_get_decoder_flags()

__malloc char* audiod_get_decoder_flags ( void  )

Return the flags for the decoder_flags status item.

Allocates a string which contains one octal digit per slot. Bit zero (value 1) is set if a receiver is active. Bit one (value 2) and bit three (value 4) have the analogous meaning for filter and writer, respectively.

Returns
String that must be freed by the caller.

References FOR_EACH_SLOT, and MAX_STREAM_SLOTS.

◆ get_time_string()

__malloc char* get_time_string ( void  )

Compute the play time based on information of the current slot.

This computes a string of the form "0:07 [3:33] (3%/3:40)" using information from the status items received from para_server and the start time of the (first) writer of the current slot.

It has to take into account that the stream was probably not started at the beginning of the file, that the clock between the server and the client host may differ and that playback of the stream was delayed, e.g. because the prebuffer filter is used in the filter configuration.

If no writer is active, for example because para_audiod runs in standby mode, an approximation based only on the status items is computed and the returned string is prefixed with "~".

Returns
A string that must be freed by the caller.

Referenced by audiod_status_dump().

◆ audiod_get_btr_root()

struct btr_node* audiod_get_btr_root ( void  )

Return the root node of the current buffer tree.

This is only used for stream grabbing.

Returns
NULL if no slot is currently active. If more than one buffer tree exists, the node corresponding to the most recently started receiver is returned.

References FOR_EACH_SLOT.

◆ uid_is_whitelisted()

bool uid_is_whitelisted ( uid_t  uid)

Lookup the given UID in the whitelist.

The whitelist is the array of arguments to the –user-allow opion. If the option was not given, the array is empty, in which case the check succeeds.

Parameters
uidUser ID to look up.
Returns
True if –user-allow was not given, or if uid matches an element of the whitelist.

References OPT_GIVEN.

◆ main()

int main ( int  argc,
char *  argv[] 
)

the main function of para_audiod

Parameters
argcusual argument count
argvusual argument vector
Returns
EXIT_SUCCESS or EXIT_FAILURE
See also
para_audiod(1)

Variable Documentation

◆ DEFINE_PARA_ERRLIST

DEFINE_PARA_ERRLIST

Array of error strings.

◆ para_log

__printf_2_3 void(* para_log) (int, const char *,...) = daemon_log

◆ sched

struct sched sched = {.timeout = 0}

The scheduler instance of para_audiod.

This is needed also in audiod_command.c (for the tasks command), so it can not be made static.

◆ stat_item_values

char* stat_item_values[NUM_STAT_ITEMS] = {NULL}

The array of status items sent by para_server.

◆ audiod_status

int audiod_status = AUDIOD_ON

The current mode of operation (AUDIOD_OFF, AUDIOD_ON or AUDIOD_STANDBY).

Set by the on/off/cycle commands.