summaryrefslogtreecommitdiff
path: root/oss_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.
* doxygen: Hide user_data variables.Andre Noll2025-10-08
| | | | | These just clutter the generated documentation, particularly the list of global variables.
* 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: 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.
* | Hide implementation of para_fd_set().Andre Noll2022-08-25
| | | | | | | | | | | | | | | | This preparatory patch for replacing select() renames para_fd_set() to sched_fd_set(), moves it to sched.c and makes it static. All users are modified to call either of the two new public functions sched_monitor_{read,write}fd() which take a pointer to struct sched rather than an fd set pointer.
* | sched: Introduce sched_{read,write}_ok().Andre Noll2022-08-25
|/ | | | | Two trivial wrappers for FD_ISSET() which hide the fact that we're still using the select(2) API.
* Teach writers to abort gracefully on early EOF.Andre Noll2021-10-21
| | | | | | | | | | | | | | | | | | | | For very short streams it may happen that the receiver and decoder unregister themselves from the buffer tree before the writer had a chance to query the information from the decoder which it needs to open the audio device. This leads to errors such as Aug 25 14:24:51 schubert (5) get_btr_value: cmd sample_rate: Operation not supported Aug 25 14:24:51 schubert (5) get_btr_value: cmd channels: Operation not supported Aug 25 14:24:51 schubert (5) get_btr_value: cmd sample_format: Operation not supported Aug 25 14:24:51 schubert (4) alsa_init: channels count not available: Invalid argument This may happen with all receivers, audio formats and writers, although it is most common with ogg streams. This commit changes get_btr_sample_rate() and friends to return a standard error code rather than assuming success. The alsa, ao and oss writers are patched to check the return value and fail gracefully if one of these functions fails.
* oss: Bail out on unsupported audio formats.Andre Noll2018-09-30
| | | | | | This is better than assuming signed 16 bit little endian. The patch also improves the error message in oss.c that gets printed when the audio format could not be set.
* 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 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.
* Fix signedness issues in format strings.Andre Noll2016-12-04
| | | | | | | | | | | | | | Compiling with -Wformat-signedness (not enabled so far) causes many warnings because of format strings which specify an unsigned type but correspond to an argument of signed type, or vice versa. This commit fixes all these mismatches. For "%u", "%d", "%lu", "%ld" we let the format string match the type of the argument, but for "%x" we need to cast the argument to a suitable unsigned type. After this patch the tree compiles cleanly with -Wformat-signedness given. The warning will be enabled in a subsequent commit.
* 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.
* Remove unnecessary system header includes.Andre Noll2015-01-12
| | | | All these headers get included from para.h.
* Assorted typo fixes in comments.Andre Noll2015-01-11
| | | | Quite a few..
* oss: Avoid sound artefacts on some setups.Andre Noll2014-09-21
| | | | | | | | | Large buffers which result in short writes cause sound artefacts on certain setups. For example, 22KHz audio on Linux/ALSA in OSS mode is affected. This patch caps the number of bytes to write to the maximum possible value. This value is obtained through the SNDCTL_DSP_GETOSPACE ioctl.
* oss: Introduce sound device lock.Andre Noll2014-09-21
| | | | | | | | | | | | | | | Unlike ALSA with dmix, the OSS driver allows only a single opener of the sound device at any given time. With para_audiod it may happen that the writer of the buffer tree for the next audio file tries to open the device while the old writer is still active. If this happens, the second writer fails to open the device which causes the whole buffer tree to be aborted. This patch serializes access to the OSS sound device by adding a locking mechanism to oss_write.c. Since audiod is single threaded this is rather simple: The lock is taken in oss_post_select() when the device is opened. It is released in oss_close() after the file descriptor has been closed.
* 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().
* task_register() conversion: writersAndre Noll2014-05-25
|
* 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.
* sched: Rename new_post_select back to post_select.Andre Noll2013-04-30
|
* sched: Kill old ->post_select variant.Andre Noll2013-04-30
| | | | It has no more users.
* oss writer: Switch to the alternative post select method.Andre Noll2013-04-30
|
* Change copyright year to 2013.Andre Noll2013-03-25
| | | | Better late than never.
* Make writer nodes honor notifications.Andre Noll2012-11-18
| | | | | | Currently, nobody is notifying any writer node but the para_play executable, which will be introduced in subsequent patches, will use this facility to terminate the audio stream.
* Simplify ggo makefile.Andre Noll2012-08-27
| | | | | | | | | | | | | Currently we have three different targets for creating *_cmdline.[ch] files. This is because receivers, filters and writers need slightly different command line options. This patch defines the common options in the ggo makefile and moves additional parameters to the individual .m4 files so that a single target to create *_cmdline.[ch] is now sufficient. The name of the command line parsers of some filters and writers changed due to this unification, so these are updated accordingly.
* 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.
* write: Remove ->shutdown.Andre Noll2012-07-08
| | | | | No writer implements this method, and nobody even looks at this pointer. Remove it.
* oss: Add proper error message on init.Andre Noll2012-05-19
| | | | | | | If the device node of the sound device (/dev/dsp) does not exist, we currently fail with a "no such file or directory" error message without mentioning the name of the device. This adds a log message which clarifies what went wrong.
* Rename write_nonblock() to xwrite().Andre Noll2012-01-20
| | | | | | This function is not only useful for non-blocking file descriptors, so the name was misleading. Rename it to xwrite() for the lack of a better name.
* 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.
* 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.
* para_write: Return proper error code.Andre Noll2011-03-12
| | | | | | | | | | | | | | | | Currently the exit code of para_write is always the value returned by schedule(). This is zero unless the call to select() fails, usually does not happen, so errors resulting from the writers do not cause para_write to exit with a non-zero exit code. In particular, para_write exits successfully if the underlying writer(s) nodes could not open their sound device or unregistered their task due to other errors. Fix this by investigating each writer node's t->error value after schedule() has returned. If this value does not correspond to an end of file condition, the strerror text of this error code is written to stderr, and para_write exits non-zero.
* Fix oss_init() error path.Andre Noll2011-02-20
| | | | | | | | | | | | A bug similar to the one fixed in the previous patch for the alsa writer is also present in the oss writer: If oss_init() fails the ->private_data pointer is non-NULL, but its contents have already been freed. glibc detects this, aborts the process and spits out *** glibc detected *** ./para_write: double free or corruption (fasttop): 0x080622a0 *** Fix this bug by initializing ->private_data only if oss_init() succeeds.
* Replace 2010 in copyright message by 2011.Andre Noll2011-01-17
|
* writers: Kill ->open.Andre Noll2010-11-23
| | | | | Now that ->open is a dummy function for all writers, we may safely remove this method from struct writer and kill the dummy functions.
* oss: Make oss_open() a no-op.Andre Noll2010-11-23
| | | | | Move the allocation of the private_oss_write_data struct to oss_init() and adjust the the check whether oss has been initialized accordingly.
* writers: Unify ->pre_select().Andre Noll2010-11-23
| | | | | | | | | | | | Always treat the easy cases "nothing to do", "error", and "not yet initialized" first. For the alsa writer, this change fixes two minor bugs: First, if data is available but alsa has not yet been initialized, we return from ->pre_select() without setting a delay. This is wrong, we should init the alsa handle ASAP in this case. Second, on errors we wait 20ms which is both ugly and unnecessary. Requesting a minimal delay is the right thing to do here as well.
* Change the ->open method of writers to void.Andre Noll2010-11-23
| | | | | These methods always succeed. Add missing documentation of the public register_writer_node() function while we're at it.
* write: Simplify config parsers.Andre Noll2010-11-23
| | | | | | These functions all call the gengetopt parser which aborts on errors. It is therefore pointless to check the return value. Document this fact and make it explicit by renaming ->parse_config of struct writer to ->parse_config_or_die().
* write: Support audio formats != 16 bit little endian.Andre Noll2010-07-13
| | | | | | | | | | | | | | | | This adds the new --sample_format option to para_write and teaches the check_wav_task to read the sample format from the wav header rather than assuming 16 bit little endian. The alsa, oss and osx writers all ask the upper buffer tree nodes for the current audio format. For para_write the check_wav task answers this query by using the value given at the command line, looking at the wav header, or using 16 bit little endian as the default answer. For para_audiod, the current decoder answers this query. In this case the audio format is either 16 bit little endian or 16 bit big endian, depending on the endianness of the machine.
* write: Make get_btr_value() return void.Andre Noll2010-07-13
| | | | | | | | | | Asking upper buffer tree nodes for the sample rate and the channels count should never fail, because the writer only asks if there is already some output data to process. So, replace the tests by assertions, change the return value of get_btr_value() to void and fix up all callers accordingly. This simplifies the code a bit.
* Deduplicate --channels and --sample-rate.Andre Noll2010-07-13
| | | | | | | | | | | | | | | These options are identical for all writers. Moreover, they only make sense for para_write but are ignored for para_audiod. So move these options from the writer-specific ggo file to write.m4, the config file for para_write. The writers obtain the sample rate and the channels count as before via the buffer tree exec mechanism, but it is now the check_wav node rather than the btr node of the writer that computes this information from the given option, the wav header or the builtin default. The new HANDLE_EXEC macro contains the logic for determining the source of both the sample rate and the channels count.
* Cosmetics: Rename samplerate to sample_rate.Andre Noll2010-07-13
| | | | | A subsequent patch will introduce sample_format which looks much nicer than sampleformat. So let's use the underscored variant throughout.