summaryrefslogtreecommitdiff
path: root/write.c (follow)
Commit message (Collapse)AuthorAge
* 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.
* write.c: Remove struct wav_params and LLS_COPY_WAV_PARMS.Andre Noll2026-01-27
| | | | | | Now that para_write is the only user of the check_wav API, we no longer need to play preprocessor tricks to make a copy of the wav related command line options.
* write.c: Simplify check_wav_init().Andre Noll2026-01-27
| | | | | | It has only one caller, which passes NULL as the child node, so this parameter can be removed. The cw_btrn parameter is also unnecessary because the caller may as well use cwc->btrn directly.
* para_write: Move check_wav.{c,h} into write.c.Andre Noll2026-01-27
| | | | | | With the resample filter gone, para_write is the only remaining user of the check_wav API. Make the check_wav code local, make all functions static, and dedoxify the documentation.
* Improve writer documentation.Andre Noll2025-10-08
| | | | | File comments for write.[ch], the usual cleanups and dedoxification and the improved comment for main() of write.c.
* Revamp the stdin/stdout API.Andre Noll2025-08-27
| | | | | | | | | | | | | | | | | | With the current API it is impossible to free the memory that was allocated by stdin_task_register() after schedule() returns. This commit replaces the APIs defined in stdin.h and stdout.h to remove the memory leaks which are inevitable with the old API. We also make struct stdin_task and stdout_task opaque because the API users (client.c, filter.c, recv.c and write.c) should not be able to manipulate the fields of these structures directly. The new stdout API differs from the new stdin API only in that stdout_new() needs an additional argument to let the caller pass in a pointer to the parent buffer tree node. Other than that, the APIs are symmetric. Use the opportunity to do the non-blocking dance in std{in,out}_new() and std{in,out}_free() rather than in the post-monitor functions. This way we may get rid of the silly ->must_set_nonblock_flag boolean of struct std{in,out}_task.
* Make struct sched private, introduce sched_new().Andre Noll2025-07-13
| | | | | | | | | | | | | | | | This moves the declaration of the structure from sched.h to sched.c because the information stored in this structure has almost no users outside of the scheduler core. As a result, the size of the structure is no longer known outside of sched.c. To initialize a scheduler instance, users now must call the new sched_new(), passing an alternative poll function if needed, We don't let applications set the default timeout anymore because the value is kind of arbitrary anyway and most users specified one second. So hardcode this as the default. Besides allocating the scheduler structure, sched_new() also initializes the task list and the poll function pointer. Thanks to these initializations, the two conditions of sched.c removed in this patch are never true.
* write.c: Make stdin task variable local.Andre Noll2025-07-12
| | | | | The variable is not used outside of setup_and_schedule(), so there is no reason for it to be global.
* 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.
* Consolidate EOF error codes.Andre Noll2023-03-11
| | | | | | Currently we have ~15 error codes which indicate an EOF condition. One should suffice, so drop all codes except the generic E_EOF and use that everywhere.
* 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: Introduce arr_zalloc().Andre Noll2022-07-29
| | | | | | | | | | | | Adjust all callers which pass a product of two integers to zalloc() to call the new function instead and reduce zalloc() to a one-line wrapper.
| * 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.
* | Rename ->{pre,post}_select methods to ->{pre,post}_monitor.Andre Noll2022-08-25
| | | | | | | | | | | | | | The word "monitor" is neutral and continues to be correct after the switch from select(2) to poll(2). Pure rename, nothing to see here.
* | sched: Use integer value for select timeout.Andre Noll2022-08-25
|/ | | | | | | | | | | | | This modifies the public struct sched so that users pass in the default timeout as an integer value in milliseconds rather than a struct timeval. This simplifies the code a little and eases the transition from select(2) to poll(2) because poll(2) also takes a plain integer for the timeout. Since para_select() of fd.c now calls ms2tv() to convert the timeout back to a struct timeval, all executables which link with fd.o must also link with time.o. This was not the case for para_mixer and para_audioc, so configure.ac needs to be adjusted accordingly.
* 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 }'
* Convert para_write to lopsub.Andre Noll2017-03-26
| | | | | | | | | | | | | This replaces the gengetopt file write.m4 by write.suite.m4, making use of the shared macros in m4/lls/include for --channels, --sample-format and --sample-rate. The gengetopt files for these options are not needed for the unconverted executables which still rely on gengetopt, so they can be removed. In write.c we now use LLS_COPY_WAV_PARMS() rather than COPY_WAV_PARMS(). The latter macro becomes unused and is removed as well.
* 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.
* Simplify the error subsystem, get rid of error2.[ch].Andre Noll2016-12-20
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit removes error2.c and the surrounding infrastructure of the build system, getting rid of ~600 LOC. After the change there are no more subsystems for error codes, and we don't need to host-compile error2.c any more. Since all executables now contain the text of every error code, the change has some impact on the sizes of the (stripped) executables: Before: After: 64K para_afh 71K para_afh 43K para_audioc 47K para_audioc 256K para_audiod 259K para_audiod 64K para_client 71K para_client 39K para_fade 47K para_fade 141K para_filter 144K para_filter 51K para_gui 59K para_gui 252K para_play 255K para_play 97K para_recv 104K para_recv 227K para_server 230K para_server 60K para_write 67K para_write This increase in size is justified by the major simplification.
* Update year in copyright headers.Andre Noll2015-01-12
| | | | | | | | | | | | | | | | Done with files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files In previous years we ran a similar script to set the second year in the range to the current year. This is kind of silly, so let's get rid of this useless information. This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in all file headers, i.e. only the first year (A) is left in. Accurate information including time stamps for each change can be obtained from the git history.
* doc: Change email address to maan@tuebingen.mpg.deAndre Noll2014-08-18
| | | | | | | | | | | | | | The mail server on systemlinux.org was down for more than a week lately, so let's use an alternative official address. This commit changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de. Most .c and .h files contain the email address in the copyright header, so they must all be patched. Three other files contain the address for a different reason: * README lists email and git, gitweb and home page URLs * configure.ac needs it for configure -h * version.c contains it for the -V option of all commands
* sched: Directly pass context pointer to pre/post_select().Andre Noll2014-05-25
| | | | | | | | | | | | | | | The patch is large, but it's fairly straight forward: Instead of a task pointer all ->pre_select() and ->post_select() methods now receive the context pointer that was passed to the scheduler when the task was registered. This allows to kill the public task_context(). Two pre_select/post_select functions are not directly called by the scheduler: session_post_select(), generic_recv_pre_select(). These are changed to receive a proper struct rather than a void pointer. Note that generic_filter_pre_select() is not changed in this manner because some filters do not provide a pre_select wrapper but set task->pre_select to generic_filter_pre_select().
* sched: Introduce task_status().Andre Noll2014-05-25
| | | | | | | | | | | Before struct task can be made private to sched.c we must eliminate code which directly accesses the fields of this structure. The last offender is ->error: in many places we check this field to detect whether some task is in an error condition. This patch provides a public accessor function, task_status(), for this purpose. All users of ->error are modified to call this function instead.
* task_register() conversion: writersAndre Noll2014-05-25
|
* task_register() conversion: write taskAndre Noll2014-05-25
|
* task_register() conversion: stdin taskAndre Noll2014-05-25
| | | | | | This renames stdin_set_defaults() to stdin_task_register() and changes the function to register the stdin task. Before this patch, the task was registered in the callers.
* Change copyright year to 2014.Andre Noll2014-02-22
| | | | | | | | | This year, we're really on time. The changes in this patch were created by the following silly script: files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2013\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2013 Andre Noll/Copyright (C) \1-2014 Andre Noll/1' $files sed --in-place= -e 's/Copyright (C) 2013 Andre Noll/Copyright (C) 2013-2014 Andre Noll/1' $files
* Revamp ggo help.Andre Noll2013-06-13
| | | | | | | | | | | | | This adds usage and description fields to struct ggo_help and changes ggo_print_help() to optionally print these. The boolean detailed_help flag of ggo_print_help() is replaced by a bitmask which lets the caller specify what to print. Four pre-defined masks are used to print the normal help, the detailed help, the help for modules (receivers, filters, writers) and the detailed module help. The new macro DEFINE_GGO_HELP can be employed to create a struct ggo_help from a gengetopt structure.
* Introduce version.c to limit recompilation on version changes.Andre Noll2013-06-13
| | | | | | | | | | | | | | Currently version.h includes git-version.h which changes whenever a different commit is checked out or the working tree becomes dirty because a file has been modified. Consequently, all .c files that include this header must be recompiled in this case. To limit the number of recompilations, this commit introduces version.c, which contains functions that return the various types of the version string. It is now the only file that includes version.h, so only version.o must be rebuilt if git-version.h changes. This also adds the build date, OS and CC version to the version output.
* Make all commands print git version and improve version string.Andre Noll2013-06-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the format of the first line of the help output varies between executables, for example: para_afh git (0.4.12.12.g15a4: spectral gravity) para_audioc git This difference comes from the fact that para_afh has its own ->print_help method which uses the VERSION_SINGLE_LINE macro of version.h while para_audioc relies on gengetopt's help output. The latter uses the make variable PACKAGE_VERSION which gets initialized at configure time through the second argument in AC_INIT of configure.ac. This value is either the version number for or the string "git". It's a good thing to have the abbreviated git version encoded in all executables, so this commit changes the argument of gengetopt's --set-version to the git version string including the codename. With the patch applied, the output of all commands looks like this if --version was given: para_filter 0.4.12.12.g11d7 (spectral gravity) To make sure things stay consistent, the patch introduces the VERSION_SINGLE_LINE macro and changes all commands to use it instead of open coding the version string.
* Avoid unwanted log messages during startup.Andre Noll2013-06-13
| | | | | | | | | | | | | | | | | | | | Regardless of the given loglevel, para_recv currently prints log messages like these at startup: afh_init: initializing mp3 handler afh_init: initializing ogg handler afh_init: initializing aac handler afh_init: initializing wma handler afh_init: initializing spx handler afh_init: initializing flac handler That's because recv_init() is called before the command line arguments are parsed, so the loglevel has not been set at this point. Other programs have similar problems. Fix these problems by always setting the loglevel right after a parser has been called so that the init functions run *after* loglevel has been set.
* sched: Rename new_post_select back to post_select.Andre Noll2013-04-30
|
* write: Switch to the alternative post select method.Andre Noll2013-04-30
|
* Change copyright year to 2013.Andre Noll2013-03-25
| | | | Better late than never.
* resample filter: Implementation.Andre Noll2012-11-25
| | | | | | | | | | | | | | | | | | The resample filter allows to change the sample rate of a stream on the fly. All the magic happens within libsamplerate, so the implementation is quite simple. However, one tricky thing to consider is how wav headers are treated: Although the resample filter creates only a single task, it adds two different nodes to the buffer tree, one for the wav detector and another one for the resample filter itself. At startup the generic code of para_filter or para_audiod adds only the resample filter node, which in turn inserts the wav detector as its own parent node. This requires to insert a new internal node to the buffer tree which is currently not supported by the buffer tree API. It is easy to implement this feature though, so this commit adds the missing functionality to buffer_tree.c.
* Replace check_wav_task by write_task.Andre Noll2012-11-25
| | | | | | | | | | | | | | | | | | | Besides the task(s) associated with the given writer(s), para_write currently sets up two other tasks: The stdin task and the check_wav task. The resample filter, which is to be introduced in subsequent patches, also needs the functionality that is provided by the check wav task. However, as filters are not supposed to create their own tasks, there should not be a dedicated task instance for checking the wav header. To overcome this problem we move the task member from check_wav.c to write.c and rename the check_wav_task struct to check_wav_context. Hence the ->pre_select and ->post_select methods become part of para_write that call into check_wav.c to do the work. The patch is quite large but large parts of the changes are just trivial cwt -> cwc conversions.
* Move wav detection code to a separate file.Andre Noll2012-11-25
| | | | | | | | | | | | | | | | | | | | | The logic to detect a wav header and delete it from an input stream is useful also for the upcoming resample filter, so let's make this code reusable. The first step for doing so is to remove the relevant parts from write.c to check_wav.c and exports those functions which are called from write.c to check_wav.h. There is one problem though: The wav detector code needs to know the arguments for the --channels, --sample_rate and --sample_format options given to para_write, but the code would not be reusable if check_wav.c depended on the gengetop args info struct of para_write. Hence we introduce the public structure wav_params in check_wav.h for this information, which is independent of gengetopt. A simple convenience helper for copying the command line arguments from an (arbitrary) args info structure to a struct wav_params is provided as well.
* write: Get rid of gengetopt's string parser.Andre Noll2012-08-27
| | | | | | | | | | | | | It causes gengetopt to generate quite some additional code for the string parsers of all writers. Moreover, this string parser is inferior to create_argv() and create_shifted_argv() of string.c as gengetopt's parser does not honor any quoting at all. This commit changes the signature of the ->parse_config_or_die method of struct writer to take an (argc, argv) pair instead of a string. All writers can thus call the vanilla command line parser of gengetopt. The single user in write_common.c now calls ->parse_config_or_die() with an (argc, argv) pair obtained from create_shifted_argv().
* btr: Remove btr_free_node().Andre Noll2012-07-08
| | | | | | | | | This has turned out to be source for bugs. Deallocate everything in btr_remove_node() hence making removing the node and freeing its resources an atomic operation. To avoid dangling pointers to freed btrn nodes, the argument of btr_remove_node() is changed to to struct btr_node **btrnp.
* Change year in copyright message to 2012.Andre Noll2012-01-07
|
* Always include stdbool.h.Andre Noll2011-12-18
| | | | | | | | | This adds the #include statement for stdbool.h to para.h. This allows to get rid of the individual includes in *.c. More importantly, since all *.c files include para.h, booleans will now be available everywhere so that we won't need to touch dozens of files anymore whenever a boolean is added to a public structure.
* sched: Allow more than one running scheduler instance.Andre Noll2011-11-20
| | | | | | | | | | | | | | | | The interactive completion code must be able to run a second, independent scheduler instance for generating the possible completions. This is currently not possible because the pre_select and post_select list heads of the scheduler are defined globally in sched.c. This patch moves these list heads from sched.c to struct sched. This leaves only the global "now" variable in sched.c, but it is OK to update this from all scheduler instances, so it can stay. Moving the two list heads to struct sched requires that several public functions, among them register_task(), grow an additional parameter. The (mostly trivial) changes that update all callers to provide the new argument make the patch rather invasive, unfortunately.
* write_common: Make check_writer_arg() exit on syntax errors.Andre Noll2011-08-13
| | | | | | | | | | | | | | | This function parses the argument of the --writer option to extract the name of the writer, which is the first word of the argument. If this word is not the name of a supported writer, the function returns NULL to indicate that the given writer does not exist. Otherwise check_writer_arg() calls the ->parse_config_or_die method of this writer which parses the remaining part of the argument and exits on errors. It is more consistent and simpler to let this function exit also in case the writer was not found. This simplifies the callers a bit since they do not have to check the return value any more. It also allows to kill E_WRITE_COMMON_SYNTAX.
* write: Kill E_WRITE_SYNTAX.Andre Noll2011-08-13
| | | | | This value was used but no code path existed that would actually return this error, so remove it.
* write: Rename main_btr() to setup_and_schedule().Andre Noll2011-08-13
| | | | | The old name was a leftover from the long ago when para_write started to use the buffer tree API.
* Move setup_writer_node() from write_common.c to write.c.Andre Noll2011-08-13
| | | | | This function is only called from write.c, so move it there and make it static.
* Merge branch 't/crypt_cleanups'Andre Noll2011-04-23
|\ | | | | | | | | Conflicts: Makefile.in
| * Remove some unnecessary includes.Andre Noll2011-03-27
| | | | | | | | | | | | | | | | This gets rid of quite some inclusions of <dirent.h> which are not needed as most .c files do not deal with directories at all. afs.c doe not mmap anything and needs nothing from sys/time.h so remove these includes as well.