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.
Remove ->fd of struct audio file data. This structure contains information about the next audio file. It is stored in a shared memory area, and a reference to this area is sent through a pipe from the afs process to the server process. The file descriptor of the next audio file, however, must be passed via Unix socket magic (SCM_RIGHTS) and thus does not need to be part of the structure. Moreover, it's easier to define the afd structure in open_and_update_audio_file() of aft.c rather than in its caller, open_next_audio_file() of afs.c, because the caller only needs the fd of the audio file and the shared memory ID but not the audio file data structure itself. Expand the documentation of open_and_update_audio_file() a bit while at it.
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: Introduce audio_format_names[]. This removes .name of struct audio_format in favor of an array of strings. This will allow us to make afl[] a constant array of pointers, some of which may be NULL to indicate that the audio format was not compiled in. This temporarily duplicates the list of audio formats. The second list will be removed in a subsequent commit.
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 }'
doxygen: Add \ref to references. This way doxygen issues a warning if the file/function/structure no longer exists and a stale reference remains.
aac_afh: Don't create chunk tables any more. A previous commit activated dynamic chunks for the aac audio format handler, so the virtual streaming system no longer consults the chunk table stored in the audio file table of the osl database. However, the code to open or add an audio file still assumes that there is a chunk table and bails out if it can't find it. This patch changes aft.c to do without a chunk table if the audio format handler supports dynamic chunks. The afh_supports_dynamic_chunks() helper needs to be made public because of this. With chunk tables being optional, the ->get_file_info method of the audio format handler can safely set ->chunk_table to NULL. It still needs to compute the maximum chunk size though.
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.
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.
afh.h: Fix typo in prototype of ->get_file_info(). The structure is called afhi throughout the tree.
afh.h: Trivial whitespace fix. Git complains about this: "space before tab in indent".
afh: Make ->suffixes array const. Not only the individual strings are constant, but also the array itself.
afh: Make ->chunks_total and ->seconds_total fixed-size. These members of struct afh_info are stored as 4-byte quantities in the serialized afhi blob created by save_afhi(), so the structure should declare them as uint32_t rather than unsigned long. Fortunately, this bug is benign since save_afhi() uses the write_u32() helper from portable_io.h which does the right thing, regardless of the type of the variable passed.
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.
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.
afh.h: Trivial whitespace fix.
Make senders independent of afs and osl. Although senders don't know anything about the osl databases of the audio file selector, all senders currently include afs.h and osl.h. This is because: * senders are part of para_server, so they include server.h, * server.h has an audio_file_data structure embedded in struct misc_meta_data, so struct audio_file_data must be declared before server.h is included, * struct audio_file_data is declared in afs.h, * afs.h makes use of structures defined in <osl.h>. This patch moves the declaration of struct audio_file_data from afs.h to afh.h, which is also included by all senders. This allows to remove the two include directives for afs.h and osl.h from all three senders.
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
Never start playback at an empty chunk. The chunk table of ogg/* audio files often contains "empty" chunks which correspond to time slices for which the virtual streaming system does not need to send any data. When playback is started at an empty chunk, an unnecessary delay results. To overcome this issue, this commit introduces a new public helper afh_get_start_chunk() which looks for the first non-empty chunk before the given chunk number. The new function is called from afh_recv.c and from vss.c so that both para_play and para_server now avoid to start streaming at an empty chunk.
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