paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

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

The paraslash's audio daemon. More...

#include <netinet/in.h>
#include <sys/socket.h>
#include <regex.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/un.h>
#include <netdb.h>
#include <signal.h>
#include <pwd.h>
#include <lopsub.h>
#include "audiod.lsg.h"
#include "recv_cmd.lsg.h"
#include "para.h"
#include "error.h"
#include "lsu.h"
#include "crypt.h"
#include "list.h"
#include "sched.h"
#include "buffer_tree.h"
#include "recv.h"
#include "filter.h"
#include "grab_client.h"
#include "client.h"
#include "audiod.h"
#include "net.h"
#include "daemon.h"
#include "string.h"
#include "fd.h"
#include "write.h"
#include "version.h"

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
 Maximal number of simultaneous instances. More...
 
#define FOR_EACH_SLOT(_slot)   for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)
 Iterate over all slots. More...
 
#define FOR_EACH_AUDIO_FORMAT(af)   for (af = 0; af < NUM_AUDIO_FORMATS; af++)
 Iterate over all supported audio formats. More...
 

Enumerations

enum  vss_status_flags { VSS_STATUS_FLAG_NEXT = 1, VSS_STATUS_FLAG_PLAYING = 2 }
 The vss status flags audiod is interested in. More...
 

Functions

__malloc char * audiod_get_decoder_flags (void)
 Return the flags for the decoder_flags status item. More...
 
__malloc char * get_time_string (void)
 Compute the play time based on information of the current slot. More...
 
struct btr_node * audiod_get_btr_root (void)
 Return the root node of the current buffer tree. More...
 
bool uid_is_whitelisted (uid_t uid)
 Lookup the given UID in the whitelist. More...
 
int main (int argc, char *argv[])
 the main function of para_audiod More...
 

Variables

 DEFINE_PARA_ERRLIST
 Array of error strings. More...
 
__printf_2_3 void(* para_log )(int, const char *,...) = daemon_log
 
struct slot_info slot [5]
 para_audiod uses MAX_STREAM_SLOTS different slots, each of which may be associated with a receiver/filter/writer triple. More...
 
struct sched sched = {.timeout = 0}
 The scheduler instance of para_audiod. More...
 
char * stat_item_values [NUM_STAT_ITEMS] = {NULL}
 The array of status items sent by para_server. More...
 
int audiod_status = AUDIOD_ON
 The current mode of operation (AUDIOD_OFF, AUDIOD_ON or AUDIOD_STANDBY). More...
 

Detailed Description

The paraslash's audio daemon.

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, MAX_STREAM_SLOTS, para_strdup(), and slot.

◆ 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 btr_get_node_start(), FOR_EACH_SLOT, slot, and tv_diff().

◆ 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

◆ slot

struct slot_info slot[5]

para_audiod uses MAX_STREAM_SLOTS different slots, each of which may be associated with a receiver/filter/writer triple.

This array holds all information on the status of these slots.

Referenced by audiod_get_btr_root(), and audiod_get_decoder_flags().

◆ 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.