string: Introduce arr_alloc(). Change all callers of alloc() which pass a product of two integers as the allocation size to call the new function instead. This function aborts if the multiplication overflows. With arr_alloc() in place, alloc() reduces to a trivial wrapper which calls new arr_alloc() with the first argument equal to one.
string: Rename para_calloc() -> zalloc(). Reword the documentation a bit since the function has never been a wrapper for calloc(3). No code changes.
string: Rename para_malloc() -> alloc(). Just because it's shorter and matches the naming of the new allocators we are about to introduce. The bulk of this patch was created with sed -i 's/para_malloc/alloc/g' *.c *.h yy/mp.y
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.
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 }'
wma_afh: Add some assert() statements. The clang static analyzer seems to have a hard time proving that if convert_utf8_to_utf16() returns non-negative, the destination pointer is non-null. This patch should help it.
wma_afh: Remove some dead stores. scan-build complains with Value stored to 'orig_title_bytes' is never read and similar for orig_artist_bytes and orig_comment_bytes. Indeed, these variables are only referenced in the if clause but not in the else clause. This commit makes them local to the if clause and removes the dead stores in the else clause..
Merge branch 'maint' A couple of fixes found by the clang static analyzer. * maint: aft: Check return value of load_afsi(). audiod: Avoid reading garbage in get_time_string(). net: Always initialize struct sockaddr_storage. wma_afh: Fix two bugs in convert_utf8_to_utf16().
Merge branch 'refs/heads/t/dynamic_chunks' A rather long and intrusive series that finally improves the aac decoder and audio format handler. The merge had a minor conflict in error.h, which was easily resolved by removing both affected error codes. Cooking for a month. * refs/heads/t/dynamic_chunks: (24 commits) afh_recv: Check return value of afh_get_chunk(). aacdec: Decode only one frame per iteration. aacdec: Combine aac_open() and aacdec_open(). aacdec: Make "initialized" a boolean. aacdec: Make frame_info local to ->post_select(). aacdec: Remove pointless assignment. aacdec: Remove pointless check and improve comment. aacdec: Rename buffer variables. aacdec: Remove pointless variable p. aacdec: Remove check which is always true. aacdec: Kill pointless label. aacdec: Remove superfluous assignment. aacdec: Improve and silence error message. aacdec: Prefer NeAACDecInit() over NeAACDecInit2(). aacdec: Don't eat full buffer on errors. Combine aacdec and aac_common. Convert the aac audio format handler to libmp4ff. aac_afh: Don't create chunk tables any more. afh: Dynamic chunks. server: Store max chunk size in database. ...
wma_afh: Fix two bugs in convert_utf8_to_utf16(). This function has two issues: * If iconv_open() fails and src is NULL (or *src is NULL) we attempt to close an invalid file descriptor. * On errors, we free *dst but miss to set it to NULL, causing a double free in the caller. This patch addresses both issues. The double free was found by the clang static analyzer.
wma_afh.c: Remove condition which is always true. The single caller of count_frames() never passes a NULL pointer.
wma_afh.c: Use DIV_ROUND_UP(). This kills another open-coded instance of DIV_ROUND_UP().
server: Store max chunk size in database. This number is needed up-front for the initialization of the fec data structures. Currently we recompute it from the chunk table each time the file is opened for streaming. We can only get rid of the chunk table concept if we tell the VSS by other means how to obtain this information. Fortunately there is an unused 4-byte field in the on-disk afhi structure, which is always zero at the moment. This patch starts to use this field to store the maximal chunk size. For backwards compatibility, when the afhi structure is loaded from disk at stream time, we check if the field is zero and recompute the max chunk size as before in this case. Although the maximal chunk size is generally only needed on the server side, for consistence we expose it though a new status item along with chunk_tv and friends.
wma: Fix packet size calculation. Usually the (fixed) packet size of a wma file equals the block align value plus WMA_FRAME_SKIP. However, this is not true in general, and if the two values differ, we fail to decode the file and bail out with an "incoherent block length" error. This patch adds code to read the correct packet size from the file properties object and uses this value in the decoder and the audio format handler.
afh: Make ->suffixes array const. Not only the individual strings are constant, but also the array itself.
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.
wma: Rename comment_header. The correct term for this header is "content description header".
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.
Remove unnecessary system header includes. All these headers get included from para.h.
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