summaryrefslogtreecommitdiff
path: root/audiod_command.c (follow)
Commit message (Collapse)AuthorAge
* audiod: Dedoxify audiod_command.c.Andre Noll2026-06-29
| | | | | | The documentation included too much detail, which is not helpful for the doxygen web page because it only hides the interesting part of the file (the five public functions).
* audiod: Write help error message to error sideband.Andre Noll2026-06-29
| | | | | | | | | Without this, the error message returned by lsu_com_help() is written to the SBD_OUTPUT band. As a result, para_audioc help does_not_exist 2>/dev/null prints the message to stdout.
* audiod: Move clear_status_items() and make it static.Andre Noll2026-05-09
| | | | And remove the stale comment. This function does not send anything.
* Switch to SPDX identifiers.Andre Noll2026-03-17
| | | | | | | | Generated with sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h followed by manually tweaking the result a bit. No license change intended.
* Remove support for audioc/audiod v1 protocol.Andre Noll2026-01-27
| | | | This breaks compatibility with v0.7, but also simplifies the code nicely.
* audioc sideband: Fix early error handling.Andre Noll2026-01-12
| | | | | Both server and client handled the "permission denied" case (client UID mismatch) incorrectly. This should fix it.
* Deprecate the audiod grab subcommand.Andre Noll2026-01-04
| | | | It has not proved to be very useful, and it adds quite a bit of complexity.
* Employ sideband API for audioc-audiod connections.Andre Noll2026-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, para_audioc writes the data it received over the local socket from audiod to stdout. This include error messages, if any. Also, para_audioc does not know whether the subcommand passed to para_audiod was successful, and exits successfully even if the subcommand failed. Thanks to the sideband API, para_client is much smarter in this regard. This patch employs the existing API also for the connection between para_audioc and para_audiod. Besides comment updates and the new sideband_log() helper, no changes to the sideband API are necessary. The client code stays unmodified as well. The new helper has three callers, two in audioc.c and one in client_common.c. Remove a pointless NULL check and a debug log message from dispatch_sbb() of client_common.c while at it. The message was useful for testing but is no longer needed. The new code is backwards compatible, i.e., an old para_audioc can still communicate with a new para_audiod and vice versa. Thus, we have to maintain two "protocols" for the audioc-audiod communication, named v1 and v2 in the code and in what follows. For example, if audioc or audiod are unpatched (so that v1 is in use), then ./para_audioc aaa > /dev/null prints nothing because with v1 the error message goes to stdout, and the command exits successfully (exit code 0). If both sides support v2, the same command prints audiod: errctx: aaa audiod: invalid subcommand main: audiod dispatch error to stderr, then exits unsuccessfully (exit code 1). Only the server reply is sideband-encoded. The way how command line arguments are passed from audioc to audiod is also changed, though. Instead of terminating the arguments with newlines, a v2 audioc prepends an additional \0 byte to the argument list, and terminates each argument with \0 in the same way the --print0 directive of GNU find(1) does. An v1 audiod interprets the leading NUL as an empty command line and closes the connection without sending any data. This can never happen with a v2 audiod because that always sends an empty sideband package to indicate success/failure. So the v2 code of audioc.c retries with v1 in this case. Conversely, a v1 client never sends an empty string, so a leading \0 identifies a v2 client. Thus, the patched audiod only needs to check the first byte of the received buffer to select the right "protocol" version. The stat and grab subcommands need special treatment because these may stay active after the command handler returns. Thus, the command handler must not send an EXIT_SUCCESS sideband packet in this case. Moreover, the protocol version needs to be communicated with the status/grab client tasks. This is done by adding a flag to the existing flags bitmask of struct stat_client and struct grab_client. After v0.8.0 has been released, the compatibility code can be dropped.
* Use iovecs for unix socket credentials.Andre Noll2026-01-04
| | | | | This is the right thing to do, since {recv,send}_cred_buffer() need to set up an iovec structure.
* Make send_cred_buffer() and recv_cred_buffer() local.Andre Noll2026-01-04
| | | | | | Only para_audioc needs the former, and only para_audiod needs the latter. With this patch in place, both functions can be static and the other executables which link in net.o don't get bloated with unnecessary code.
* audiod_command.c: Improve documentation of stat_client_write_item().Andre Noll2025-12-12
| | | | The new text is shorter and more clear.
* Merge topic branch t/mixer into masterAndre Noll2025-11-22
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A medium sized series which implements the --one-shot option of the audiod stat subcommand and improves the sleep subcommand of para_mixer by making use of the new option. The series also contains a few assorted cleanups to the mixer related source files. * refs/heads/t/mixer: mixer: Smarter mood switching. audiod: New option: stat --one-shot. mixer: Simplify com_snooze(). mixer: Constify handle argument of ->get(). mixer: Simplify ->close(). mixer: Simplify alsa_mix_get(). mixer: Add two examples to man page. mixer: Improve help text of --fade-exponent. mixer: Simple logging adjustments.
| * audiod: New option: stat --one-shot.Andre Noll2025-11-10
| | | | | | | | | | This is a preparatory patch for the subsequent revamp of para_mixer's sleep subcommand.
* | Merge topic branch t/doxygen into masterAndre Noll2025-11-15
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This revamps the doxygen part of the documentation web page and adds a couple of entry points for users to get started with the code base. We provide links to header files which describe the API of central subsystems and links to the main function of each paraslash executable. The file comments of the source files reachable through these links have been extended to contain a detailed description of the API or executable. Unlike the introductory text of the manual pages, these comments focus on the code, in particular on the interaction between the various subsystems. * refs/heads/t/doxygen: (31 commits) mix web: Revamp documentation page. Improve server documentation. Improve para_play documentation. Improve crypto documentation. Improve i9e documentation. Improve mixer documentation. Improve audiod documentation. Improve audioc documentation. Improve client documentation. Improve gui documentation. Improve writer documentation. Improve receiver documentation. Improve filter documentation. Improve audio file selector documentation. Improve sender documentation. Improve FEC documentation. Improve virtual streaming system documentation. Improve audio format handler documentation. Improve buffer tree documentation. ...
| * | Improve audiod documentation.Andre Noll2025-10-08
| | | | | | | | | | | | | | | The new file comment for audiod.c, the usual dose of dedox for audiod.c and audiod_command.c, and the improved documentation of audiod's main function.
| * | doxygen: Hide user_data variables.Andre Noll2025-10-08
| |/ | | | | | | | | These just clutter the generated documentation, particularly the list of global variables.
* / audiod: Omit ucred check on *BSD.Andre Noll2025-11-15
|/ | | | | NetBSD and FreeBSD don't support Unix socket credentials, so all users should be allowed to contact audiod via the local socket.
* audiod_command: Add OPT_GIVEN macro.Andre Noll2025-10-06
| | | | This macro improves the readability of the subsequent code a lot.
* Fix task and grab subcommands.Andre Noll2025-08-25
| | | | | | | | These broke due to the recent commit that made the scheduler structure private. The problem is that the public "sched" variable defined in audiod.c has become a pointer, but the code in audiod_command.c was not adjusted accordingly. Fixes: 8925c518a819d6e4826dcbb616cc3e1b85920354
* audiod: Free status items on exit.Andre Noll2025-08-07
| | | | | | | In close_stat_pipe() we call clear_and_dump_items(), then dump the status items again for no good reason. Rename clear_and_dump_items() to clear_status_items(), stop dumping items there, and call the new function also from audiod_cleanup() to avoid the memory leaks at exit.
* Merge topic branch t/build into masterAndre Noll2025-05-20
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A medium sized series for the build system which improves the way the git version string is stored in the executables and man pages. Subsequent patches of the series remove some warts from the makefile: we no longer use order-only dependencies and the .PRECIOUS target. The merge results in a conflict against the "remove regex include" commit 67388cd4fae0. This is trivial to resolve, though. * refs/heads/t/build: Doxify version functions. Doxify OV_EXCLUDE_STATIC_CALLBACKS #define. Makefile: Fix braino in tarball target. build: Remove superfluous dependency in Makefile.real. build: Remove the .PRECIOUS target. build: Improve clean targets. build: Get rid of directory order-only dependencies. build: Compile with -Wunused -Wall also on BSD. build: Revamp git versioning. build: Merge version.{c,h} into string.{c,h}.
| * build: Merge version.{c,h} into string.{c,h}.Andre Noll2025-03-25
| | | | | | | | | | | | | | | | | | This is a preparatory patch for the upcoming revamp of the git version script. The revamped script generates version.c, a file which is currently tracked by git. We can easily get rid of it (and of version.h) since all paraslash executables link in both string.o and version.o. So let's move the three small functions of version.c to string.c and their declarations from version.h to string.h.
* | Include regex.h from para.h.Andre Noll2025-05-19
| | | | | | | | Every .c file includes it anyway.
* | Check return value of lsu_com_help().Andre Noll2025-05-03
|/ | | | | | | | | | | | | This function fails if an invalid command name is passed as the argument, yet all callers ignore the error. Modify the callers to print the strerror text as appropriate and no longer do that in lsu_lopsub_error(). Rename this function and introduce the error type argument to print more meaningful error messages. One visible consequence is that para_client help does-not-exist used to succeed while it now exits with status 1.
* audiod: Improve stat_client_add().Andre Noll2023-12-24
| | | | | Let it receive a bool rather than an int and dedox its documentation because it's a static function.
* audiod_command: Remove dump_stat_client_list().Andre Noll2023-06-14
| | | | It is not very useful and can spam the log.
* audiod_command.c: Dedox stat_item_valid().Andre Noll2023-01-09
| | | | | Another static function which does not need to be documented with doxygen.
* Merge topic branch t/overflow into masterAndre Noll2022-10-03
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This series implements a new memory allocation API which checks for overflows. The first part of the series just renames the main allocation functions. Later patches in the series implement allocators which take two size_t arguments (like calloc(3)) and check whether the multiplication overflows by employing the __builtin_mul_overflow() primitive supported by gcc and clang. This requires us to bump the lowest supported gcc and clang version. * refs/heads/t/overflow: build: Compile with -ftrapv. string: Introduce arr_zalloc(). string: Introduce arr_alloc(). string: Introduce arr_realloc() and check for integer overflow. string: Rename para_calloc() -> zalloc(). string: Rename para_malloc() -> alloc(). string: Overhaul para_strdup().
| * string: Rename para_calloc() -> zalloc().Andre Noll2022-07-29
| | | | | | | | | | Reword the documentation a bit since the function has never been a wrapper for calloc(3). No code changes.
* | Merge branch 'refs/heads/t/ll'Andre Noll2022-09-18
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two little cleanups related to the logging facility and two commits which add the ll command to para_server and para_audiod. The merge resulted in a conflict in afs.c due to the earlier merge of the poll topic branch which replaced all calls to select() by calls to poll(). The implementation of the ll server command introduced a new caller of select(), afs_select(), which needs to be replaced by afs_poll() to resolve the conflict. * refs/heads/t/ll: New server command: ll to change the log level at runtime. New audiod command: ll to change the log level at runtime. daemon: Kill get_loglevel_by_name(). server/audiod: Don't parse loglevel argument unnecessarily.
| * | New audiod command: ll to change the log level at runtime.Andre Noll2022-07-02
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | The new public daemon_get_loglevel() is needed in the zero argument case. Otherwise, the ll command handler parses the argument and calls daemon_set_loglevel(). The lopsub stanza for the subcommand is stored in a separate file which is currently only included by the lopsub suite for para_audiod, but will be included as well by the server suite. For similar reasons we implement the completer as a generic public function, i9e_ll_completer(), although it only has one caller in audioc.c. Another caller follows when the ll server command is added.
* | Misc documentation cleanups related to select().Andre Noll2022-08-25
| | | | | | | | | | Assorted comment cleanups which avoid to talk about select(2) and fd sets. No code changes.
* | audiod: Rename handle_connect().Andre Noll2022-08-25
| | | | | | | | | | | | | | | | | | | | | | Now that it has the same signature as para_server's handle_connect(), doxygen gets confused and complains as follows: audiod_command.c:359: warning: argument 'accept_fd' of command @param is not found in the argument list of handle_connect(int fd) This is a false positive, but since "handle_connect" is not a very descriptive name for a public function in the first place, let's rename it.
* | net: Drop fd_set parameter from para_accept().Andre Noll2022-08-25
|/ | | | | | As for read_nonblock(), the parameter is dispensable because it is only used for an optimization to avoid a system call. Get rid of it because it hinders the conversion from select(2) to poll(2).
* audiod: Implement help --long.Andre Noll2018-04-22
| | | | | | | | This converts the help command of para_audiod to the generic lsu_com_help(), adding --long and removing quite a few lines of duplicated code. This patch also touches audioc.c since para_audioc needs to learn to complete the new --long option. Moreover the help text of the help command is made a bit more useful.
* Shorten copyright notice.Andre Noll2017-09-22
| | | | | | | | | | | | | | | | | | | | | The GPLv2 line does not add any additional information, so drop it. This leaves a single line of legalese text for most files, which is about the amount of screen real estate it deserves. This patch was created with the following script (plus some manual fixups): awk '{ if (NR <= 5) { gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g") if (gs != $0) year = gs next } if (NR == 6 && year != "") printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year) print }'
* Merge branch 'refs/heads/t/si_conversion'Andre Noll2017-08-27
|\ | | | | | | | | | | | | | | | | | | A single patch which moves the list of status items from configure.ac to para.h. Cooking for five weeks. * refs/heads/t/si_conversion: Define status items in para.h.
| * Define status items in para.h.Andre Noll2017-07-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The only reason the status item enum and string array are defined in configure.ac is that upper case identifiers and lower case strings are not easy to do in cpp as it lacks toupper(). However, configure.ac is not the right place for defining C language constructs as the configure script should only check for installed packages. This commit moves the definition of the status item enum and array to para.h and modifies all users to use lower case for the item names. This was automated with a script which essentially did upper=${i^^} sed -i "s/\<SI_$upper/SI_$i/g" $files for each status item $i. Care has been taken to leave the order of the status items unchanged. This is important because the item numbers must be considered part of the API between server and client.
* | doxygen: Add \ref to references.Andre Noll2017-06-25
|/ | | | | This way doxygen issues a warning if the file/function/structure no longer exists and a stale reference remains.
* audiod: Avoid uninitialized memory access.Andre Noll2017-04-21
| | | | | | | | | | In handle_connect(), the local pointer variable errctx is not initialized. If an error occurs early in the function, for example because recv_cred_buffer() fails, we jump to the "out" label and try to print the string errctx points to. This will cause a segfault or worse, so make sure the variable is always initialized. This bug was found by the static analyzer of clang.
* Convert para_audiod to lopsub.Andre Noll2017-03-26
| | | | | | | | | | | | | This commit replaces the gengetopt file for para_audiod by a lopsub suite, introducing several new files in m/lls/include which correspond to options also needed by para_server (which has not been converted to lopsub yet). The audiod_status_info enumeration is now provided by lopsub and can be removed from audiod.h. The patch also adds a new description section to the manual page para_audiod(1).
* Convert writers to lopsub.Andre Noll2017-03-26
| | | | | | | | | | | | | | | | | | | | | Similar to the previous commits for receivers and filters, this commit replaces the five gengetopt parsers for the alsa, ao, file, oss, osx writers by a lopsub suite and links para_write with -llopsub. This allows to get rid of the WRITER_ENUM and the writers array as a reference to each writer structure are stored in the lopsub user_data pointer. Moreover, ->init(), ->parse_config(), ->free_config() and ->ggo_help() of struct writer are not needed any more and can be removed. The patch also removes write_common.h and moves the few prototypes write.h. Now that receivers, filters and writers have all been converted, we may also stop to include ggo.h from audiod_command.c and play.c. As for the receivers and filters, t0005 needs slight adjustments due to the new section header in the man page.
* Convert audiod commands to lopsub.Andre Noll2017-03-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The four command lists (server, afs, audiod, play) and all executables will be converted to the long option parser library (lopsub). This first patch converts the audiod commands (on, off, cycle...) and adds the necessary infrastructure to the build system. The option parser for para_audiod is still generated by gengetopt and will be converted in a subsequent patch. The build system is updated to include an autoconf test which checks for the lopsub library and the lopsubgen executable. If the check fails, it prints instructions on how to download the lopsub package. Moreover, a section on lopsub is added to the INSTALL file and the library is listed as a required tool in the manual. The options and help texts of all audiod commands are moved from audiod.cmd to the new file audiod_cmd.suite.m4. Until all command lists are converted, man_util.bash needs an ugly hack to deal with the two kinds of files. The help texts have been reworked slightly, but no syntactical changes were performed. However, one side effect of the change is that options to audiod commands now accept short and long options, and that short options may be combined in the usual way. The error subsystem of paraslash is extended to treat lopsub errors analogous to errors from the osl libary: we reserve a new bit for error codes returned from lopsub library functions and a lls() wrapper function that must be used for all lopsub functions which return a lopsub error code on failure. The E_INVALID_AUDIOD_CMD error code can be removed since invalid commands are now detected by the lopsub library, which returns its own error code in this case. As a result of the conversion, struct audiod_command can be removed. Command handlers now take a pointer to a lopsub parse result instead of the (argc, argv) pair. The patch also changes the completers for audiod commands in audioc.c. to use the information in the generated audioc_cmd.lsg.h header file instead of duplicating this information. With the patch applied, para_audiod and para_audioc need to be linked with -llopsub. We still need to include ggo.h from audiod_command.c until receivers, filters and writers have been converted as well.
* audiod: Move UID check from audiod_command.c to audiod.c.Andre Noll2016-08-07
| | | | | | | | | | | | | | | | | | | check_perms() is the only reason for the gengetopt config pointer being public and for passing the whitelist pointer to handle_connect() in audiod_command.c. The code get less convoluted by moving the permission check to audiod.c where both the conf pointer and the uid_whitelist are defined. This introduces the new public function uid_is_whitelisted() in audiod.c which replaces check_perms(). This allows to * pass only the UID to the check function, * drop the whitelist pointer argument from handle_connect(), * make the conf pointer in audiod.c static. The patch also reorders the function declarations in audiod.h a bit to separate the functions defined in audiod.c from those defined in audiod_command.c.
* Merge branch 'refs/heads/t/command_handler_cleanups'Andre Noll2015-10-25
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cooking for about two months. * refs/heads/t/command_handler_cleanups: (39 commits) com_addatt(): Return negative on errors com_rm(): In force mode, don't complain if no paths matched. aft: Unify handling of hash and path duplicates. afs: Provide pbout para_buffer for each callback. afs: Make afs callbacks more flexible. afs: Rename callback_function to afs_callback. com_check(): Add attribute checking. Let afs_event() return int. playlist_check_callback(): Return negative on errors mood_check_callback(): Return negative on errors com_mvblob(): Return negative on errors com_addblob(): Return negative on errors com_rmblob(): Return negative on errors, cleanup com_catblob(): Return negative on errors com_lsblob(): Return negative on errors rmatt: Cleanup callback. com_rmatt(): Return negative on errors com_mvatt(): Return negative on errors com_lsatt(): Return negative on errors com_init(): Return negative on errors ...
| * Do not check return value of WRITE_STATUS_ITEM().Andre Noll2015-08-12
| | | | | | | | | | | | | | The previous commit removed error checking from para_printf(), but one instance remains: the WRITE_STATUS_ITEM() macro which also calls para_printf(). This patch removes the error checking code of this macro and adjusts all callers.
| * audiod: Document and fix command handler return values.Andre Noll2015-08-12
| | | | | | | | | | | | | | | | | | | | | | | | It has always been the case that a positive return value from a command handler causes audiod to dump all audiod status items to all clients. This behaviour is not documented though, and some command handlers get it wrong. In fact, the help, stat, tasks, grab, version commands all return positive values although those commands never change any status items. This comment documents the meaning of the return value and fixes up the above command handlers.
* | audiod_command.c: Trivial whitespace fix.Andre Noll2015-08-30
| |
* | audiod_command.c: Fix typo in comment.Andre Noll2015-08-19
|/
* command_util.bash: Kill make_proto().Andre Noll2015-08-12
| | | | | | | | | | | | | | It is always a bad idea to parse C code with a regex in a script. In addition, it is completely unnecessary in this case. This commit changes command_util.bash to define, in addition to the old XXX_CMD_ARRAY, another preprocessor macro XXX__COMMAND_HANDLERS containing the comma separated list of command handlers without any type information instead of grepping the source files. A simple typedef is used to declare all command handlers. Avoiding all the grep/sed calls reduces the (warm cache) make dep time by ~10%.