paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

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

Paraslash's standalone player. More...

#include <regex.h>
#include <signal.h>
#include <lopsub.h>
#include "recv_cmd.lsg.h"
#include "filter_cmd.lsg.h"
#include "play_cmd.lsg.h"
#include "write_cmd.lsg.h"
#include "play.lsg.h"
#include "para.h"
#include "lsu.h"
#include "list.h"
#include "error.h"
#include "buffer_tree.h"
#include "version.h"
#include "string.h"
#include "sched.h"
#include "filter.h"
#include "afh.h"
#include "recv.h"
#include "write.h"
#include "fd.h"
#include "interactive.h"

Macros

#define CMD_PTR   (lls_cmd(0, play_suite))
 
#define OPT_RESULT(_name)    (lls_opt_result(LSG_PLAY_PARA_PLAY_OPT_ ## _name, play_lpr))
 
#define OPT_GIVEN(_name)   (lls_opt_given(OPT_RESULT(_name)))
 
#define OPT_UINT32_VAL(_name)   (lls_uint32_val(0, OPT_RESULT(_name)))
 
#define OPT_STRING_VAL(_name)   (lls_string_val(0, OPT_RESULT(_name)))
 
#define AFH_RECV_CMD   (lls_cmd(LSG_RECV_CMD_CMD_AFH, recv_cmd_suite))
 
#define AFH_RECV   ((struct receiver *)lls_user_data(AFH_RECV_CMD))
 
#define INTERNAL_KEYMAP_ENTRIES
 
#define KEYMAP_ENTRY(a, b)   a
 
#define KEYMAP_ENTRY(a, b)   b
 
#define NUM_INTERNALLY_MAPPED_KEYS   ARRAY_SIZE(default_commands)
 
#define NUM_MAPPED_KEYS   (NUM_INTERNALLY_MAPPED_KEYS + OPT_GIVEN(KEY_MAP))
 
#define FOR_EACH_MAPPED_KEY(i)   for (i = 0; i < NUM_MAPPED_KEYS; i++)
 
#define LSG_PLAY_CMD_CMD(_name)
 
#define EXPORT_PLAY_CMD_HANDLER(_cmd)
 

Typedefs

typedef int(* play_cmd_handler_t) (struct lls_parse_result *lpr)
 

Enumerations

enum  state_change_request_type { CRT_NONE, CRT_REPOS, CRT_FILE_CHANGE, CRT_TERM_RQ }
 Describes a request to change the state of para_play. More...
 

Functions

int main (int argc, char *argv[])
 The main function of para_play. More...
 

Variables

 DEFINE_PARA_ERRLIST
 Array of error strings. More...
 
__printf_2_3 void(* para_log )(int, const char *,...) = stderr_log
 The log function of para_gui, always set to curses_log(). More...
 
char * stat_item_values [NUM_STAT_ITEMS] = {NULL}
 The array of status items sent by para_server. More...
 
const struct play_command_info lsg_play_cmd_com_quit_user_data = { .handler = com_quit }
 
const struct play_command_info lsg_play_cmd_com_help_user_data = { .handler = com_help }
 
const struct play_command_info lsg_play_cmd_com_info_user_data = { .handler = com_info }
 
const struct play_command_info lsg_play_cmd_com_tasks_user_data = { .handler = com_tasks }
 
const struct play_command_info lsg_play_cmd_com_ls_user_data = { .handler = com_ls }
 
const struct play_command_info lsg_play_cmd_com_play_user_data = { .handler = com_play }
 
const struct play_command_info lsg_play_cmd_com_pause_user_data = { .handler = com_pause }
 
const struct play_command_info lsg_play_cmd_com_prev_user_data = { .handler = com_prev }
 
const struct play_command_info lsg_play_cmd_com_next_user_data = { .handler = com_next }
 
const struct play_command_info lsg_play_cmd_com_fg_user_data = { .handler = com_fg }
 
const struct play_command_info lsg_play_cmd_com_bg_user_data = { .handler = com_bg }
 
const struct play_command_info lsg_play_cmd_com_jmp_user_data = { .handler = com_jmp }
 
const struct play_command_info lsg_play_cmd_com_ff_user_data = { .handler = com_ff }
 

Detailed Description

Paraslash's standalone player.

Macro Definition Documentation

◆ CMD_PTR

#define CMD_PTR   (lls_cmd(0, play_suite))

◆ OPT_RESULT

#define OPT_RESULT (   _name)     (lls_opt_result(LSG_PLAY_PARA_PLAY_OPT_ ## _name, play_lpr))

◆ OPT_GIVEN

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

◆ OPT_UINT32_VAL

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

◆ OPT_STRING_VAL

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

◆ AFH_RECV_CMD

#define AFH_RECV_CMD   (lls_cmd(LSG_RECV_CMD_CMD_AFH, recv_cmd_suite))

◆ AFH_RECV

#define AFH_RECV   ((struct receiver *)lls_user_data(AFH_RECV_CMD))

◆ INTERNAL_KEYMAP_ENTRIES

#define INTERNAL_KEYMAP_ENTRIES
Value:
KEYMAP_ENTRY("^", "jmp 0"), \
KEYMAP_ENTRY("1", "jmp 10"), \
KEYMAP_ENTRY("2", "jmp 21"), \
KEYMAP_ENTRY("3", "jmp 32"), \
KEYMAP_ENTRY("4", "jmp 43"), \
KEYMAP_ENTRY("5", "jmp 54"), \
KEYMAP_ENTRY("6", "jmp 65"), \
KEYMAP_ENTRY("7", "jmp 76"), \
KEYMAP_ENTRY("8", "jmp 87"), \
KEYMAP_ENTRY("9", "jmp 98"), \
KEYMAP_ENTRY("+", "next"), \
KEYMAP_ENTRY("-", "prev"), \
KEYMAP_ENTRY(":", "bg"), \
KEYMAP_ENTRY("i", "info"), \
KEYMAP_ENTRY("l", "ls"), \
KEYMAP_ENTRY("s", "play"), \
KEYMAP_ENTRY("p", "pause"), \
KEYMAP_ENTRY("q", "quit"), \
KEYMAP_ENTRY("?", "help"), \
KEYMAP_ENTRY("\033[D", "ff -10"), \
KEYMAP_ENTRY("\033[C", "ff 10"), \
KEYMAP_ENTRY("\033[A", "ff 60"), \
KEYMAP_ENTRY("\033[B", "ff -60"), \

◆ KEYMAP_ENTRY [1/2]

#define KEYMAP_ENTRY (   a,
 
)    a

◆ KEYMAP_ENTRY [2/2]

#define KEYMAP_ENTRY (   a,
 
)    b

◆ NUM_INTERNALLY_MAPPED_KEYS

#define NUM_INTERNALLY_MAPPED_KEYS   ARRAY_SIZE(default_commands)

◆ NUM_MAPPED_KEYS

#define NUM_MAPPED_KEYS   (NUM_INTERNALLY_MAPPED_KEYS + OPT_GIVEN(KEY_MAP))

◆ FOR_EACH_MAPPED_KEY

#define FOR_EACH_MAPPED_KEY (   i)    for (i = 0; i < NUM_MAPPED_KEYS; i++)

◆ LSG_PLAY_CMD_CMD

#define LSG_PLAY_CMD_CMD (   _name)
Value:
{.name = #_name, \
.completer = _name ## _completer}

◆ EXPORT_PLAY_CMD_HANDLER

#define EXPORT_PLAY_CMD_HANDLER (   _cmd)
Value:
const struct play_command_info lsg_play_cmd_com_ ## _cmd ## _user_data = { \
.handler = com_ ## _cmd \
};

Typedef Documentation

◆ play_cmd_handler_t

typedef int(* play_cmd_handler_t) (struct lls_parse_result *lpr)

Enumeration Type Documentation

◆ state_change_request_type

Describes a request to change the state of para_play.

There is only one variable of this type: rq of the global play task structure. Command handlers only set this variable and the post_monitor() function of the play task investigates its value during each iteration of the scheduler run and performs the actual work.

Enumerator
CRT_NONE 

Everybody is happy.

CRT_REPOS 

Stream must be repositioned (com_jmp(), com_ff()).

CRT_FILE_CHANGE 

New file should be loaded (com_next()).

CRT_TERM_RQ 

Someone wants us for dead (com_quit()).

Function Documentation

◆ main()

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

The main function of para_play.

Parameters
argcSee man page.
argvSee man page.

para_play distributes its work by submitting various tasks to the paraslash scheduler. The receiver, filter and writer tasks, which are used to play an audio file, require one task each to maintain their underlying buffer tree node. These tasks only exist when an audio file is playing.

The i9 task, which is submitted and maintained by the i9e subsystem, reads an input line and calls the corresponding command handler such as com_stop() which is implemented in this file. The command handlers typically write a request to the global play_task structure, whose contents are read and acted upon by another task, the play task.

As a rule, playlist handling is performed exclusively in play context, i.e. in the post-monitor step of the play task, while command handlers are only called in i9e context.

Returns
EXIT_FAILURE or EXIT_SUCCESS.

References sched::default_timeout.

Variable Documentation

◆ DEFINE_PARA_ERRLIST

DEFINE_PARA_ERRLIST

Array of error strings.

◆ para_log

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

The log function of para_gui, always set to curses_log().

◆ stat_item_values

char* stat_item_values[NUM_STAT_ITEMS] = {NULL}

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().

◆ lsg_play_cmd_com_quit_user_data

const struct play_command_info lsg_play_cmd_com_quit_user_data = { .handler = com_quit }

◆ lsg_play_cmd_com_help_user_data

const struct play_command_info lsg_play_cmd_com_help_user_data = { .handler = com_help }

◆ lsg_play_cmd_com_info_user_data

const struct play_command_info lsg_play_cmd_com_info_user_data = { .handler = com_info }

◆ lsg_play_cmd_com_tasks_user_data

const struct play_command_info lsg_play_cmd_com_tasks_user_data = { .handler = com_tasks }

◆ lsg_play_cmd_com_ls_user_data

const struct play_command_info lsg_play_cmd_com_ls_user_data = { .handler = com_ls }

◆ lsg_play_cmd_com_play_user_data

const struct play_command_info lsg_play_cmd_com_play_user_data = { .handler = com_play }

◆ lsg_play_cmd_com_pause_user_data

const struct play_command_info lsg_play_cmd_com_pause_user_data = { .handler = com_pause }

◆ lsg_play_cmd_com_prev_user_data

const struct play_command_info lsg_play_cmd_com_prev_user_data = { .handler = com_prev }

◆ lsg_play_cmd_com_next_user_data

const struct play_command_info lsg_play_cmd_com_next_user_data = { .handler = com_next }

◆ lsg_play_cmd_com_fg_user_data

const struct play_command_info lsg_play_cmd_com_fg_user_data = { .handler = com_fg }

◆ lsg_play_cmd_com_bg_user_data

const struct play_command_info lsg_play_cmd_com_bg_user_data = { .handler = com_bg }

◆ lsg_play_cmd_com_jmp_user_data

const struct play_command_info lsg_play_cmd_com_jmp_user_data = { .handler = com_jmp }

◆ lsg_play_cmd_com_ff_user_data

const struct play_command_info lsg_play_cmd_com_ff_user_data = { .handler = com_ff }
KEYMAP_ENTRY
#define KEYMAP_ENTRY(a, b)
Definition: play.c:528