paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros | Typedefs | Enumerations | Functions | Variables
audiod_command.c File Reference

Commands for para_audiod. 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 <lopsub.h>
#include "audiod.lsg.h"
#include "para.h"
#include "lsu.h"
#include "audiod_cmd.lsg.h"
#include "list.h"
#include "sched.h"
#include "buffer_tree.h"
#include "filter.h"
#include "grab_client.h"
#include "error.h"
#include "audiod.h"
#include "net.h"
#include "daemon.h"
#include "string.h"
#include "write.h"
#include "fd.h"
#include "version.h"

Macros

#define MAX_STAT_CLIENTS   50
 The maximal number of simultaneous connections. More...
 
#define EXPORT_AUDIOD_CMD_HANDLER(_cmd)
 Define the user_data pointer as expected by lopsub. More...
 

Typedefs

typedef int(* audiod_cmd_handler_t) (int, struct lls_parse_result *)
 Pointer to a command handler function. More...
 

Enumerations

enum  stat_client_flags { SCF_PARSER_FRIENDLY = 1 }
 Flags used for the stat command of para_audiod. More...
 

Functions

void close_stat_clients (void)
 Empty the status clients list. More...
 
void stat_client_write_item (int item_num)
 Write a message to all connected status clients. More...
 
int dispatch_local_connection (int accept_fd)
 Handle arriving connections on the local socket. More...
 
void audiod_status_dump (bool force)
 Send the current audiod status to all connected stat clients. More...
 
void clear_and_dump_items (void)
 Flush and send all status items. More...
 

Variables

struct sched sched
 The scheduler instance of para_audiod. More...
 
char * stat_item_values [NUM_STAT_ITEMS]
 The array of status items sent by para_server. More...
 
const char * status_item_list [] = {STATUS_ITEMS}
 The list of all status items used by para_{server,audiod,gui}. More...
 
const struct audiod_command_info lsg_audiod_cmd_com_help_user_data = { .handler = com_help }
 Implementation of help . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_ll_user_data = { .handler = com_ll }
 Implementation of ll . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_tasks_user_data = { .handler = com_tasks }
 Implementation of tasks . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_stat_user_data = { .handler = com_stat }
 Implementation of stat . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_grab_user_data = { .handler = com_grab }
 Implementation of grab . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_term_user_data = { .handler = com_term }
 Implementation of term . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_on_user_data = { .handler = com_on }
 Implementation of on . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_off_user_data = { .handler = com_off }
 Implementation of off . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_sb_user_data = { .handler = com_sb }
 Implementation of sb . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_cycle_user_data = { .handler = com_cycle }
 Implementation of cycle . More...
 
const struct audiod_command_info lsg_audiod_cmd_com_version_user_data = { .handler = com_version }
 Implementation of version . More...
 

Detailed Description

Commands for para_audiod.

Macro Definition Documentation

◆ MAX_STAT_CLIENTS

#define MAX_STAT_CLIENTS   50

The maximal number of simultaneous connections.

◆ EXPORT_AUDIOD_CMD_HANDLER

#define EXPORT_AUDIOD_CMD_HANDLER (   _cmd)
Value:
\
const struct audiod_command_info lsg_audiod_cmd_com_ ## _cmd ## _user_data = { \
.handler = com_ ## _cmd \
};

Define the user_data pointer as expected by lopsub.

Typedef Documentation

◆ audiod_cmd_handler_t

typedef int(* audiod_cmd_handler_t) (int, struct lls_parse_result *)

Pointer to a command handler function.

Enumeration Type Documentation

◆ stat_client_flags

Flags used for the stat command of para_audiod.

Enumerator
SCF_PARSER_FRIENDLY 

Enable parser-friendly output.

Function Documentation

◆ close_stat_clients()

void close_stat_clients ( void  )

Empty the status clients list.

This iterates over the list of connected status clients, closes each client file descriptor and frees the resources.

References list_for_each_entry_safe.

◆ stat_client_write_item()

void stat_client_write_item ( int  item_num)

Write a message to all connected status clients.

Parameters
item_numThe number of the status item of msg.

On write errors, remove the status client from the client list and close its file descriptor.

References para_buffer::flags, list_for_each_entry_safe, PBF_SIZE_PREFIX, and stat_item_values.

Referenced by audiod_status_dump(), and clear_and_dump_items().

◆ dispatch_local_connection()

int dispatch_local_connection ( int  accept_fd)

Handle arriving connections on the local socket.

Parameters
accept_fdThe fd to accept connections on.

This is called in each iteration of the main loop of the scheduler. If there is an incoming connection, the function reads the command sent by the peer, checks the connecting user's permissions by using unix socket credentials (if supported by the OS) and calls the corresponding command handler if permissions are OK.

Returns
Positive on success, negative on errors, zero if there was no connection to accept.
See also
para_accept(), recv_cred_buffer().

References MAXLINE.

◆ audiod_status_dump()

void audiod_status_dump ( bool  force)

Send the current audiod status to all connected stat clients.

Parameters
forceWhether to write unchanged items.

References daemon_get_uptime_str(), get_time_string(), now, stat_client_write_item(), and stat_item_values.

◆ clear_and_dump_items()

void clear_and_dump_items ( void  )

Flush and send all status items.

Send to each connected client the full status item list with empty values.

References FOR_EACH_STATUS_ITEM, stat_client_write_item(), and stat_item_values.

Variable Documentation

◆ sched

struct sched sched
extern

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]
extern

The array of status items sent by para_server.

The array of status items sent by para_server.

This is used by the amp filter which first tries to obtain the amplification value from an element in this array.

Referenced by audiod_status_dump(), clear_and_dump_items(), and stat_client_write_item().

◆ status_item_list

const char* status_item_list[] = {STATUS_ITEMS}

The list of all status items used by para_{server,audiod,gui}.

status items

◆ lsg_audiod_cmd_com_help_user_data

const struct audiod_command_info lsg_audiod_cmd_com_help_user_data = { .handler = com_help }

Implementation of help .

◆ lsg_audiod_cmd_com_ll_user_data

const struct audiod_command_info lsg_audiod_cmd_com_ll_user_data = { .handler = com_ll }

Implementation of ll .

◆ lsg_audiod_cmd_com_tasks_user_data

const struct audiod_command_info lsg_audiod_cmd_com_tasks_user_data = { .handler = com_tasks }

Implementation of tasks .

◆ lsg_audiod_cmd_com_stat_user_data

const struct audiod_command_info lsg_audiod_cmd_com_stat_user_data = { .handler = com_stat }

Implementation of stat .

◆ lsg_audiod_cmd_com_grab_user_data

const struct audiod_command_info lsg_audiod_cmd_com_grab_user_data = { .handler = com_grab }

Implementation of grab .

◆ lsg_audiod_cmd_com_term_user_data

const struct audiod_command_info lsg_audiod_cmd_com_term_user_data = { .handler = com_term }

Implementation of term .

◆ lsg_audiod_cmd_com_on_user_data

const struct audiod_command_info lsg_audiod_cmd_com_on_user_data = { .handler = com_on }

Implementation of on .

◆ lsg_audiod_cmd_com_off_user_data

const struct audiod_command_info lsg_audiod_cmd_com_off_user_data = { .handler = com_off }

Implementation of off .

◆ lsg_audiod_cmd_com_sb_user_data

const struct audiod_command_info lsg_audiod_cmd_com_sb_user_data = { .handler = com_sb }

Implementation of sb .

◆ lsg_audiod_cmd_com_cycle_user_data

const struct audiod_command_info lsg_audiod_cmd_com_cycle_user_data = { .handler = com_cycle }

Implementation of cycle .

◆ lsg_audiod_cmd_com_version_user_data

const struct audiod_command_info lsg_audiod_cmd_com_version_user_data = { .handler = com_version }

Implementation of version .