]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afh: Constify definition of audio format handlers.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 25 Sep 2018 19:41:20 +0000 (21:41 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 21 Dec 2018 13:40:42 +0000 (14:40 +0100)
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.


No differences found