afh: Limit chunk numbers to 32 bit. The number of chunks and the chunk offsets are stored in the audio file table as 32 bit unsigned integers. Thus, chunk numbers and sizes cannot exceed 2^32 - 1. Make this fact obvious by changing the corresponding parameters of aac_afh_get_chunk() from size_t or unsigned long to uint32_t.
afh: Avoid memory leak at exit. We missed to free the lopsub parse result. This is not a real leak because it's a one-off allocation and we are about to exit anyway. It's worth to fix nevertheless, though, because with the patch applied, valgrind says "no leaks are possible". Hence any other output means we have introduced a new memory leak.
Merge branch 'refs/heads/t/afh' A couple of patches which remove ->init of struct audio_format_handler and struct receiver. Cooking for 9 months. * refs/heads/t/afh: Remove ->init() of struct receiver. afh: Constify definition of audio format handlers. afh: Introduce audio_format_names[]. afh: Get rid of dummy entry at the end of afl[]. afh: Minor simplification for afh_get_chunk(). afh: Move audio_format_name() up.
afh: Constify definition of audio format handlers. The audio_format_handler structure contains only pointers, and the ->init method of each instance initializes these pointers to constant values. The ->init() method is thus useless at best, and it prevents the structures from being declared constant. This patch removes ->init() of struct audio_format_handler and the public afh_init() which iterates over all audio formats to call each ->init() method. The audio format handlers are modified to define an instance of the structure rather than an init function which fills the fields of the given structure. The structure can be declared constant, but not static because afh_common.c needs a way to refer to it. We rely on weak symbols to deal with audio format handlers which are not compiled in. The codec-independent code in afh_common.c defines a weak instance of the audio_format_handler structure for each audio format. The command handlers which are compiled in override the weak symbol with their own definition. The afh receiver used to define afh_init() as its (receiver!) init function, which no longer exists. Since receiver init functions are optional, we don't need to supply a replacement. However, play.c calls ->init() of the afh_receiver unconditionally. This call needs to be removed to avoid a null pointer dereference.
afh: Implement --preserve. This is easy because we already have the inode information of the old file from the existing call to stat(2).
Shorten copyright notice. 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 }'
afh: Make parse result pointer static. It is only referenced within afh.c.
Merge branch 'refs/heads/t/lopsub' The bulk of the changes in this release is the conversion of all command line parsers from gengetopt to lopsub. The series also contains a few cleanups that have become possible due to the switch from gengetopt to lopsub. The patches towards the end of the series rename para_fade to para_mixer. Naturally, the merge conflicted rather heavily against the other topic branches that have been merged since the lopsub branch was started. Conflicting files: Makefile.real afh.c afh_recv.c configure.ac osx_write.c write.c The resolutions for these conflicts were recorded with git rerere and have been tested for quite some time. Cooking for three weeks. * refs/heads/t/lopsub: (74 commits) audioc: Avoid double free in audioc_i9e_line_handler(). audiod: Avoid uninitialized memory access. Simplify mixer setup. mixer: Implement non-linear time scale for fading. mixer: Allow arbitrary relative time for sleep subcommand. Convert para_fade to subcommands, rename it to para_mixer. build: Create .dep files only during compilation. build: Simplify definition of $m4_lls_deps. build: Rename command list variables. build: Combine $(CFLAGS) and $(STRICT_CFLAGS). build: Let .d files depend only on .c. build: Don't create phony targets for dependencies. build: Remove duplicate dependency. build: Remove cmdline_dir and friends. build: Remove some unused variables from Makefile.real. build: Remove m4/gengetopt. Remove gengetopt and help2man checks from configure.ac. Remove man_util.bash. Remove ggo.c and ggo.h. manual: Do not mention gengetopt and help2man any more. ...
Convert para_afh to lopsub. This commit replaces the gengetopt file for para_afh by the lopsub suite afh.suite and links the executable with --llopsub. The patch also adds a short description of the two operating modes of para_afh (print or modify) to the manual page para_afh(1).
afh: Dynamic chunks. paraslash chunk tables were designed long ago with the idea that the full audio file, with the exception of a potential header, is going to be sent to the client. This allows to store a sequence of offsets as the chunk table. Each chunk is defined as the contiguous region of the file given by two consecutive offsets. For most audio formats, however, not every part of the file corresponds to encoded audio. We work around this on the client side by letting the filters detect and skip those parts which can not be fed to the decoder. This works generally well, but for the aac decoder we have a rather ugly hack that skips over any non aac decoded data of its input. This hack was never very reliable, and the concept of dynamic chunks finally allows to get rid of it. Dynamic chunks work as follows. Each audio format handler signifies support by defining the new ->get_chunk method. In this case afh_get_chunk() no longer consults the chunk table at all but calls the new method instead in order to obtain a reference to the chunk. This comes with a certain overhead at runtime because we need to call into the functions of the mp4ff library (ships together with faad) rather looking up the offset in the chunk table. Only the aac audio format handler supports dynamic chunks per this commit. To keep the patch size relatively small, this commit does not touch ->get_file_info() of the aac audio format handler. Therefore, when a new m4a file is added to the database, the aac audio format handler still creates the chunk table. A subsequent commit will turn off this unnecessary operation. The documentation is updated to mention that mp4ff is now required for the aac audio format handler. The configure script now checks for the mp4ff header and the library and deactivates aac support if it was not found.
Simplify the error subsystem, get rid of error2.[ch]. 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.
afh: Print help if no arguments are given. Currently, if para_afh is invoked with no non-option arguments, the command fails with main: afh syntax error This message is not very helpful, so let's print the short help in this case, and exit successfully.
The wma tagger. This adds infrastructure to support meta tag editing. If the new --modify option is given to para_afh, the arguments to --title, --artist, --album and --comment are used to alter the meta information of the audio file. Only the wma audio format handler is extended to support the new feature. Patches for other audio format handlers follow. As for the implementation, this commit adds the function pointer ->rewrite_tags to struct audio_format_handler. This function takes a file descriptor to a newly opened temporary file. The individual audio format handlers are supposed to write the altered contents to this file descriptor. On success, the temporary file is renamed on top of the original file unless --backup is given. Since meta tags in wma files are encoded in UTF-16 we need primitives to convert from UTF8 to UTF16 and vice versa. These are provided by libiconv, so we check for this library and deactivate the new features on systems that lack libiconv. Unfortunately the signatures of iconv() are different between Linux and FreeBSD. To deal with this incompatibility this patch adds a configure check to determine if the cast is necessary.
afh: Fix fd leak. The main() function of para_afh obtains the open file descriptor from mmap_full_file() which is then passed to compute_afhi(). If this file descriptor is never closed, we have an fd leak. Unfortunately it depends on the audio format handler whether fd gets closed or not: the mp3 audio format handler closes it through libid3tag's id3_file_close() while all other audio format handlers leave it open. Fix this by changing mp3_get_id3() to operate on a copy of the fd instead so that the original fd remains open. The newly added close() in afh.c thus fixes the fd leak and never closes an invalid fd.
afh: Unmap the audio file on errors. If compute_afhi() returns negative we miss to call para_munmap() to unmap the audio file. This is not a serious bug since we exit anyway in this case.
Update year in copyright headers. 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.de 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
Change copyright year to 2014. 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
afh: Initialize audio format handlers only once. afc.c calls afh_init() twice. This does not really hurt as this function is idempotent, but it causes the initialization log messages to be printed twice. This gets rid of the additional call to afh_init() which crept in in commit 042767ce (Use self-made help to avoid recompilations on version changes).
afh/play: Include supported audio formats in help output. This is useful information, and it is simple to do, so include it in the help.